All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Suren Baghdasaryan <surenb@google.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	akpm@linux-foundation.org, kent.overstreet@linux.dev,
	petr@tesarici.cz, keescook@chromium.org,
	pasha.tatashin@soleen.com, kernel-team@android.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/1] mm: enumerate all gfp flags
Date: Mon, 26 Feb 2024 09:43:35 +0100	[thread overview]
Message-ID: <ZdxPN4RpNW54ckTE@tiehlicka> (raw)
In-Reply-To: <CAJuCfpFskKqCGj4imMMLjUQJWR_8-KHuYc=xAZ4e20+57Zf5Rg@mail.gmail.com>

On Sun 25-02-24 01:12:46, Suren Baghdasaryan wrote:
> On Sat, Feb 24, 2024 at 7:03 AM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
> >
> > Le 24/02/2024 à 02:58, Suren Baghdasaryan a écrit :
> > > Introduce GFP bits enumeration to let compiler track the number of used
> > > bits (which depends on the config options) instead of hardcoding them.
> > > That simplifies __GFP_BITS_SHIFT calculation.
> > >
> > > Suggested-by: Petr Tesařík <petr@tesarici.cz>
> > > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > > Reviewed-by: Kees Cook <keescook@chromium.org>
> > > Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> > > Acked-by: Michal Hocko <mhocko@suse.com>
> > > ---
> > > Changes from v4 [1]:
> > > - Split from the series [2] as a stand-alone patch, per Michal Hocko
> > > - Added Reviewed-by, per Pasha Tatashin
> > > - Added Acked-by, per Michal Hocko
> > >
> > > [1] https://lore.kernel.org/all/20240221194052.927623-7-surenb@google.com/
> > > [2] https://lore.kernel.org/all/20240221194052.927623-1-surenb@google.com/
> > >
> > >   include/linux/gfp_types.h | 90 +++++++++++++++++++++++++++------------
> > >   1 file changed, 62 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h
> > > index 1b6053da8754..868c8fb1bbc1 100644
> > > --- a/include/linux/gfp_types.h
> > > +++ b/include/linux/gfp_types.h
> > > @@ -21,44 +21,78 @@ typedef unsigned int __bitwise gfp_t;
> > >    * include/trace/events/mmflags.h and tools/perf/builtin-kmem.c
> > >    */
> > >
> > > +enum {
> > > +     ___GFP_DMA_BIT,
> > > +     ___GFP_HIGHMEM_BIT,
> > > +     ___GFP_DMA32_BIT,
> > > +     ___GFP_MOVABLE_BIT,
> > > +     ___GFP_RECLAIMABLE_BIT,
> > > +     ___GFP_HIGH_BIT,
> > > +     ___GFP_IO_BIT,
> > > +     ___GFP_FS_BIT,
> > > +     ___GFP_ZERO_BIT,
> > > +     ___GFP_UNUSED_BIT,      /* 0x200u unused */
> >
> > Hi,
> >
> > what is the need to have this ___GFP_UNUSED_BIT now?
> 
> Hi!
> We can remove it but then all values will shift. That should be safe
> to do now but I prefer one patch to do only one thing. We can add a
> separate patch to do further cleanup of unused values.

Agreed!

> > > +     ___GFP_DIRECT_RECLAIM_BIT,
> > > +     ___GFP_KSWAPD_RECLAIM_BIT,
> > > +     ___GFP_WRITE_BIT,
> > > +     ___GFP_NOWARN_BIT,
> > > +     ___GFP_RETRY_MAYFAIL_BIT,
> > > +     ___GFP_NOFAIL_BIT,
> > > +     ___GFP_NORETRY_BIT,
> > > +     ___GFP_MEMALLOC_BIT,
> > > +     ___GFP_COMP_BIT,
> > > +     ___GFP_NOMEMALLOC_BIT,
> > > +     ___GFP_HARDWALL_BIT,
> > > +     ___GFP_THISNODE_BIT,
> > > +     ___GFP_ACCOUNT_BIT,
> > > +     ___GFP_ZEROTAGS_BIT,
> > > +#ifdef CONFIG_KASAN_HW_TAGS
> > > +     ___GFP_SKIP_ZERO_BIT,
> > > +     ___GFP_SKIP_KASAN_BIT,
> > > +#endif
> > > +#ifdef CONFIG_LOCKDEP
> > > +     ___GFP_NOLOCKDEP_BIT,
> > > +#endif
> > > +     ___GFP_LAST_BIT
> > > +};
> >
> > Does it make sense to have something like:
> >    BUILD_BUG_ON(___GFP_LAST_BIT > BITS_PER_LONG, "blah");
> 
> I suppose that would not hurt, except gfp_t is unsigned int, not long.
> Something like this would work I think:
> 
> BUILD_BUG_ON_MSG(___GFP_LAST_BIT > BITS_PER_TYPE(gfp_t), "GFP bit overflow");
> 
> except I'm not sure where to put this check. One of the __init
> functions in page_alloc.c would probably work but none seem to be
> appropriate. mm_core_init() perhaps? Other ideas?

Would that check add much? We currently cannot use the full width of the
gfp_t because radix tree code needs to fit also its own tag into the
same word (see radix_tree_init). If the radix tree constrain is lifted
then we should add something like the above.
-- 
Michal Hocko
SUSE Labs


  reply	other threads:[~2024-02-26  8:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-24  1:58 [PATCH v5 1/1] mm: enumerate all gfp flags Suren Baghdasaryan
2024-02-24  7:03 ` Christophe JAILLET
2024-02-25  1:12   ` Suren Baghdasaryan
2024-02-26  8:43     ` Michal Hocko [this message]
2024-02-26 16:13       ` Suren Baghdasaryan

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=ZdxPN4RpNW54ckTE@tiehlicka \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=keescook@chromium.org \
    --cc=kent.overstreet@linux.dev \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=petr@tesarici.cz \
    --cc=surenb@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.