Re: [PATCHv2 02/14] mm/sparse: Check memmap alignment
From: David Hildenbrand (Red Hat)
Date: Fri Jan 09 2026 - 10:30:26 EST
For quite some time there will be a magical config option that will switch
between both layouts. I'd assume that things will get more complicated if we
suddenly have a "compound_head/folio" pointer and a "compound_info" pointer
at the same time.
But it's really Willy who has the concept in mind as he is very likely right
now busy writing some of that code.
I'm just the messenger.
:)
[I would hope that Willy could share his thoughts]
If you or Willy think that this patch will impede memdesc progress, I am
okay not pushing this patchset upstream.
I pinged Willy.
I was really excited when I found this trick to get rid of fake heads.
But ultimately, it is a clean up. I failed to find a performance win I
hoped for.
I think it's quite nice as a cleanup, and if we wouldn't have memdescs on the horizon that essentially change the code completely in another direction (having all pages point to a struct folio, not just the tail pages), I wouldn't be bringing this up :)
Also, I try to understand what 32-byte layout means for fake heads.
_refcount in struct page is going to 0 and refcounting happens on folios.
Yes, for folios.
So I wounder if we can all pages identical (no tail pages per se) and
avoid fake heads this way?
That's the ultimate goal, yes. Essentially, all pages will point to the
memdesc, and there will not be a reason to check for head/fake-head etc.
I think initially, the compound-page concept might
still co-exist for some memdescs that we won't initially allocate separately.
But I don't know the details of that.
I know that the transition phase is tricky :)
Regarding reference and folios: yes exactly. When trying to get a reference, we'll spot in the memdesc field that this is a folio and try on the folio instead.
In the future, most pages will either be permanently frozen and not have a refcount (e.g., struct ptdesc), or have a refcount in their memdesc. In the transition, the location of the refcount depends on memdesc type (in memdesc vs. in page).
--
Cheers
David