From: cl@linux.com
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 1/9] slub: Use freelist instead of "object" in __slab_alloc
Date: Wed, 09 May 2012 10:09:51 -0500 [thread overview]
Message-ID: <20120509151007.365973198@linux.com> (raw)
In-Reply-To: 20120509150950.243797150@linux.com
[-- Attachment #1: use_freelist_instead_of_object --]
[-- Type: text/plain, Size: 3923 bytes --]
The variable "object" really refers to a list of objects that we
are handling.
Signed-off-by: Christoph Lameter <cl@linux.com>
---
mm/slub.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c 2012-04-09 09:54:31.036589056 -0500
+++ linux-2.6/mm/slub.c 2012-04-10 10:32:54.322751065 -0500
@@ -2127,7 +2127,7 @@ slab_out_of_memory(struct kmem_cache *s,
static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
int node, struct kmem_cache_cpu **pc)
{
- void *object;
+ void *freelist;
struct kmem_cache_cpu *c;
struct page *page = new_slab(s, flags, node);
@@ -2140,7 +2140,7 @@ static inline void *new_slab_objects(str
* No other reference to the page yet so we can
* muck around with it freely without cmpxchg
*/
- object = page->freelist;
+ freelist = page->freelist;
page->freelist = NULL;
stat(s, ALLOC_SLAB);
@@ -2148,9 +2148,9 @@ static inline void *new_slab_objects(str
c->page = page;
*pc = c;
} else
- object = NULL;
+ freelist = NULL;
- return object;
+ return freelist;
}
/*
@@ -2170,6 +2170,7 @@ static inline void *get_freelist(struct
do {
freelist = page->freelist;
counters = page->counters;
+
new.counters = counters;
VM_BUG_ON(!new.frozen);
@@ -2203,7 +2204,7 @@ static inline void *get_freelist(struct
static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
unsigned long addr, struct kmem_cache_cpu *c)
{
- void **object;
+ void *freelist;
unsigned long flags;
local_irq_save(flags);
@@ -2219,6 +2220,7 @@ static void *__slab_alloc(struct kmem_ca
if (!c->page)
goto new_slab;
redo:
+
if (unlikely(!node_match(c, node))) {
stat(s, ALLOC_NODE_MISMATCH);
deactivate_slab(s, c);
@@ -2226,15 +2228,15 @@ redo:
}
/* must check again c->freelist in case of cpu migration or IRQ */
- object = c->freelist;
- if (object)
+ freelist = c->freelist;
+ if (freelist)
goto load_freelist;
stat(s, ALLOC_SLOWPATH);
- object = get_freelist(s, c->page);
+ freelist = get_freelist(s, c->page);
- if (!object) {
+ if (!freelist) {
c->page = NULL;
stat(s, DEACTIVATE_BYPASS);
goto new_slab;
@@ -2243,10 +2245,10 @@ redo:
stat(s, ALLOC_REFILL);
load_freelist:
- c->freelist = get_freepointer(s, object);
+ c->freelist = get_freepointer(s, freelist);
c->tid = next_tid(c->tid);
local_irq_restore(flags);
- return object;
+ return freelist;
new_slab:
@@ -2260,13 +2262,13 @@ new_slab:
}
/* Then do expensive stuff like retrieving pages from the partial lists */
- object = get_partial(s, gfpflags, node, c);
+ freelist = get_partial(s, gfpflags, node, c);
- if (unlikely(!object)) {
+ if (unlikely(!freelist)) {
- object = new_slab_objects(s, gfpflags, node, &c);
+ freelist = new_slab_objects(s, gfpflags, node, &c);
- if (unlikely(!object)) {
+ if (unlikely(!freelist)) {
if (!(gfpflags & __GFP_NOWARN) && printk_ratelimit())
slab_out_of_memory(s, gfpflags, node);
@@ -2279,14 +2281,14 @@ new_slab:
goto load_freelist;
/* Only entered in the debug case */
- if (!alloc_debug_processing(s, c->page, object, addr))
+ if (!alloc_debug_processing(s, c->page, freelist, addr))
goto new_slab; /* Slab failed checks. Next slab needed */
- c->freelist = get_freepointer(s, object);
+ c->freelist = get_freepointer(s, freelist);
deactivate_slab(s, c);
c->node = NUMA_NO_NODE;
local_irq_restore(flags);
- return object;
+ 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-05-09 15:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-09 15:09 [Slub cleanup 0/9] Slub: cleanups V2 cl, Christoph Lameter
2012-05-09 15:09 ` cl, Christoph Lameter [this message]
2012-05-09 15:09 ` [Slub cleanup 2/9] slub: Add frozen check in __slab_alloc cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 3/9] slub: Acquire_slab() avoid loop cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 4/9] slub: Simplify control flow in __slab_alloc() cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 5/9] slub: new_slab_objects() can also get objects from partial list cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 6/9] slub: Get rid of the node field cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 7/9] slub: Separate out kmem_cache_cpu processing from deactivate_slab cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 8/9] slub: Use page variable instead of c->page cl, Christoph Lameter
2012-05-09 15:09 ` [Slub cleanup 9/9] slub: pass page to node_match() instead of kmem_cache_cpu structure cl, Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
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
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=20120509151007.365973198@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 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).