Re: [PATCH v4 3/8] x86/mm: Use 'ptdesc' when freeing PMD pages

Jason Gunthorpe
2025-09-05T18:26:04Z

On Fri, Sep 05, 2025 at 01:50:58PM +0800, Lu Baolu wrote:
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> There are a billion ways to refer to a physical memory address.
> One of the x86 PMD freeing code location chooses to use a 'pte_t *' to
> point to a PMD page and then call a PTE-specific freeing function for
> it. That's a bit wonky.
>
> Just use a 'struct ptdesc *' instead. Its entire purpose is to refer
> to page table pages. It also means being able to remove an explicit
> cast.
>
> Right now, pte_free_kernel() is a one-liner that calls
> pagetable_dtor_free(). Effectively, all this patch does is
> remove one superfluous __pa(__va(paddr)) conversion and then
> call pagetable_dtor_free() directly instead of through a helper.
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> arch/x86/mm/pgtable.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)

Much better

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason