From: Christoph Lameter <cl@linux.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: linux-mm@kvack.org, David Rientjes <rientjes@google.com>
Subject: [Slub cleanup 3/9] slub: Acquire_slab() avoid loop
Date: Mon, 23 Jan 2012 14:16:49 -0600 [thread overview]
Message-ID: <20120123201707.186039210@linux.com> (raw)
In-Reply-To: 20120123201646.924319545@linux.com
[-- Attachment #1: simplify --]
[-- Type: text/plain, Size: 2148 bytes --]
Avoid the loop in acquire slab and simply fail if there is a conflict.
This will cause the next page on the list to be considered.
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
---
mm/slub.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c 2012-01-13 08:47:10.938748802 -0600
+++ linux-2.6/mm/slub.c 2012-01-13 08:47:17.158748674 -0600
@@ -1484,12 +1484,12 @@ static inline void remove_partial(struct
}
/*
- * Lock slab, remove from the partial list and put the object into the
- * per cpu freelist.
+ * Remove slab from the partial list, freeze it and
+ * return the pointer to the freelist.
*
* Returns a list of objects or NULL if it fails.
*
- * Must hold list_lock.
+ * Must hold list_lock since we modify the partial list.
*/
static inline void *acquire_slab(struct kmem_cache *s,
struct kmem_cache_node *n, struct page *page,
@@ -1504,22 +1504,24 @@ static inline void *acquire_slab(struct
* The old freelist is the list of objects for the
* per cpu allocation list.
*/
- do {
- freelist = page->freelist;
- counters = page->counters;
- new.counters = counters;
- if (mode)
- new.inuse = page->objects;
+ freelist = page->freelist;
+ counters = page->counters;
+ new.counters = counters;
+ if (mode)
+ new.inuse = page->objects;
- VM_BUG_ON(new.frozen);
- new.frozen = 1;
+ VM_BUG_ON(new.frozen);
+ new.frozen = 1;
- } while (!__cmpxchg_double_slab(s, page,
+ if (!__cmpxchg_double_slab(s, page,
freelist, counters,
NULL, new.counters,
- "lock and freeze"));
+ "acquire_slab"))
+
+ return NULL;
remove_partial(n, page);
+ WARN_ON(!freelist);
return freelist;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-01-23 20:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-23 20:16 [Slub cleanup 0/9] Slub: cleanups V1 Christoph Lameter
2012-01-23 20:16 ` [Slub cleanup 1/9] slub: Use freelist instead of "object" in __slab_alloc Christoph Lameter
2012-02-01 21:51 ` David Rientjes
2012-01-23 20:16 ` [Slub cleanup 2/9] slub: Add frozen check " Christoph Lameter
2012-02-01 21:54 ` David Rientjes
2012-01-23 20:16 ` Christoph Lameter [this message]
2012-01-23 20:16 ` [Slub cleanup 4/9] slub: Simplify control flow in __slab_alloc() Christoph Lameter
2012-02-01 22:02 ` David Rientjes
2012-01-23 20:16 ` [Slub cleanup 6/9] slub: Get rid of the node field Christoph Lameter
2012-02-01 22:11 ` David Rientjes
2012-01-23 20:16 ` [Slub cleanup 7/9] slub: Separate out kmem_cache_cpu processing from deactivate_slab Christoph Lameter
2012-01-23 20:16 ` [Slub cleanup 8/9] slub: Use page variable instead of c->page Christoph Lameter
2012-01-23 20:16 ` [Slub cleanup 9/9] slub: pass page to node_match() instead of kmem_cache_cpu structure Christoph Lameter
[not found] ` <20120123201708.312262597@linux.com>
2012-02-01 22:05 ` [Slub cleanup 5/9] slub: new_slab_objects() can also get objects from partial list David Rientjes
-- strict thread matches above, loose matches on Subject: below --
2012-05-09 15:09 [Slub cleanup 0/9] Slub: cleanups V2 cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 3/9] slub: Acquire_slab() avoid loop cl, Christoph Lameter
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=20120123201707.186039210@linux.com \
--to=cl@linux.com \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.