kernel - Rewrite lockmgr / struct lock
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 21 Oct 2013 17:59:40 +0000 (10:59 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 21 Oct 2013 18:22:42 +0000 (11:22 -0700)
commit05eacabc4af23ec82366095309047efe01dc1d6b
tree298f76176ffbf883699a19b8e894e60191b713ab
parent381893162d4a19ee2bebf252f7801d5016140cf8
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.
sys/kern/kern_lock.c
sys/kern/vfs_lock.c
sys/kern/vfs_subr.c
sys/netproto/ncp/ncp_conn.c
sys/sys/lock.h
sys/vm/swap_pager.c