MFC:	r233042, r233054, r233056, r233187

- Do not unnecessarily clear display memory when switching modes.
- Remove unnecessary static variable initializations and duplicate codes.
- Consistently use bcopy(9) over memcpy(9).
- Save and restore linear frame buffer between suspend and resume.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233581 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC:	r233208, r233249

Fix a witness panic.  We cannot enter critical section here.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233582 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC:	r233313

Add ACPI_LV_REPAIR debug level, available since ACPICA 20091214.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233583 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r230348:
	 - Fix warning when compiling with gcc46:
	        error: variable 'extra_async_bytes' set but not used

Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@233588 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233276:
  Acquire modules lock before call module_getname() in the KLD_DEBUG case.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233595 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232852:
Tune cpuset macros to optimize cases when CPU_SETSIZE fits into single
machine word. For example, it turns CPU_SET() into expected shift and OR,
removing extra shift, AND and additional index on memory access.

Generated code checked for kernel (optimized) and user-level (unoptimized)
cases with GCC and CLANG.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233598 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232207, r232454:
Rework CPU load balancing in SCHED_ULE:
 - In sched_pickcpu() be more careful taking previous CPU on SMT systems.
Do it only if all other logical CPUs of that physical one are idle to avoid
extra resource sharing.
 - In sched_pickcpu() change general logic of CPU selection. First
look for idle CPU, sharing last level cache with previously used one,
skipping SMT CPU groups. If none found, search all CPUs for the least loaded
one, where the thread with its priority can run now. If none found, search
just for the least loaded CPU.
 - Make cpu_search() compare lowest/highest CPU load when comparing CPU
groups with equal load. That allows to differentiate 1+1 and 2+0 loads.
 - Make cpu_search() to prefer specified (previous) CPU or group if load
is equal. This improves cache affinity for more complicated topologies.
 - Randomize CPU selection if above factors are equal. Previous code tend
to prefer CPUs with lower IDs, causing unneeded collisions.
 - Rework periodic balancer in sched_balance_group(). With cpu_search()
more intelligent now, make balansing process flat, removing recursion
over the topology tree. That fixes double swap problem and makes load
distribution more even and predictable.

All together this gives 10-15% performance improvement in many tests on
CPUs with SMT, such as Core i7, for number of threads is less then number
of logical CPUs. In some tests it also gives positive effect to systems
without SMT.

Sponsored by:	iXsystems, Inc.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233599 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: 232487
  Properly restore curvnet context when returning early from
  ether_input_internal().

  This change only affects options VIMAGE kernel builds.

  PR:           kern/165643
  Submitted by: Vijay Singh
  MFC after:    3 days


git-svn-id: svn://svn.freebsd.org/base/stable/9@233602 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232517:
  Change SYSINIT priorities so that ip_mroute_modevent() is executed
  before vnet_mroute_init(), since vnet_mroute_init() depends on mfchashsize
  tunable to be set, and that is done in in ip_mroute_modevent().
  Apparently I broke that ordering with r208744 almost 2 years ago...

  PR:           kern/162201
  Submitted by: Stevan Markovic (mcafee.com)
  MFC after:    3 days


git-svn-id: svn://svn.freebsd.org/base/stable/9@233604 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC:	r233313

Add ACPI_LV_REPAIR debug level, available since ACPICA 20091214.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233612 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232830:
Add a header with definitions useful for constructing ELF notes.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233624 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC Revision 233465

Correct failure to attach the PV block front device on Citrix
XenServer configurations that advertise the multi-page ring extension,
but only allow a single page of ring space.

sys/dev/xen/blkfront/blkfront.c:
	If only one page of ring space is being used, do not publish
	in the XenStore the number of pages in use (1), via either
	of the supported multi-page ring extension schemes.

	Single page operation is the same with or without the
	ring-page extension being negotiated.   Relying on the
	legacy behavior avoids an incompatible difference in how
	the two ring-page extension schemes that are out in the
	wild, deal with the base case of a single page.  The
	Amazon/Red Hat drivers use the same XenStore variable as
	if the extension was not negotiated.  The Citrix drivers
	assume the new ring reference XenStore variables will be
	available

