Re: [PATCH] mm: Wire up tail page poisoning over ->mappings

From: Peter Xu
Date: Sun Aug 20 2023 - 21:14:45 EST


On Fri, Aug 18, 2023 at 11:14:28PM +0100, Matthew Wilcox wrote:
> On Tue, Aug 15, 2023 at 05:06:59PM -0400, Peter Xu wrote:
> > I split this out from another rfc series. Removed RFC tag because it
> > wasn't for this patch but for the documentation updates. I'll post the rfc
> > part alone. Comments welcomed, thanks.
>
> I still hate it, as I explained here:

I still prefer it be merged.

>
> https://lore.kernel.org/linux-mm/ZNp7yUgUrIpILnXu@xxxxxxxxxxxxxxxxxxxx/

https://lore.kernel.org/linux-mm/ZNqFv0AwkfDKExiw@x1n/#t

Firstly, I've answered and you didn't follow that up.

This is not identical to that version, it added one more change to remove
the other hard coded "2"

>
> > > + * When the tail page's mapping field reused, it'll be exempted from
> > > + * ->mapping poisoning and checks. Also see the macro TAIL_MAPPING.
> > > + */
> > > +#define TAIL_MAPPING_REUSED_MAX (2)
> >
> > More importantly, I think this is over-parametrisation. If you start to
> > use extra fields in struct folio, just change the code in page_alloc.c
> > directly.

Change the hard-coded "2"s in different functions? Can you kindly explain
why can't we just have a macro to help?

Setting tail mapping for tail 1/2 is even wrong, which part of this patch
fixes:

@@ -428,7 +428,8 @@ static inline void prep_compound_tail(struct page *head, int tail_idx)
{
struct page *p = head + tail_idx;

- p->mapping = TAIL_MAPPING;
+ if (tail_idx > TAIL_MAPPING_REUSED_MAX)
+ p->mapping = TAIL_MAPPING;
set_compound_head(p, head);
set_page_private(p, 0);
}

Do you mean you prefer me to add one more hard-coded "2" and "just boost it
when it's needed"?

Thanks,

--
Peter Xu