Re: [PATCH] Revert "ptdesc: remove references to folios from __pagetable_ctor() and pagetable_dtor()"

From: Matthew Wilcox

Date: Wed Feb 25 2026 - 11:08:46 EST


On Tue, Feb 24, 2026 at 04:24:34PM -0800, Axel Rasmussen wrote:
> This change swapped out mod_node_page_state for lruvec_stat_add_folio.
> But, these two APIs are not interchangeable: the lruvec version also
> increments memcg stats, in addition to "global" pgdat stats.
>
> So after this change, the "pagetables" memcg stat in memory.stat always
> yields "0", which is a userspace visible regression.
>
> I tried to look for a refactor where we add a variant of
> lruvec_stat_mod_folio which takes a pgdat and a memcg instead of a
> folio, to try to adhere to the spirit of the original patch. But at the
> end of the day this just means we have to call
> folio_memcg(ptdesc_folio(ptdesc)) anyway, which doesn't really
> accomplish much.

Thank you! I hadn't been able to get a straight answer on this before.

You're right that there's no good function to call, but that just means
we need to make one. The principle here is that (eventually) different
memdescs don't need to know about each other. Obviously we're not there
yet, but we can start disentangling them by not casting ptdescs back to
folios (even though they're created that way).

Here's three patches smooshed together; I have them separately and I'll
post them soon.