freebsd-skq/sys/security/mac
rwatson 874a1578bb 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
..
mac_atalk.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_audit.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_cred.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_framework.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_framework.h Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00
mac_inet6.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_inet.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_internal.h Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_label.c Introduce accessor functions mac_label_get() and mac_label_set() to replace 2007-02-06 14:19:25 +00:00
mac_net.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_pipe.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_policy.h Remove 'uio' argument from MAC Framework and MAC policy entry points for 2009-03-08 12:32:06 +00:00
mac_posix_sem.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_posix_shm.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_priv.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_process.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_socket.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_syscalls.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_system.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_sysv_msg.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_sysv_sem.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_sysv_shm.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00
mac_vfs.c Rework MAC Framework synchronization in a number of ways in order to 2009-03-14 16:06:06 +00:00