svn commit: r186825 - head/sys/security/audit

Robert Watson rwatson at FreeBSD.org
Tue Jan 6 06:15:39 PST 2009


Author: rwatson
Date: Tue Jan  6 14:15:38 2009
New Revision: 186825
URL: http://svn.freebsd.org/changeset/base/186825

Log:
  Do a lockless read of the audit pipe list before grabbing the audit pipe
  lock in order to avoid the lock acquire hit if the pipe list is very
  likely empty.
  
  Obtained from:	TrustedBSD Project
  MFC after:	3 weeks
  Sponsored by:	Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==============================================================================
--- head/sys/security/audit/audit_pipe.c	Tue Jan  6 14:10:30 2009	(r186824)
+++ head/sys/security/audit/audit_pipe.c	Tue Jan  6 14:15:38 2009	(r186825)
@@ -436,6 +436,10 @@ audit_pipe_preselect(au_id_t auid, au_ev
 {
 	struct audit_pipe *ap;
 
+	/* Lockless read to avoid acquiring the global lock if not needed. */
+	if (TAILQ_EMPTY(&audit_pipe_list))
+		return (0);
+
 	AUDIT_PIPE_LIST_RLOCK();
 	TAILQ_FOREACH(ap, &audit_pipe_list, ap_list) {
 		AUDIT_PIPE_LOCK(ap);


More information about the svn-src-head mailing list