kernel - Rewrite lockmgr / struct lock
* Rewrite lockmgr() to remove the exclusive spinlock used internally
to guard operations.
* Retain existing API and operational semantics. This is primarily:
- Acquiring a LK_SHARED lock on a lock the caller already owns
exclusively simply bumps the count and retains the exclusive
nature of the lock.
- Exclusive requests and upgrade requests have priority over shared
locks even if the lock is currently held shared, unless the thread
is flagged for deadlock treatment.
- Upgrade requests are capable of guaranteeing the upgrade (as before).
This could be further enhanced because we now have the last release
transfer the exclusive lock to the upgrade requestor, but the original
API didn't have a function for this so neither do we. The more
primitive detection method is used (aka LK_SLEEPFAIL and/or
LK_EXCLUPGRADE).
* Reduce multiple tracking fields into one field so we can use
atomic_cmpset_int().
* Hot-path common operations. A single atomic_cmpset_int() gets us
through.