On Mon, Dec 04, 2023 at 04:09:36PM +0100, David Hildenbrand wrote: > I think for the pagecache it should work. In the context of [1], a total > mapcount would likely still be possible. Anything beyond that likely not, if > we ever care. I confess I hadn't gone through your patches. https://lore.kernel.org/all/20231124132626.235350-8-david@xxxxxxxxxx/ is the critical one. It's actually going to walk off the end of order-2 folios today (which we'll create, eg with XFS). You can put _rmap_val0 and _rmap_val1 in page2 and _rmap_val2-5 in page3 to fix this. Once we're allocating order-1 folios, I think you can avoid this scheme and just check page0 and page1 mapcounts independently.