Re: [patch 04/10] SLUB: Avoid checking for a valid object before zeroing on the fast path

2007-10-28 Thread Pekka J Enberg
On Sat, 27 Oct 2007, Christoph Lameter wrote:
> 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.

Reviewed-by: Pekka Enberg <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 04/10] SLUB: Avoid checking for a valid object before zeroing on the fast path

2007-10-27 Thread Christoph Lameter
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 <[EMAIL PROTECTED]>

---
 mm/slub.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

Index: linux-2.6/mm/slub.c
===
--- linux-2.6.orig/mm/slub.c2007-10-25 19:37:38.0 -0700
+++ linux-2.6/mm/slub.c 2007-10-25 19:38:14.0 -0700
@@ -1573,19 +1573,22 @@ static void __always_inline *slab_alloc(
 
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;
 }
 

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