[patch 05/10] SLUB: Avoid touching page struct when freeing to per cpu slab

From: Christoph Lameter
Date: Sat Jul 07 2007 - 23:53:39 EST


Instead of checking for SlabDebug which requires access the page struct
contents simply check the per cpu freepointer if its not NULL. It can only
be not NULL if !SlabDebug.

This means we will not free to the cpu slab if the per cpu list is
empty. In that case it is likely that the cpu slab is soon being
retired anyways. Not freeing to an empty freelist is also required
to avoid races in the cmpxchg alloc/free version.

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>

---
mm/slub.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Index: linux-2.6.22-rc6-mm1/mm/slub.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/slub.c 2007-07-05 19:05:29.000000000 -0700
+++ linux-2.6.22-rc6-mm1/mm/slub.c 2007-07-05 19:05:33.000000000 -0700
@@ -1525,6 +1531,7 @@ new_slab:
}
return NULL;
debug:
+ c->freelist = NULL;
object = c->page->freelist;
if (!alloc_debug_processing(s, c->page, object, addr))
goto another_slab;
@@ -1663,7 +1670,7 @@ static void __always_inline slab_free(st

local_irq_save(flags);
c = get_cpu_slab(s, smp_processor_id());
- if (likely(page == c->page && !SlabDebug(page))) {
+ if (likely(page == c->page && c->freelist)) {
object[c->offset] = c->freelist;
c->freelist = object;
} else

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/