[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <641755b75b4ecb9c9822e15e707a0ebf1e250788@linux.dev>
Date: Mon, 21 Apr 2025 05:13:03 +0000
From: "Lance Yang" <lance.yang@...ux.dev>
To: "Andrew Morton" <akpm@...ux-foundation.org>, "David Hildenbrand"
<david@...hat.com>
Cc: mingzhe.yang@...com, linux-mm@...ck.org, linux-kernel@...r.kernel.org,
"Lance Yang" <ioworker0@...il.com>
Subject: Re: [RESEND PATCH v2 1/1] mm/rmap: add CONFIG_MM_ID guard for
folio_test_large_maybe_mapped_shared()
April 21, 2025 at 7:29 AM, "Andrew Morton" <akpm@...ux-foundation.org> wrote:
>
> On Fri, 18 Apr 2025 23:22:28 +0800 Lance Yang <ioworker0@...il.com> wrote:
>
> >
> > From: Lance Yang <lance.yang@...ux.dev>
> >
> >
> >
> > To prevent folio_test_large_maybe_mapped_shared() from being used without
> >
> > CONFIG_MM_ID, we add a compile-time check rather than wrapping it in
> >
> > '#ifdef', avoiding even more #ifdef in callers that already use
> >
> > IS_ENABLED(CONFIG_MM_ID).
> >
> >
> >
> > Also, we used plenty of IS_ENABLED() on purpose to keep the code free of
> >
> > '#ifdef' mess.
> >
>
> I dunno, this just seems really whacky.
I'd hope David could leave some comments on that.
>
> >
> > --- a/include/linux/page-flags.h
> >
> > +++ b/include/linux/page-flags.h
> >
> > @@ -1232,6 +1232,8 @@ static inline int folio_has_private(const struct folio *folio)
> >
> >
> >
> > static inline bool folio_test_large_maybe_mapped_shared(const struct folio *folio)
> >
> > {
> >
> > + /* This function should never be called without CONFIG_MM_ID enabled. */
> >
>
> A correcter comment would be "This function should never be compiled
>
> without CONFIG_MM_ID enabled".
Yes, that is more exact ;)
>
> Which lets the cat out of the bag. Why the heck is it being compiled
>
> with CONFIG_MM_ID=n?? We have tools to prevent that.
>
> Can we just slap "#ifdef CONFIG_MM_ID" around the whole function? It
>
> should have no callers, right? If the linker ends up complaining then
>
> something went wrong.
The reason we can't simply add #ifdef CONFIG_MM_ID around folio_test_large_maybe_mapped_shared()
is because its caller folio_maybe_mapped_shared() relies on IS_ENABLED(CONFIG_MM_ID).
If we do, with CONFIG_TRANSPARENT_HUGEPAGE=N, we'll hit compilation errors like:
./include/linux/mm.h: In function ‘folio_maybe_mapped_shared’:
./include/linux/mm.h:2337:16: error: implicit declaration of function ‘folio_test_large_maybe_mapped_shared’; did you mean ‘folio_maybe_mapped_shared’? [-Werror=implicit-function-declaration]
2337 | return folio_test_large_maybe_mapped_shared(folio);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| folio_maybe_mapped_shared
cc1: some warnings being treated as errors
Thanks,
Lance
>
Powered by blists - more mailing lists