From owner-cvs-src-old@FreeBSD.ORG Sat Mar 14 16:06:27 2009 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 45510106564A for ; Sat, 14 Mar 2009 16:06:27 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2E6EF8FC08 for ; Sat, 14 Mar 2009 16:06:27 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EG6Rcm029151 for ; Sat, 14 Mar 2009 16:06:27 GMT (envelope-from rwatson@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n2EG6RZ5029149 for cvs-src-old@freebsd.org; Sat, 14 Mar 2009 16:06:27 GMT (envelope-from rwatson@repoman.freebsd.org) Message-Id: <200903141606.n2EG6RZ5029149@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to rwatson@repoman.freebsd.org using -f From: Robert Watson Date: Sat, 14 Mar 2009 16:06:06 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/security/mac mac_atalk.c mac_audit.c mac_cred.c mac_framework.c mac_inet.c mac_inet6.c mac_internal.h mac_net.c mac_pipe.c mac_posix_sem.c mac_posix_shm.c mac_priv.c mac_process.c mac_socket.c mac_syscalls.c mac_system.c ... X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 16:06:27 -0000 rwatson 2009-03-14 16:06:06 UTC FreeBSD src repository Modified files: sys/security/mac mac_atalk.c mac_audit.c mac_cred.c mac_framework.c mac_inet.c mac_inet6.c mac_internal.h mac_net.c mac_pipe.c mac_posix_sem.c mac_posix_shm.c mac_priv.c mac_process.c mac_socket.c mac_syscalls.c mac_system.c mac_sysv_msg.c mac_sysv_sem.c mac_sysv_shm.c mac_vfs.c Log: SVN rev 189797 on 2009-03-14 16:06:06Z by rwatson 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) Revision Changes Path 1.2 +6 -2 src/sys/security/mac/mac_atalk.c 1.7 +5 -5 src/sys/security/mac/mac_audit.c 1.4 +17 -17 src/sys/security/mac/mac_cred.c 1.143 +72 -111 src/sys/security/mac/mac_framework.c 1.24 +45 -28 src/sys/security/mac/mac_inet.c 1.4 +16 -9 src/sys/security/mac/mac_inet6.c 1.128 +80 -19 src/sys/security/mac/mac_internal.h 1.134 +23 -16 src/sys/security/mac/mac_net.c 1.116 +12 -10 src/sys/security/mac/mac_pipe.c 1.17 +9 -9 src/sys/security/mac/mac_posix_sem.c 1.4 +10 -9 src/sys/security/mac/mac_posix_shm.c 1.6 +2 -2 src/sys/security/mac/mac_priv.c 1.131 +5 -5 src/sys/security/mac/mac_process.c 1.15 +34 -26 src/sys/security/mac/mac_socket.c 1.139 +8 -4 src/sys/security/mac/mac_syscalls.c 1.115 +7 -7 src/sys/security/mac/mac_system.c 1.13 +18 -13 src/sys/security/mac/mac_sysv_msg.c 1.12 +9 -8 src/sys/security/mac/mac_sysv_sem.c 1.11 +12 -10 src/sys/security/mac/mac_sysv_shm.c 1.130 +19 -16 src/sys/security/mac/mac_vfs.c