From 7fd272550bd43cc1d7289ef0ab2fa50de137e767 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 9 Dec 2007 10:14:36 -0800 Subject: [PATCH] Avoid double memclear() in SLOB/SLUB Both slob and slub react to __GFP_ZERO by clearing the allocation, which means that passing the GFP_ZERO bit down to the page allocator is just wasteful and pointless. Acked-by: Matt Mackall Reviewed-by: Pekka Enberg Signed-off-by: Linus Torvalds --- mm/slob.c | 2 +- mm/slub.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/slob.c b/mm/slob.c index ee2ef8af0d43..773a7aa80ab5 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -330,7 +330,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) /* Not enough space: must allocate a new page */ if (!b) { - b = slob_new_page(gfp, 0, node); + b = slob_new_page(gfp & ~__GFP_ZERO, 0, node); if (!b) return 0; sp = (struct slob_page *)virt_to_page(b); diff --git a/mm/slub.c b/mm/slub.c index b9f37cb0f2e6..9c1d9f3b364f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1468,6 +1468,9 @@ static void *__slab_alloc(struct kmem_cache *s, void **object; struct page *new; + /* We handle __GFP_ZERO in the caller */ + gfpflags &= ~__GFP_ZERO; + if (!c->page) goto new_slab; -- 2.30.2