Re: [PATCH] arm64: mm: call pagetable dtor when freeing hot-removed page tables

From: David Hildenbrand (Arm)

Date: Sun May 31 2026 - 15:29:33 EST


On 5/27/26 09:34, Kevin Brodsky wrote:
> On 26/05/2026 14:31, David Hildenbrand (Arm) wrote:
>> On 5/26/26 13:54, Kevin Brodsky wrote:
>>> Agreed, I think this is the right thing to do, something like:
>>>
>>> if (folio_test_pgtable(page_folio(page)))
>>> pagetable_dtor_free(page_ptdesc(page)); else
>>> free_hotplug_page_range(page, PAGE_SIZE, NULL);
>> That code pattern is wrong.
>>
>> folio_test_pgtable() shouldn't exist.
>>
>> In the future, something is either a pgtable or a folio, not both.
>>
>> So check the type against the page, not the folio.
>
> In other words use PageTable(page) instead? Interestingly I can see a
> few calls to folio_test_pgtable() across the kernel but none to
> PageTable(), maybe just an antipattern then? The ctor/dtor also use
> __folio_{set,clear}_pgtable().

We started running into the wrong direction, and now have to undo all the wrong
things we already did :)

In the current design Willy has in mind, doing a page_folio() will later return
NULL if it's not actually a folio.

--
Cheers,

David