All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: Add support to allocate gigantic hugepages using CMA
@ 2021-07-29  6:24 Kefeng Wang
  2021-07-29 14:32 ` Alex Ghiti
  0 siblings, 1 reply; 3+ messages in thread
From: Kefeng Wang @ 2021-07-29  6:24 UTC (permalink / raw)
  To: Palmer Dabbelt, linux-riscv
  Cc: palmerdabbelt, paul.walmsley, aou, Kefeng Wang

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.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/riscv/Kconfig   | 2 +-
 arch/riscv/mm/init.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 8fcceb8eda07..20a589605307 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -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
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index a14bf3910eec..f2268402894b 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -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();
 }
 
-- 
2.26.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: Add support to allocate gigantic hugepages using CMA
  2021-07-29  6:24 [PATCH] riscv: Add support to allocate gigantic hugepages using CMA Kefeng Wang
@ 2021-07-29 14:32 ` Alex Ghiti
  2021-07-30  0:58   ` Kefeng Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Ghiti @ 2021-07-29 14:32 UTC (permalink / raw)
  To: Kefeng Wang, Palmer Dabbelt, linux-riscv
  Cc: palmerdabbelt, paul.walmsley, aou

Hi Kefeng,

Le 29/07/2021 à 08:24, Kefeng Wang a écrit :
> 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

> And add support to allocate gigantic
> hugepages using CMA by specifying the hugetlb_cma= kernel parameter.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   arch/riscv/Kconfig   | 2 +-
>   arch/riscv/mm/init.c | 2 ++
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 8fcceb8eda07..20a589605307 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -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
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index a14bf3910eec..f2268402894b 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -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();
>   }
>   
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: Add support to allocate gigantic hugepages using CMA
  2021-07-29 14:32 ` Alex Ghiti
@ 2021-07-30  0:58   ` Kefeng Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Kefeng Wang @ 2021-07-30  0:58 UTC (permalink / raw)
  To: Alex Ghiti, Palmer Dabbelt, linux-riscv; +Cc: palmerdabbelt, paul.walmsley, aou


On 2021/7/29 22:32, Alex Ghiti wrote:
> Hi Kefeng,
>
> Le 29/07/2021 à 08:24, Kefeng Wang a écrit :
>> 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.

>
> Thanks,
>
> Alex
>
>> And add support to allocate gigantic
>> hugepages using CMA by specifying the hugetlb_cma= kernel parameter.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   arch/riscv/Kconfig   | 2 +-
>>   arch/riscv/mm/init.c | 2 ++
>>   2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 8fcceb8eda07..20a589605307 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -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
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index a14bf3910eec..f2268402894b 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -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();
>>   }
>>
> .
>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-30  0:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  6:24 [PATCH] riscv: Add support to allocate gigantic hugepages using CMA Kefeng Wang
2021-07-29 14:32 ` Alex Ghiti
2021-07-30  0:58   ` Kefeng Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.