LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Pekka J Enberg <penberg@cs.helsinki.fi>
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
Date: Thu, 22 Feb 2007 14:39:12 +0200 (EET)	[thread overview]
Message-ID: <Pine.LNX.4.64.0702221437400.14523@sbz-30.cs.Helsinki.FI> (raw)

From: Pekka Enberg <penberg@cs.helsinki.fi>

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 <wli@holomorphy.com>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 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;
 }
 

             reply	other threads:[~2007-02-22 12:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22 12:39 Pekka J Enberg [this message]
2007-02-22 21:57 ` Christoph Lameter
2007-02-22 23:01 Christoph Lameter
2007-02-24  4:30 ` William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0702221437400.14523@sbz-30.cs.Helsinki.FI \
    --to=penberg@cs.helsinki.fi \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=wli@holomorphy.com \
    --subject='Re: [RFC/PATCH] slab: free pages in a batch in drain_freelist' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).