kernel - Introduce hard code sections, simplify critical sections & mplocks
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 29 Aug 2010 04:07:08 +0000 (21:07 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 29 Aug 2010 04:54:01 +0000 (21:54 -0700)
commit4a28fe22d241d9ebd6072389b0d87650b332b579
tree126fad7c79519ee6e297cc8ba0fcc18771a8b305
parent4041d91945fc1e4ba1bb1065fd5f9915983f8605
kernel - Introduce hard code sections, simplify critical sections & mplocks

* Introduce hard code sections with crit_enter_hard(), crit_exit_hard(),
  lwkt_gettoken_hard() and lwkt_reltoken_hard().

  These functions create a hard code section that, like an interrupt or ipi,
  does not allow any case which might potentially block or switch threads.
  While in a hard code section any such case will assert and panic the
  system.

  For example, acquiring a token that is not already held would be disallowed
  even if the acquisition could be accomplished without blocking.  However,
  acquiring a token which is already held would be allowed.  Same with the
  mplock, lockmgr locks, etc. (mtx's and serializers have not been dealt
  with yet).

* Introduce ASSERT_LWKT_TOKEN_HARD() and ASSERT_LWKT_TOKEN_CRIT().

  These assert that a token is held and a hard critical section (hard)
  or any critical section (crit) is in place.

* Rework the critical section macros and optimize the crit_exit*() code
  to two conditionals which are usually always false regardless of
  whether critcount is transitioning 1->0 or not.  Also declare
  crit_panic() __dead2 which may produce better code.

* Rework get_mplock() to reduce code generation.  The hard code section
  assertions would have made it too big.  We still optimize the case
  where the mplock is already held.
sys/kern/kern_lock.c
sys/kern/kern_mplock.c
sys/kern/lwkt_thread.c
sys/kern/lwkt_token.c
sys/sys/globaldata.h
sys/sys/mplock2.h
sys/sys/thread.h
sys/sys/thread2.h
sys/vm/vm_map.h