Re: [PATCH 1/3] sparc64: remove hugetlb_free_pgd_range()

From: Anthony Yznaga
Date: Wed Jul 16 2025 - 12:44:47 EST




On 7/16/25 1:20 AM, David Hildenbrand wrote:
On 16.07.25 03:26, Anthony Yznaga wrote:
The sparc implementation of hugetlb_free_pgd_range() is identical
to free_pgd_range() with the exception of checking for and skipping
possible leaf entries at the PUD and PMD levels.

And the pgd loop was optimized out, because probably not applicable.

These checks are
unnecessary because any huge pages have been freed and their PTEs
cleared by the time page tables needed to map them are freed.

Do we know why that handling was added in the first place, and why it no longer applies?

The PMD handling was added by 7bc3777ca19c (sparc64: Trim page tables for 8M hugepages). The only clue is that the commit message has the sentence, "Also, when freeing page table for 8M hugepage backed region, make sure we don't try to access non-existent PTE level." I'd guess that it was something left over from development that snuck in. The patch is changing from storing 1024 PTEs at the PTE level for an 8M hugetlb page to storing a single PMD entry.


These is_hugetlb_pmd/is_hugetlb_pud are rather weird on the code path.

Looks like a very nice cleanup.