All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] SELinux: remove the unused ae.used
@ 2009-02-12 19:50 Eric Paris
  2009-02-12 19:50 ` [PATCH 2/5] SELinux: more careful use of avd in avc_has_perm_noaudit Eric Paris
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Eric Paris @ 2009-02-12 19:50 UTC (permalink / raw)
  To: selinux; +Cc: sds, jmorris, paul.moore

Currently SELinux code has an atomic which was intended to track how many
times an avc entry was used and to evict entries when they haven't been
used recently.  Instead we never let this atomic get above 1 and evict when
it is first checked for eviction since it hits zero.  This is a total waste
of time so I'm completely dropping ae.used.

This change resulted in about a 3% faster avc_has_perm_noaudit when running
oprofile against a tbench benchmark.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 security/selinux/avc.c |   28 +++++++---------------------
 1 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index 703aba1..abfe378 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -88,7 +88,6 @@ struct avc_entry {
 	u32			tsid;
 	u16			tclass;
 	struct av_decision	avd;
-	atomic_t		used;	/* used recently */
 };
 
 struct avc_node {
@@ -321,16 +320,13 @@ static inline int avc_reclaim_node(void)
 
 		rcu_read_lock();
 		list_for_each_entry(node, &avc_cache.slots[hvalue], list) {
-			if (atomic_dec_and_test(&node->ae.used)) {
-				/* Recently Unused */
-				avc_node_delete(node);
-				avc_cache_stats_incr(reclaims);
-				ecx++;
-				if (ecx >= AVC_CACHE_RECLAIM) {
-					rcu_read_unlock();
-					spin_unlock_irqrestore(&avc_cache.slots_lock[hvalue], flags);
-					goto out;
-				}
+			avc_node_delete(node);
+			avc_cache_stats_incr(reclaims);
+			ecx++;
+			if (ecx >= AVC_CACHE_RECLAIM) {
+				rcu_read_unlock();
+				spin_unlock_irqrestore(&avc_cache.slots_lock[hvalue], flags);
+				goto out;
 			}
 		}
 		rcu_read_unlock();
@@ -350,7 +346,6 @@ static struct avc_node *avc_alloc_node(void)
 
 	INIT_RCU_HEAD(&node->rhead);
 	INIT_LIST_HEAD(&node->list);
-	atomic_set(&node->ae.used, 1);
 	avc_cache_stats_incr(allocations);
 
 	if (atomic_inc_return(&avc_cache.active_nodes) > avc_cache_threshold)
@@ -383,15 +378,6 @@ static inline struct avc_node *avc_search_node(u32 ssid, u32 tsid, u16 tclass)
 		}
 	}
 
-	if (ret == NULL) {
-		/* cache miss */
-		goto out;
-	}
-
-	/* cache hit */
-	if (atomic_read(&ret->ae.used) != 1)
-		atomic_set(&ret->ae.used, 1);
-out:
 	return ret;
 }
 


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-02-13 22:45 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 19:50 [PATCH 1/5] SELinux: remove the unused ae.used Eric Paris
2009-02-12 19:50 ` [PATCH 2/5] SELinux: more careful use of avd in avc_has_perm_noaudit Eric Paris
2009-02-12 20:30   ` Paul Moore
2009-02-13 14:20   ` Stephen Smalley
2009-02-13 22:45   ` James Morris
2009-02-12 19:50 ` [PATCH 3/5] SELinux: remove unused av.decided field Eric Paris
2009-02-12 20:33   ` Paul Moore
2009-02-13 17:26   ` Stephen Smalley
2009-02-13 22:45   ` James Morris
2009-02-12 19:50 ` [PATCH 4/5] SELinux: code readability with avc_cache Eric Paris
2009-02-12 20:39   ` Paul Moore
2009-02-13 22:45   ` James Morris
2009-02-12 19:51 ` [PATCH 5/5] SELinux: convert the avc cache hash list to an hlist Eric Paris
2009-02-12 20:40   ` Paul Moore
2009-02-13 22:45   ` James Morris
2009-02-12 20:15 ` [PATCH 1/5] SELinux: remove the unused ae.used Paul Moore
2009-02-12 20:26   ` Eric Paris
2009-02-13  6:45     ` KaiGai Kohei
2009-02-13 14:12 ` Stephen Smalley
2009-02-13 22:44 ` James Morris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.