Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sparc: use vmemmap_populate_hugepages for vmemmap_populate

Change sparc's implementation of vmemmap_populate() using
vmemmap_populate_hugepages() to streamline the code. Another benefit is
that it allows us to eliminate the external declarations of
vmemmap_p?d_populate functions and convert them to static functions.

Since vmemmap_populate_hugepages may fallback to vmemmap_populate-
_basepages, which differs from sparc's original implementation. During
the v1 discussion with Mike Rapoport, sparc uses base pages in the kernel
page tables, so it should be able to use them in vmemmap as well.
Consequently, no additional special handling is required.

1. In the SPARC architecture, reimplement vmemmap_populate using
vmemmap_populate_hugepages.

2. Allow the SPARC arch to fallback to vmemmap_populate_basepages(),
when vmemmap_alloc_block returns NULL.

Link: https://lkml.kernel.org/r/20260201063532.44807-2-pilgrimtao@gmail.com
Signed-off-by: Chengkaitao <chengkaitao@kylinos.cn>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Acked-by: Andreas Larsson <andreas@gaisler.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Chengkaitao and committed by
Andrew Morton
92a9cf97 bc7a2d1b

+16 -31
+16 -31
arch/sparc/mm/init_64.c
··· 2562 2562 EXPORT_SYMBOL(_PAGE_CACHE); 2563 2563 2564 2564 #ifdef CONFIG_SPARSEMEM_VMEMMAP 2565 - int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend, 2566 - int node, struct vmem_altmap *altmap) 2565 + void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, 2566 + unsigned long addr, unsigned long next) 2567 2567 { 2568 2568 unsigned long pte_base; 2569 2569 ··· 2576 2576 2577 2577 pte_base |= _PAGE_PMD_HUGE; 2578 2578 2579 - vstart = vstart & PMD_MASK; 2580 - vend = ALIGN(vend, PMD_SIZE); 2581 - for (; vstart < vend; vstart += PMD_SIZE) { 2582 - pgd_t *pgd = vmemmap_pgd_populate(vstart, node); 2583 - unsigned long pte; 2584 - p4d_t *p4d; 2585 - pud_t *pud; 2586 - pmd_t *pmd; 2579 + pmd_val(*pmd) = pte_base | __pa(p); 2580 + } 2587 2581 2588 - if (!pgd) 2589 - return -ENOMEM; 2582 + int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node, 2583 + unsigned long addr, unsigned long next) 2584 + { 2585 + int large = pmd_leaf(*pmdp); 2590 2586 2591 - p4d = vmemmap_p4d_populate(pgd, vstart, node); 2592 - if (!p4d) 2593 - return -ENOMEM; 2587 + if (large) 2588 + vmemmap_verify((pte_t *)pmdp, node, addr, next); 2594 2589 2595 - pud = vmemmap_pud_populate(p4d, vstart, node); 2596 - if (!pud) 2597 - return -ENOMEM; 2590 + return large; 2591 + } 2598 2592 2599 - pmd = pmd_offset(pud, vstart); 2600 - pte = pmd_val(*pmd); 2601 - if (!(pte & _PAGE_VALID)) { 2602 - void *block = vmemmap_alloc_block(PMD_SIZE, node); 2603 - 2604 - if (!block) 2605 - return -ENOMEM; 2606 - 2607 - pmd_val(*pmd) = pte_base | __pa(block); 2608 - } 2609 - } 2610 - 2611 - return 0; 2593 + int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend, 2594 + int node, struct vmem_altmap *altmap) 2595 + { 2596 + return vmemmap_populate_hugepages(vstart, vend, node, NULL); 2612 2597 } 2613 2598 #endif /* CONFIG_SPARSEMEM_VMEMMAP */ 2614 2599