riscv: Add support to allocate gigantic hugepages using CMA
PATCH 1/1 riscv: Add support to allocate gigantic hugepages using CMA
The RV32 only has at most 1GB memory(MAXPHYSMEM_1GB), so let's disable HUGETLBFS on RV32. And add support to allocate gigantic hugepages using CMA by specifying the hugetlb_cma= kernel parameter.
--- arch/riscv/Kconfig | 2 +- arch/riscv/mm/init.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +1 -1
@@ -33,7 +33,7 @@ config RISCV select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT - select ARCH_SUPPORTS_HUGETLBFS if MMU + select ARCH_SUPPORTS_HUGETLBFS if MMU && 64BIT select ARCH_USE_MEMTEST select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU select ARCH_WANT_FRAME_POINTERS
arch/riscv/mm/init.c +2 -0
@@ -19,6 +19,7 @@#include <linux/set_memory.h> #include <linux/dma-map-ops.h> #include <linux/crash_dump.h> +#include <linux/hugetlb.h> #include <asm/fixmap.h> #include <asm/tlbflush.h>
@@ -216,6 +217,7 @@ static void __init setup_bootmem(void)early_init_fdt_scan_reserved_mem ();dma_contiguous_reserve (dma32_phys_limit); +hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT );memblock_allow_resize (); }
Signature · 7 lines
2.26.2 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Alex Ghiti
reviewerHi Kefeng,
Le 29/07/2021 à 08:24, Kefeng Wang a écrit :
Quoted 2 lines
The RV32 only has at most 1GB
memory(MAXPHYSMEM_1GB), so let's disable HUGETLBFS on RV32.
There is only one size of hugepages for RV32 which is 4MB, there isn't any gigantic hugepage of 1GB: there are only 2 levels of page table, a PGDIR represents 4MB and this is the only way to have a hugepage on RV32. So I think we should leave hugetlbfs available on RV32.
Thanks,
Alex
Quoted 36 lines
And add support to allocate gigantic
hugepages using CMA by specifying the hugetlb_cma= kernel parameter.Signed-off-by Kefeng Wang <[email protected]>--- arch/riscv/Kconfig | 2 +- arch/riscv/mm/init.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)arch/riscv/Kconfig +1
-1@@ -33,7 +33,7 @@ config RISCV select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT - select ARCH_SUPPORTS_HUGETLBFS if MMU + select ARCH_SUPPORTS_HUGETLBFS if MMU && 64BIT select ARCH_USE_MEMTEST select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU select ARCH_WANT_FRAME_POINTERSarch/riscv/mm/init.c +1
-0@@ -19,6 +19,7 @@#include <linux/set_memory.h> #include <linux/dma-map-ops.h> #include <linux/crash_dump.h> +#include <linux/hugetlb.h> #include <asm/fixmap.h> #include <asm/tlbflush.h>
arch/riscv/mm/init.c static void __init setup_bootmem(void) · line 223
Quoted 7 lines
arch/riscv/mm/init.c +1
-0@@ -216,6 +217,7 @@ static void __init setup_bootmem(void)early_init_fdt_scan_reserved_mem ();dma_contiguous_reserve (dma32_phys_limit); +hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT );memblock_allow_resize (); }
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 7 lines · Alex Ghiti
Hi Kefeng,
Le 29/07/2021 à 08:24, Kefeng Wang a écrit :
Quoted 2 lines
The RV32 only has at most 1GB
memory(MAXPHYSMEM_1GB), so let's disable HUGETLBFS on RV32.There is only one size of hugepages for RV32 which is 4MB, there isn't any gigantic hugepage of 1GB: there are only 2 levels of page table, a PGDIR represents 4MB and this is the only way to have a hugepage on RV32. So I think we should leave hugetlbfs available on RV32.
OK, will update, thanks.
Quoted 38 lines
Thanks,
Alex
Quoted 33 lines
And add support to allocate gigantic
hugepages using CMA by specifying the hugetlb_cma= kernel parameter.Signed-off-by Kefeng Wang <[email protected]>---
arch/riscv/Kconfig | 2 +-
arch/riscv/mm/init.c| 2 ++2 files changed, 3 insertions(+), 1 deletion(-)arch/riscv/Kconfig +0
-0@@ -33,7 +33,7 @@ config RISCVselect
ARCH_HAS_TICK_BROADCASTifGENERIC_CLOCKEVENTS_BROADCASTselectARCH_OPTIONAL_KERNEL_RWXifARCH_HAS_STRICT_KERNEL_RWXselectARCH_OPTIONAL_KERNEL_RWX_DEFAULT
- selectARCH_SUPPORTS_HUGETLBFSif MMU
+ selectARCH_SUPPORTS_HUGETLBFSif MMU && 64BIT
selectARCH_USE_MEMTEST
selectARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUTif MMU selectARCH_WANT_FRAME_POINTERSarch/riscv/mm/init.c +1
-0@@ -19,6 +19,7 @@ #include <linux/set_memory.h> #include <linux/dma-map-ops.h> #include <linux/crash_dump.h> +#include <linux/hugetlb.h> #include <asm/fixmap.h> #include <asm/tlbflush.h>
Quoted 9 lines
arch/riscv/mm/init.c static void __init setup_bootmem(void) · line 222
Quoted 7 lines
arch/riscv/mm/init.c +1
-0@@ -216,6 +217,7 @@ static void __init setup_bootmem(void) early_init_fdt_scan_reserved_mem(); dma_contiguous_reserve(dma32_phys_limit); + hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); memblock_allow_resize(); }.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv