Merge 233103, 233912 from head:

233103:
Some software think a mutex can be destroyed after it owned it, for
example, it uses a serialization point like following:
	pthread_mutex_lock(&mutex);
	pthread_mutex_unlock(&mutex);
	pthread_mutex_destroy(&muetx);
They think a previous lock holder should have already left the mutex and
is no longer referencing it, so they destroy it. To be maximum compatible
with such code, we use IA64 version to unlock the mutex in kernel, remove
the two steps unlocking code.

233912:
umtx operation UMTX_OP_MUTEX_WAKE has a side-effect that it accesses
a mutex after a thread has unlocked it, it event writes data to the mutex
memory to clear contention bit, there is a race that other threads
can lock it and unlock it, then destroy it, so it should not write
data to the mutex memory if there isn't any waiter.
The new operation UMTX_OP_MUTEX_WAKE2 try to fix the problem. It
requires thread library to clear the lock word entirely, then
call the WAKE2 operation to check if there is any waiter in kernel,
and try to wake up a thread, if necessary, the contention bit is set again
by the operation. This also mitgates the chance that other threads find
the contention bit and try to enter kernel to compete with each other
to wake up sleeping thread, this is unnecessary. With this change, the
mutex owner is no longer holding the mutex until it reaches a point
where kernel umtx queue is locked, it releases the mutex as soon as
possible.
Performance is improved when the mutex is contensted heavily.  On Intel
i3-2310M, the runtime of a benchmark program is reduced from 26.87 seconds
to 2.39 seconds, it even is better than UMTX_OP_MUTEX_WAKE which is
deprecated now. http://people.freebsd.org/~davidxu/bench/mutex_perf.c

Special code for stable/9:
And add code to detect if the UMTX_OP_MUTEX_WAKE2 is available.
MFC r233939:
 Free ballooned pages with the corresponding malloc type.
MFC 233296,233300:
 Prevent fs_file NULL pointer dereference.
MFC 234059:
Recognize the RDRAND instruction feature.
MFC r233175:
  Make kern.geom.part node not static. Also add CTLFLAG_TUN to the
  check_integrity sysctl.
MFC r233176:
  Add new GEOM_PART_LDM module that implements the Logical Disk Manager
  scheme. The LDM is a logical volume manager for MS Windows NT and it
  is also known as dynamic volumes. It supports about 2000 partitions
  and also provides the capability for software RAID implementations.

  This version implements only partitioning scheme capability and based
  on the linux-ntfs project documentation and several publications across
  the Web. NOTE: JBOD, RAID0 and RAID5 volumes aren't supported.

  An access to the LDM metadata is read-only. When LDM is on the disk
  partitioned with MBR we can also destroy metadata. For the GPT
  partitioned disks destroy action is not supported.

MFC r233177:
  Connect geom_part_ldm module to the build.

MFC r233178:
  Connect geom_part_ldm to the kernel build.

MFC r233181:
  Add CTLFLAG_TUN to sysctls.

MFC r233651:
  Do proper cleanup for the GPT case when an error occurs.

MFC r233652:
  VMDB offset should be greater than logical volume size only for MBR.
MFC r233179:
  Document GEOM_PART_LDM scheme and partition types.
MFC r234122:
  It seems that libdisk(3) incorrectly sets d_secperunit value.
  Automatically fix it like GEOM_PART_BSD does.

  PR:		bin/165789
MFC r233711:
Major update to driver to support for Drake Skinny and ThunderBolt cards.

MFC r233768:
Change typedef atomic_t to struct mfi_atomic to avoid name space
collision and some couple more style changes.

MFC r233805:
Move struct megasas_sge from mfi_ioctl.h to mfivar.h so we can
remove including machine/bus.h.  Add some more mfi_ prefixes to
avoid name space pollution.

MFC r233877:
- Do not include machine/atomic.h.  It is no longer necessary since r233768.
- Remove bogus "atomic" macros and a read-only variable from softc.
MFC r233713
Remove the magic mfi_array is 288 bytes and just use the
sizeof the array since it is not 288 bytes.

Change reporting of a "SYSTEM" disk to "JBOD" to match
LSI MegaCli and firmware reporting.

This means that mfiutil command to "create jbod" is now a
little confusing since a RAID per drive is not really what
LSI defines JBOD to be.  This should be fixed in the future
and support added to really create LSI JBOD and enable that
feature on cards that support it.
MFC r230778
When detaching an AIO or LIO requests grab the lock and tell knlist_remove
that we have the lock now.  This cleans up a locking panic ASSERT when
knlist_empty is called without a lock when INVARIANTS etc. are turned.
MFC r234058:
  In kdump's mkioctls script, use '${CPP}' instead of hardcodedly using
  'gcc -E'.  This fixes building when WITH_CLANG_IS_CC is in effect.

  Report by:	Niclas Zeising <zeising@daemonic.se>

