[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c81b176893c349dfb12feaebd17e0694fedec0b@linux.dev>
Date: Mon, 21 Apr 2025 05:16:50 +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 1:13 PM, "Lance Yang" <lance.yang@...ux.dev> wrote:
>
> 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).
static inline bool folio_maybe_mapped_shared(struct folio *folio)
{
[...]
if (!IS_ENABLED(CONFIG_MM_ID))
return true;
[...]
return folio_test_large_maybe_mapped_shared(folio);
}
folio_maybe_mapped_shared() is always available - doesn't depend on
CONFIG_MM_ID or CONFIG_TRANSPARENT_HUGEPAGE.
Thanks,
Lance
>
> 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