From 247402d2cc2fe5cf01b2ffb366d4d336a0488ac5 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Mon, 7 Jan 2008 23:20:28 -0800 Subject: [PATCH] SLUB: Avoid NULL check in fastpath The fast path always results in a valid object. Move the check for the NULL pointer to the slow branch that calls __slab_alloc. Only __slab_alloc can return NULL if there is no memory available anymore and that case is exceedingly rare. Signed-off-by: Christoph Lameter Reviewed-by: Pekka Enberg Signed-off-by: Andrew Morton --- mm/slub.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 880c649..71d0cf8 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1556,19 +1556,22 @@ static __always_inline void *slab_alloc(struct kmem_cache *s, local_irq_save(flags); c = get_cpu_slab(s, smp_processor_id()); - if (unlikely(!c->freelist || !node_match(c, node))) + if (unlikely(!c->freelist || !node_match(c, node))) { object = __slab_alloc(s, gfpflags, node, addr, c); - - else { + if (unlikely(!object)) { + local_irq_restore(flags); + goto out; + } + } else { object = c->freelist; c->freelist = object[c->offset]; } local_irq_restore(flags); - if (unlikely((gfpflags & __GFP_ZERO) && object)) + if (unlikely((gfpflags & __GFP_ZERO))) memset(object, 0, c->objsize); - +out: return object; } -- debian.1.5.3.7.1-dirty