LWN.net Logo

4/5: LSM hooks rework

From:  Kurt Garloff <garloff@suse.de>
To:  Linux kernel list <linux-kernel@vger.kernel.org>
Subject:  [PATCH] 4/5: LSM hooks rework
Date:  Sun, 13 Feb 2005 16:12:10 -0500
Cc:  Andreas Gruenbacher <agruen@suse.de>, James Morris <jmorris@redhat.com>, Chris Wright <chrisw@osdl.org>

From: Kurt Garloff <garloff@suse.de>
Subject: Consider the capability case the likely one
References: 40217, 39439

The case that security_ops points to the default capability_
security_ops is the fast path and arguably the more likely one
on most systems. So mark it likely to tell the compiler to
optimize accordingly and increase the chances of having this
predicted correctly by the CPU.

This is patch 4/5 of the LSM overhaul.

 security.h |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

Signed-off-by: Kurt Garloff <garloff@suse.de>

Index: linux-2.6.10/include/linux/security.h
===================================================================
--- linux-2.6.10.orig/include/linux/security.h
+++ linux-2.6.10/include/linux/security.h
@@ -1253,9 +1253,9 @@ extern int mod_reg_security	(const char 
 extern int mod_unreg_security	(const char *name, struct security_operations
*ops);
 
 /* Condition for invocation of non-default security_op */
 #define COND_SECURITY(seop, def) 	\
-	(security_ops == &capability_security_ops)? def: security_ops->seop
+	(likely(security_ops == &capability_security_ops))? def: security_ops->seop
 
 #else /* CONFIG_SECURITY */
 static inline int security_init(void)
 {
-- 
Kurt Garloff, Director SUSE Labs, Novell Inc.


Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds