Patch series "mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd()", v3. The weak vmemmap_set_pmd() and vmemmap_check_pmd() hooks are currently no-ops in the generic code, which leaves architectures that need PMD-level handling to open-code the same logic locally. This series provides generic implementations for both helpers in mm/sparse-vmemmap.c. vmemmap_set_pmd() installs a huge PMD with PAGE_KERNEL protection, and vmemmap_check_pmd() verifies a present leaf PMD before reusing the existing vmemmap_verify() helper. With those generic helpers in place, patches 2-5 remove the now redundant arch-specific implementations from arm64, riscv, loongarch, and sparc. This patch (of 5): The two weak functions are currently no-ops on every architecture, forcing each platform that needs them to duplicate the same handful of lines. Provide a generic implementation: - vmemmap_set_pmd() simply sets a huge PMD with PAGE_KERNEL protection. - vmemmap_check_pmd() verifies that the PMD is present and leaf, then calls the existing vmemmap_verify() helper. Architectures that need special handling can continue to override the weak symbols; everyone else gets the standard version for free.
Unified · Split
| @@ -386,12 +386,17 @@ int __meminit vmemmap_populate_hvo(unsigned long addr, unsigned long end, · 385 unmodified lines | |||
| 386 | void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, | 386 | void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, |
| 387 | unsigned long addr, unsigned long next) | 387 | unsigned long addr, unsigned long next) |
| 388 | { | 388 | { |
| 389 | WARN_ON_ONCE(!pmd_set_huge(pmd, virt_to_phys(p), PAGE_KERNEL)); | ||
| 389 | } | 390 | } |
| 390 | 391 | ||
| 391 | int __weak __meminit vmemmap_check_pmd(pmd_t *pmd, int node, | 392 | int __weak __meminit vmemmap_check_pmd(pmd_t *pmd, int node, |
| 392 | unsigned long addr, unsigned long next) | 393 | unsigned long addr, unsigned long next) |
| 393 | { | 394 | { |
| 394 | return 0; | 395 | if (!pmd_leaf(pmdp_get(pmd))) |
| 396 | return 0; | ||
| 397 | vmemmap_verify((pte_t *)pmd, node, addr, next); | ||
| 398 | |||
| 399 | return 1; | ||
| 395 | } | 400 | } |
| 396 | 401 | ||
| 397 | int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, | 402 | int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, |