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

From: David Hildenbrand (Arm)

Date: Wed Feb 25 2026 - 11:23:03 EST


On 2/25/26 17:04, David Hildenbrand (Arm) wrote:
> On 2/25/26 01:24, 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.
>
> Argh, missed that these page tables are charged.
>
>>
>> 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.
>
> The goal of the original patch is obviously to get rid of any folio
> references in ptdesc code.
>
> But if these ptdesc are charged, then we'd also need long-term a
> ptdesc->memcg_data.
>
> For now we could still go through page->memcg_data, to avoid going
> through the folio.
>
> But that requires some work, so likely we should just directly enlighten
> ptdesc to have memcg_data.
>
> Agreed that, as a quick fix, reverting the commit might be best.
>
> But let's wait a bit whether Willy has a comment.

Heh, Willy just replied while composing the mail. :)

--
Cheers,

David