Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jan 2009 14:15:38 +0000 (UTC)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r186825 - head/sys/security/audit
Message-ID:  <200901061415.n06EFc91033354@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901061415.n06EFc91033354>