diff options
author | Dimitri Sivanich <sivanich@sgi.com> | 2004-08-22 22:48:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-08-22 22:48:27 -0700 |
commit | 063583c19f01c91fdc5054c8947aeeb5c9a16032 (patch) | |
tree | 8c9542a24b781a5a5ba39b9d45322865052562f3 /mm | |
parent | cba5bbaad62c9d72caf399646458b095a93ffea8 (diff) | |
download | history-063583c19f01c91fdc5054c8947aeeb5c9a16032.tar.gz |
[PATCH] slab: locking optimization for cache_reap
Here is another cache_reap optimization that reduces latency when applied
after the 'Move cache_reap out of timer context' patch I submitted on 7/14
(for inclusion in -mm next week).
Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slab.c | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/mm/slab.c b/mm/slab.c index 74653f89ea624b..fd80d31fbab0ae 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2620,27 +2620,6 @@ static void enable_cpucache (kmem_cache_t *cachep) cachep->name, -err); } -static void drain_array(kmem_cache_t *cachep, struct array_cache *ac) -{ - int tofree; - - check_irq_off(); - if (ac->touched) { - ac->touched = 0; - } else if (ac->avail) { - tofree = (ac->limit+4)/5; - if (tofree > ac->avail) { - tofree = (ac->avail+1)/2; - } - spin_lock(&cachep->spinlock); - free_block(cachep, ac_entry(ac), tofree); - spin_unlock(&cachep->spinlock); - ac->avail -= tofree; - memmove(&ac_entry(ac)[0], &ac_entry(ac)[tofree], - sizeof(void*)*ac->avail); - } -} - static void drain_array_locked(kmem_cache_t *cachep, struct array_cache *ac, int force) { @@ -2694,16 +2673,14 @@ static void cache_reap(void *unused) goto next; check_irq_on(); - local_irq_disable(); - drain_array(searchp, ac_data(searchp)); - if(time_after(searchp->lists.next_reap, jiffies)) - goto next_irqon; + spin_lock_irq(&searchp->spinlock); - spin_lock(&searchp->spinlock); - if(time_after(searchp->lists.next_reap, jiffies)) { + drain_array_locked(searchp, ac_data(searchp), 0); + + if(time_after(searchp->lists.next_reap, jiffies)) goto next_unlock; - } + searchp->lists.next_reap = jiffies + REAPTIMEOUT_LIST3; if (searchp->lists.shared) @@ -2736,9 +2713,7 @@ static void cache_reap(void *unused) spin_lock_irq(&searchp->spinlock); } while(--tofree > 0); next_unlock: - spin_unlock(&searchp->spinlock); -next_irqon: - local_irq_enable(); + spin_unlock_irq(&searchp->spinlock); next: ; } |