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

riscv: Use hugepage mappings for vmemmap

This will allow better TLB utilization and then should be more performant.

Before:

---[ vmemmap start ]---
0xffff8d8002000000-0xffff8d8012000000 0x000000046ec00000 256M PTE . .. .. D A G . . W R V
---[ vmemmap end ]---

After:

---[ vmemmap start ]---
0xffff8d8002000000-0xffff8d8012000000 0x000000046ec00000 256M PMD . .. .. D A G . . W R V
---[ vmemmap end ]---

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20231214132935.212864-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

authored by

Alexandre Ghiti and committed by
Palmer Dabbelt
ff172d48 d3e591a3

+20 -1
+20 -1
arch/riscv/mm/init.c
··· 1387 1387 } 1388 1388 1389 1389 #ifdef CONFIG_SPARSEMEM_VMEMMAP 1390 + void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node, 1391 + unsigned long addr, unsigned long next) 1392 + { 1393 + pmd_set_huge(pmd, virt_to_phys(p), PAGE_KERNEL); 1394 + } 1395 + 1396 + int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node, 1397 + unsigned long addr, unsigned long next) 1398 + { 1399 + vmemmap_verify((pte_t *)pmdp, node, addr, next); 1400 + return 1; 1401 + } 1402 + 1390 1403 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, 1391 1404 struct vmem_altmap *altmap) 1392 1405 { 1393 - return vmemmap_populate_basepages(start, end, node, NULL); 1406 + /* 1407 + * Note that SPARSEMEM_VMEMMAP is only selected for rv64 and that we 1408 + * can't use hugepage mappings for 2-level page table because in case of 1409 + * memory hotplug, we are not able to update all the page tables with 1410 + * the new PMDs. 1411 + */ 1412 + return vmemmap_populate_hugepages(start, end, node, NULL); 1394 1413 } 1395 1414 #endif 1396 1415