freebsd-dev/sys/security
Robert Watson 4020272933 Rework MAC Framework synchronization in a number of ways in order to
improve performance:

- Eliminate custom reference count and condition variable to monitor
  threads entering the framework, as this had both significant overhead
  and behaved badly in the face of contention.

- Replace reference count with two locks: an rwlock and an sx lock,
  which will be read-acquired by threads entering the framework
  depending on whether a give policy entry point is permitted to sleep
  or not.

- Replace previous mutex locking of the reference count for exclusive
  access with write acquiring of both the policy list sx and rw locks,
  which occurs only when policies are attached or detached.

- Do a lockless read of the dynamic policy list head before acquiring
  any locks in order to reduce overhead when no dynamic policies are
  loaded; this a race we can afford to lose.

- For every policy entry point invocation, decide whether sleeping is
  permitted, and if not, use a _NOSLEEP() variant of the composition
  macros, which will use the rwlock instead of the sxlock.  In some
  cases, we decide which to use based on allocation flags passed to the
  MAC Framework entry point.

As with the move to rwlocks/rmlocks in pfil, this may trigger witness
warnings, but these should (generally) be false positives as all
acquisition of the locks is for read with two very narrow exceptions
for policy load/unload, and those code blocks should never acquire
other locks.

Sponsored by:	Google, Inc.
Obtained from:	TrustedBSD Project
Discussed with:	csjp (idea, not specific patch)
2009-03-14 16:06:06 +00:00
..
audit Add a new thread-private flag, TDP_AUDITREC, to indicate whether or 2009-03-09 10:45:58 +00:00
mac Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_biba Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00
mac_bsdextended Mark the bsdextended rules sysctl as being mpsafe. 2009-03-09 17:42:18 +00:00
mac_ifoff Rather than having MAC policies explicitly declare what object types 2009-01-10 10:58:41 +00:00
mac_lomac Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00
mac_mls Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00
mac_none Rather than having MAC policies explicitly declare what object types 2009-01-10 10:58:41 +00:00
mac_partition Rather than having MAC policies explicitly declare what object types 2009-01-10 10:58:41 +00:00
mac_portacl Rather than having MAC policies explicitly declare what object types 2009-01-10 10:58:41 +00:00
mac_seeotheruids Rather than having MAC policies explicitly declare what object types 2009-01-10 10:58:41 +00:00
mac_stub Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00
mac_test Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00