Re: [PATCH v3] mm, slab: Check GFP_SLAB_BUG_MASK before alloc_pages in kmalloc_order
From: David Rientjes
Date: Wed Jul 01 2020 - 14:52:44 EST
On Wed, 1 Jul 2020, Long Li wrote:
> diff --git a/mm/slab.c b/mm/slab.c
> index ac7a223d9ac3..2850fe3c5fb8 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -2573,13 +2573,9 @@ static struct page *cache_grow_begin(struct kmem_cache *cachep,
> * Be lazy and only check for valid flags here, keeping it out of the
> * critical path in kmem_cache_alloc().
> */
> - if (unlikely(flags & GFP_SLAB_BUG_MASK)) {
> - gfp_t invalid_mask = flags & GFP_SLAB_BUG_MASK;
> - flags &= ~GFP_SLAB_BUG_MASK;
> - pr_warn("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n",
> - invalid_mask, &invalid_mask, flags, &flags);
> - dump_stack();
> - }
> + if (unlikely(flags & GFP_SLAB_BUG_MASK))
> + flags = kmalloc_invalid_flags(flags);
> +
> WARN_ON_ONCE(cachep->ctor && (flags & __GFP_ZERO));
> local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
>
Is this name correct? kmalloc_invalid_flags() masks off the invalid flags
and returns the valid flags :) Maybe kmalloc_check_flags()?