MFC r234060:
  Since truss also uses kdump's mkioctls script, pass the value of ${CPP}
  there too, similar to r234058.
MFC r234336:
Fix typo miror -> mirror

Reported by:	Glen Barber <gjb@FreeBSD.org>
MFC r234170:
Propagate the current state of rtld_bind_lock to dlopen_object() calls
through the filter loading call chain. This fixes attempts to
write-lock the already locked rtld_bind_lock when filter loading is
initiated by relocation of dlopening dso.
MFC r234172:
Add thread-private flag to indicate that error value is already placed
in td_errno. Flag is supposed to be used by syscalls returning
EJUSTRETURN because errno was already placed into the usermode frame
by a call to set_syscall_retval(9). Both ktrace and dtrace get errno
value from td_errno if the flag is set.

Use the flag to fix sigsuspend(2) error return ktrace records.
MFC of 233627, 234024, 234025, and 234026

Restore per mount-point counts of synchronous and asynchronous
reads and writes associated with UFS and MSDOS filesystems.

MFS 233627:
Keep track of the mount point associated with a special device
to enable the collection of counts of synchronous and asynchronous
reads and writes for its associated filesystem. The counts are
displayed using `mount -v'.

Ensure that buffers used for paging indicate the vnode from
which they are operating so that counts of paging I/O operations
from the filesystem are collected.

This checkin only adds the setting of the mount point for the
UFS/FFS filesystem, but it would be trivial to add the setting
and clearing of the mount point at filesystem mount/unmount
time for other filesystems too.

Reviewed by: kib

MFC 234024:
Drop an unnecessary setting of si_mountpt when updating a UFS mount point.
Clearly it must have been set when the mount was done.

Reviewed by: kib

MFC 234025:
Add I/O accounting to msdos filesystem.

Suggested and reviewed by: kib

MFC 234026:
Expand locking around identification of filesystem mount point when
accounting for I/O counts at completion of I/O operation. Also switch
from using global devmtx to vnode mutex to reduce contention.

Suggested and reviewed by: kib
MFC:	r234350

- When interrupt is not requested for VM86 call, make a fake exit point and
push the address onto stack as we do for INTn emulation.  This avoids stack
underflow when we encounter RETF instruction in VM86 mode.  Lack of this
exit point actually caused page fault in VM86 mode with VESA module when we
resume from suspend state.
- Remove unnecessary CLI and STI instructions from BIOS interrupt emulation.
INTn and IRET must be able to emulate the flag correctly.
MFV r234164/MFC r234165:

The BIND 9.8.2 tarball was re-rolled to remove 9.8.1 release notes.
This change was noticed by ISC at:

https://lists.isc.org/pipermail/bind-users/2012-April/087345.html

and verified by me both by comparing the contents of the old and new
distfiles and by verifying the PGP signature on the new distfile.
MFC of 233817:

A file cannot be deallocated until its last name has been removed
and it is no longer referenced by a user process. The inode for a
file whose name has been removed, but is still referenced at the
time of a crash will still be allocated in the filesystem, but will
have no references (e.g., they will have no names referencing them
from any directory).

With traditional soft updates these unreferenced inodes will be
found and reclaimed when the background fsck is run. When using
journaled soft updates, the kernel must keep track of these inodes
so that it can find and reclaim them during the cleanup process.
Their existence cannot be stored in the journal as the journal only
handles short-term events, and they may persist for days. So, they
are tracked by keeping them in a linked list whose head pointer is
stored in the superblock. The journal tracks them only until their
linked list pointers have been commited to disk. Part of the cleanup
process involves traversing the list of unreferenced inodes and
reclaiming them.

This bug was triggered when confusion arose in the commit steps
of keeping the unreferenced-inode linked list coherent on disk.
Notably, a race between the link() system call adding a link-count
to a file and the unlink() system call removing a link-count to
the file. Here if the unlink() ran after link() had looked up
the file but before link() had incremented the link-count of the
file, the file's link-count would drop to zero before the link()
incremented it back up to one. If the file was referenced by a
user process, the first transition through zero made it appear
that it should be added to the unreferenced-inode list when in
fact it should not have been added. If the new name created by
link() was deleted within a few seconds (with the file still
referenced by a user process) it would legitimately be a candidate
for addition to the unreferenced-inode list. The result was that
there were two attempts to add the same inode to the unreferenced-inode
list which scrambled the unreferenced-inode list's pointers leading
to a panic. The fix is to detect and avoid the false attempt at
adding it to the unreferenced-inode list by having the link()
system call check to see if the link count is zero before it
increments it. If it is, the link() fails with ENOENT (showing that
it has failed the link()/unlink() race).

While tracking down this bug, we have added additional assertions
to detect the problem sooner and also simplified some of the code.

Reported by:      Kirk Russell
Fix submitted by: Jeff Roberson
Tested by:        Peter Holm
PR:               kern/159971
MFC of 234157:

Whitespace cleanup.