From: Vlastimil Babka <vbabka@suse.cz>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Andrey Konovalov <andreyknvl@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Marco Elver <elver@google.com>
Cc: linux-mm@kvack.org, Michal Hocko <mhocko@suse.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: slab_pre_alloc_hook() strips __GFP_NOLOCKDEP away.
Date: Wed, 23 Mar 2022 12:45:04 +0100 [thread overview]
Message-ID: <84b266e6-93af-aea8-fbf3-feb6d2fe1875@suse.cz> (raw)
In-Reply-To: <YjsEwM/jQsAKbkYP@linutronix.de>
On 3/23/22 12:30, Sebastian Andrzej Siewior wrote:
> On 2022-03-23 11:09:35 [+0100], Vlastimil Babka wrote:
>>> --- a/mm/slab.h
>>> +++ b/mm/slab.h
>>> @@ -717,7 +717,7 @@ static inline struct kmem_cache *slab_pre_alloc_hook(struct kmem_cache *s,
>>> struct obj_cgroup **objcgp,
>>> size_t size, gfp_t flags)
>>> {
>>> - flags &= gfp_allowed_mask;
>>> + flags &= gfp_allowed_mask | __GFP_NOLOCKDEP;
>>
>> Hmm but gfp_allowed_mask already should contain __GFP_NOLOCKDEP after
>> kernel_init_freeable() is reached. I doubt we can reach fs or reclaim
>> code before that?
>
> That is way past init. I have
> gfp_allowed_mask = 0x1ffffff
> __GFP_NOLOCKDEP = 0x8000000
>
> Looking at the origin of gfp_allowed_mask
>
> | /* Room for N __GFP_FOO bits */
> | #define __GFP_BITS_SHIFT (24 + \
> | 3 * IS_ENABLED(CONFIG_KASAN_HW_TAGS) + \
> | IS_ENABLED(CONFIG_LOCKDEP))
> | #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
Mainline has this:
#define __GFP_BITS_SHIFT (25 + IS_ENABLED(CONFIG_LOCKDEP))
which looks OK.
The '24' comes from "kasan, mm: only define ___GFP_SKIP_KASAN_POISON
with HW_TAGS" in mmotm.
It makes ___GFP_SKIP_KASAN_POISON optional, that's why the decrease to
24. However this is not about the number of flags, but the highest bit,
which can be that of __GFP_NOLOCKDEP and it's then not covered by
__GFP_BITS_SHIFT if lockdep is enabled and kasan not...
> which in my case 24 + 1 but it would need to be something like
> 27 * IS_ENABLED(CONFIG_LOCKDEP)
>
> or a better way to come up with __GFP_BITS_MASK.
>
> Sebastian
prev parent reply other threads:[~2022-03-23 11:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 17:39 Sebastian Andrzej Siewior
2022-03-23 10:09 ` Vlastimil Babka
2022-03-23 11:30 ` Sebastian Andrzej Siewior
2022-03-23 11:45 ` Vlastimil Babka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84b266e6-93af-aea8-fbf3-feb6d2fe1875@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=bigeasy@linutronix.de \
--cc=elver@google.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox