new_slab_objects() always return c->page matching the required gfpflags, but the current code is misleading and ___slab_alloc->deactivate_slab seems to allow not-pfmemalloc purpose obj to be allocated from pfmemalloc-purpose page. This patch re-organize the code to eliminate the confusion. Signed-off-by: Pingfan Liu <kernelfans@xxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/slub.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a68c2ae..e152634 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2551,23 +2551,21 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, } freelist = new_slab_objects(s, gfpflags, node, &c); - if (unlikely(!freelist)) { slab_out_of_memory(s, gfpflags, node); return NULL; } + VM_BUG_ON(!pfmemalloc_match(page, gfpflags)); page = c->page; - if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags))) + if (likely(!kmem_cache_debug(s)) goto load_freelist; /* Only entered in the debug case */ - if (kmem_cache_debug(s) && - !alloc_debug_processing(s, page, freelist, addr)) + if (!alloc_debug_processing(s, page, freelist, addr)) goto new_slab; /* Slab failed checks. Next slab needed */ - - deactivate_slab(s, page, get_freepointer(s, freelist), c); - return freelist; + else + goto load_freelist; } /* -- 2.7.4