Re: [PATCH v1 04/29] mm/page_alloc: let page freeing clear any set page type
From: Lorenzo Stoakes
Date: Tue Jul 01 2025 - 04:39:28 EST
On Tue, Jul 01, 2025 at 10:34:33AM +0200, David Hildenbrand wrote:
> > > > > Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
> > > > > Acked-by: Harry Yoo <harry.yoo@xxxxxxxxxx>
> > > > > Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
Based on discussion below, I'm good with this now with the comment change, so
feel free to add:
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
> > > > > ---
> > > > > mm/page_alloc.c | 3 +++
> > > > > 1 file changed, 3 insertions(+)
> > > > >
> > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > > > > index 858bc17653af9..44e56d31cfeb1 100644
> > > > > --- a/mm/page_alloc.c
> > > > > +++ b/mm/page_alloc.c
> > > > > @@ -1380,6 +1380,9 @@ __always_inline bool free_pages_prepare(struct page *page,
> > > > > mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1);
> > > > > page->mapping = NULL;
> > > > > }
> > > > > + if (unlikely(page_has_type(page)))
> > > > > + page->page_type = UINT_MAX;
> > > >
> > > > Feels like this could do with a comment!
> > >
> > > /* Reset the page_type -> _mapcount to -1 */
> >
> > Hm this feels like saying 'the reason we set it to -1 is to set it to -1' :P
>
> Bingo! Guess why I didn't add a comment in the first place :P
>
> >
> > I'd be fine with something simple like
> >
> > /* Set page_type to reset value */
>
> "Reset the page_type (which overlays _mapcount)"
>
> ?
Sounds good thanks, have an R-b above on the basis of this change.
>
> > > But... Can't we just put a #define somewhere here to make life easy?
> Like:
>
> Given that Willy will change all that soon, I'm not in favor of doing that
> in this series.
Ah is he? I mean of course he is :))) this does seem like a prime target for the
ongoing memdesc/foliofication efforts.