[PATCH] 4/5: LSM hooks rework

From: Kurt Garloff
Date: Sun Feb 13 2005 - 16:24:29 EST


From: Kurt Garloff <garloff@xxxxxxx>
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@xxxxxxx>

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.

Attachment: pgp00000.pgp
Description: PGP signature