[slubllv3 19/21] slub: fast release on full slab

From: Christoph Lameter
Date: Fri Apr 15 2011 - 16:48:16 EST


Make deactivation occur implicitly while checking out the current freelist.

This avoids one cmpxchg operation on a slab that is now fully in use.

Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>

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

Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c 2011-04-15 14:30:10.000000000 -0500
+++ linux-2.6/mm/slub.c 2011-04-15 14:30:12.000000000 -0500
@@ -1953,9 +1953,21 @@ static void *__slab_alloc(struct kmem_ca
object = page->freelist;
counters = page->counters;
new.counters = counters;
- new.inuse = page->objects;
VM_BUG_ON(!new.frozen);

+ /*
+ * If there is no object left then we use this loop to
+ * deactivate the slab which is simple since no objects
+ * are left in the slab and therefore we do not need to
+ * put the page back onto the partial list.
+ *
+ * If there are objects left then we retrieve them
+ * and use them to refill the per cpu queue.
+ */
+
+ new.inuse = page->objects;
+ new.frozen = object != NULL;
+
} while (!cmpxchg_double_slab(s, page,
object, counters,
NULL, new.counters,
@@ -1965,8 +1977,10 @@ static void *__slab_alloc(struct kmem_ca
load_freelist:
VM_BUG_ON(!page->frozen);

- if (unlikely(!object))
+ if (unlikely(!object)) {
+ c->page = NULL;
goto new_slab;
+ }

c->freelist = get_freepointer(s, object);


--
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/