Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933062AbXBVMjQ (ORCPT ); Thu, 22 Feb 2007 07:39:16 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933068AbXBVMjP (ORCPT ); Thu, 22 Feb 2007 07:39:15 -0500 Received: from courier.cs.helsinki.fi ([128.214.9.1]:57460 "EHLO mail.cs.helsinki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933062AbXBVMjN (ORCPT ); Thu, 22 Feb 2007 07:39:13 -0500 Date: Thu, 22 Feb 2007 14:39:12 +0200 (EET) From: Pekka J Enberg To: linux-mm@kvack.org cc: linux-kernel@vger.kernel.org, wli@holomorphy.com, clameter@sgi.com Subject: [RFC/PATCH] slab: free pages in a batch in drain_freelist Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2191 Lines: 75 From: Pekka Enberg As suggested by William, free the actual pages in a batch so that we don't keep pounding on l3->list_lock. Cc: William Lee Irwin III Cc: Christoph Lameter Signed-off-by: Pekka Enberg --- mm/slab.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) Index: uml-2.6/mm/slab.c =================================================================== --- uml-2.6.orig/mm/slab.c 2007-02-22 14:19:46.000000000 +0200 +++ uml-2.6/mm/slab.c 2007-02-22 14:28:01.000000000 +0200 @@ -2437,38 +2437,36 @@ * * Returns the actual number of slabs released. */ -static int drain_freelist(struct kmem_cache *cache, - struct kmem_list3 *l3, int tofree) +static int drain_freelist(struct kmem_cache *cache, struct kmem_list3 *l3, + int tofree) { + struct slab *slabp, *this, *next; + struct list_head to_free_list; struct list_head *p; int nr_freed; - struct slab *slabp; + INIT_LIST_HEAD(&to_free_list); nr_freed = 0; - while (nr_freed < tofree && !list_empty(&l3->slabs_free)) { - spin_lock_irq(&l3->list_lock); + spin_lock_irq(&l3->list_lock); + while (nr_freed < tofree && !list_empty(&l3->slabs_free)) { p = l3->slabs_free.prev; - if (p == &l3->slabs_free) { - spin_unlock_irq(&l3->list_lock); - goto out; - } + if (p == &l3->slabs_free) + break; slabp = list_entry(p, struct slab, list); #if DEBUG BUG_ON(slabp->inuse); #endif - list_del(&slabp->list); - /* - * Safe to drop the lock. The slab is no longer linked - * to the cache. - */ + list_move(&slabp->list, &to_free_list); l3->free_objects -= cache->num; - spin_unlock_irq(&l3->list_lock); - slab_destroy(cache, slabp); nr_freed++; } -out: + spin_unlock_irq(&l3->list_lock); + + list_for_each_entry_safe(this, next, &to_free_list, list) + slab_destroy(cache, this); + return nr_freed; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/