Reported by:	Oliver Schonefeld <schonefeld@ids-mannheim.de>


git-svn-id: svn://svn.freebsd.org/base/stable/9@233626 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC of 232351, 233438, and 233629

MFC reviewed by: kib

MFC 232351:

This change avoids a kernel deadlock on "snaplk" when using
snapshots on UFS filesystems running with journaled soft updates.
This is the first of several bugs that need to be fixed before
removing the restriction added in -r230250 to prevent the use
of snapshots on filesystems running with journaled soft updates.

The deadlock occurs when holding the snapshot lock (snaplk)
and then trying to flush an inode via ffs_update(). We become
blocked by another process trying to flush a different inode
contained in the same inode block that we need. It holds the
inode block for which we are waiting locked. When it tries to
write the inode block, it gets blocked waiting for the our
snaplk when it calls ffs_copyonwrite() to see if the inode
block needs to be copied in our snapshot.

The most obvious place that this deadlock arises is in the
ffs_copyonwrite() routine when it updates critical metadata
in a snapshot and tries to write it out before proceeding.
The fix here is to write the data and indirect block pointer
for the snapshot, but to skip the call to ffs_update() to
write the snapshot inode. To ensure that we will never have
to update a pointer in the inode itself, the ffs_snapshot()
routine that creates the snapshot has to ensure that all the
direct blocks are allocated as part of the creation of the
snapshot.

A less obvious place that this deadlock occurs is when we hold
the snaplk because we are deleting a snapshot. In the course of
doing the deletion, we need to allocate various soft update
dependency structures and allocate some journal space. If we
hit a resource limit while doing this we decrease the resources
in use by flushing out an existing dirty file to get it to give
up the soft dependency resources that it holds. The flush can
cause an ffs_update() to be done on the inode for the file that
we have selected to flush resulting in the same deadlock as
described above when the inode that we have chosen to flush
resides in the same inode block as the snapshot inode that we hold.
The fix is to defer cleaning up any time that the inode on which
we are operating is a snapshot.

Help and review by:    Jeff Roberson
Tested by:             Peter Holm

MFC 233438:

Add a third flags argument to ffs_syncvnode to avoid a possible conflict
with MNT_WAIT flags that passed in its second argument.

Discussed with: kib

MFC 233629:

A refinement of change 232351 to avoid a race with a forcible unmount.
While we have a snapshot vnode unlocked to avoid a deadlock with another
inode in the same inode block being updated, the filesystem containing
it may be forcibly unmounted. When that happens the snapshot vnode is
revoked. We need to check for that condition and fail appropriately.

Spotted by:  kib
Reviewed by: kib


git-svn-id: svn://svn.freebsd.org/base/stable/9@233630 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233136, r233432:
	Restore the ability to use a non-standard LOCALBASE to sshd
	Add the ability to use a non-standard LOCALBASE to ssh

Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@233632 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r227489:
	- fix duplicate "a a" in some comments

Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@233640 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233291
  Handle spurious page faults that may occur in no-fault sections of the
  kernel.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233647 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232835:
Do not fall back to slow synchronous i/o when low on memory or buffers.
The bawrite() schedules the write to happen immediately, and its use
frees the current thread to do more cleanups.

MFC r232837:
Remove superfluous brackets.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233653 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232948:
Supply boolean as the second argument to ffs_update(), and not a
MNT_[NO]WAIT constants, which in fact always caused sync operation.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233654 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233096:

  Hide a few declarations from userland (including `struct inpcbgroup'). This
  removes the dependency on <machine/param.h> which was introduced with SVN
  rev 222748 (due to CACHE_LINE_SIZE).

  Reviewed by:    bde
  MFC after:      10 days


git-svn-id: svn://svn.freebsd.org/base/stable/9@233659 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r231300, r231328:
	Permit the use of relative paths for the prefix argument.
	Remove an unnecessary cwd from created plists when -p is specified

Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@233685 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f