From d423f266c4fc1939678262d5024de087b1291625 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 6 Jan 2009 14:15:38 +0000 Subject: [PATCH] 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. --- sys/security/audit/audit_pipe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/security/audit/audit_pipe.c b/sys/security/audit/audit_pipe.c index ef4fc83d9e07..afc7d5473196 100644 --- a/sys/security/audit/audit_pipe.c +++ b/sys/security/audit/audit_pipe.c @@ -436,6 +436,10 @@ audit_pipe_preselect(au_id_t auid, au_event_t event, au_class_t class, { 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);