Bring back drain_array locked in the sense that it locks the array. Ironically we now bring drain_array_locked() back since there are common occurances where we need to lock the array. This allows further code consolidation. Signed-off-by: Christoph Lameter Index: linux-2.6.16-rc5-mm2/mm/slab.c =================================================================== --- linux-2.6.16-rc5-mm2.orig/mm/slab.c 2006-03-03 18:16:41.000000000 -0800 +++ linux-2.6.16-rc5-mm2/mm/slab.c 2006-03-03 18:16:43.000000000 -0800 @@ -956,6 +956,18 @@ static void drain_array(struct kmem_cach struct kmem_list3 *l3, struct array_cache *ac, int force, int node); +static void drain_array_locked(struct kmem_cache *cachep, + struct kmem_list3 *l3, struct array_cache *ac, + int force, int node) +{ + if (ac && ac->avail) { + spin_lock_irq(&ac->lock); + drain_array(cachep, cachep->nodelists[node], + ac, force, node); + spin_unlock_irq(&ac->lock); + } +} + /* * Called from cache_reap() to regularly drain alien caches round robin. */ @@ -963,15 +975,8 @@ static void reap_alien(struct kmem_cache { int node = __get_cpu_var(reap_node); - if (l3->alien) { - struct array_cache *ac = l3->alien[node]; - if (ac && ac->avail) { - spin_lock_irq(&ac->lock); - drain_array(cachep, cachep->nodelists[node], - ac, 1, node); - spin_unlock_irq(&ac->lock); - } - } + if (l3->alien) + drain_array_locked(cachep, l3, l3->alien[node], 1, node); } static void drain_alien_cache(struct kmem_cache *cachep, @@ -984,9 +989,14 @@ static void drain_alien_cache(struct kme for_each_online_node(i) { ac = alien[i]; if (ac) { - spin_lock_irqsave(&ac->lock, flags); - drain_array(cachep, cachep->nodelists[i], ac, 1, i); - spin_unlock_irqrestore(&ac->lock, flags); + /* + * Save irq since drain_array_locked + * may enable/disable. + */ + local_irq_save(flags); + drain_array_locked(cachep, cachep->nodelists[i], + ac, 1, i); + local_irq_restore(flags); } } } @@ -3483,7 +3493,7 @@ static int do_tune_cpucache(struct kmem_ drain_array(cachep, cachep->nodelists[node], ccold, 1, node); - kfree(ccold); + kfree(new.new[i]); } err = alloc_kmemlist(cachep);