* [PATCH] riscv: mm: Enable PMD split page table lock for RV64
@ 2021-07-30 13:11 Kefeng Wang
2021-08-05 11:51 ` Alex Ghiti
2021-08-27 15:18 ` Kefeng Wang
0 siblings, 2 replies; 4+ messages in thread
From: Kefeng Wang @ 2021-07-30 13:11 UTC (permalink / raw)
To: Palmer Dabbelt, linux-riscv
Cc: palmerdabbelt, paul.walmsley, aou, alex, Kefeng Wang
After commit 1355c31eeb7e ("asm-generic: pgalloc: provide generic
pmd_alloc_one() and pmd_free_one()"), it is easy to enable
ARCH_ENABLE_SPLIT_PMD_PTLOCK for RV64.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
arch/riscv/Kconfig | 1 +
arch/riscv/mm/init.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 8fcceb8eda07..c3e456fc7108 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -12,6 +12,7 @@ config 32BIT
config RISCV
def_bool y
+ select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
select ARCH_CLOCKSOURCE_INIT
select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index e547e53cddd2..ce12905a0224 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -361,7 +361,8 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
unsigned long vaddr;
vaddr = __get_free_page(GFP_KERNEL);
- BUG_ON(!vaddr);
+ BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
+
return __pa(vaddr);
}
--
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] 4+ messages in thread
* Re: [PATCH] riscv: mm: Enable PMD split page table lock for RV64
2021-07-30 13:11 [PATCH] riscv: mm: Enable PMD split page table lock for RV64 Kefeng Wang
@ 2021-08-05 11:51 ` Alex Ghiti
2021-08-05 16:24 ` Kefeng Wang
2021-08-27 15:18 ` Kefeng Wang
1 sibling, 1 reply; 4+ messages in thread
From: Alex Ghiti @ 2021-08-05 11:51 UTC (permalink / raw)
To: Kefeng Wang, Palmer Dabbelt, linux-riscv
Cc: palmerdabbelt, paul.walmsley, aou
Hi Kefeng,
On 30/07/2021 15:11, Kefeng Wang wrote:
> After commit 1355c31eeb7e ("asm-generic: pgalloc: provide generic
> pmd_alloc_one() and pmd_free_one()"), it is easy to enable
> ARCH_ENABLE_SPLIT_PMD_PTLOCK for RV64.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> arch/riscv/Kconfig | 1 +
> arch/riscv/mm/init.c | 3 ++-
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 8fcceb8eda07..c3e456fc7108 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -12,6 +12,7 @@ config 32BIT
>
> config RISCV
> def_bool y
> + select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
> select ARCH_CLOCKSOURCE_INIT
> select ARCH_SUPPORTS_ATOMIC_RMW
> select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index e547e53cddd2..ce12905a0224 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -361,7 +361,8 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
> unsigned long vaddr;
>
> vaddr = __get_free_page(GFP_KERNEL);
> - BUG_ON(!vaddr);
> + BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
> +
> return __pa(vaddr);
> }
>
>
I took the time to check how the page table lock works, and indeed, the
commit you mention makes it easy to enable this feature since the
initialization of the lock for the general case is done there and your
patch seems correct as this is the only place we allocate a PMD page,
and the PTE page allocation already calls pgtable_pte_page_ctor.
Maybe your commit message would need some of the explanation I gave
above, or something similar, but this is up to you.
You can add:
Reviewed-by: Alexandre Ghiti <alex@ghiti.fr>
Thanks,
Alex
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: mm: Enable PMD split page table lock for RV64
2021-08-05 11:51 ` Alex Ghiti
@ 2021-08-05 16:24 ` Kefeng Wang
0 siblings, 0 replies; 4+ messages in thread
From: Kefeng Wang @ 2021-08-05 16:24 UTC (permalink / raw)
To: Alex Ghiti, Palmer Dabbelt, linux-riscv; +Cc: palmerdabbelt, paul.walmsley, aou
On 2021/8/5 19:51, Alex Ghiti wrote:
> Hi Kefeng,
>
> On 30/07/2021 15:11, Kefeng Wang wrote:
>> After commit 1355c31eeb7e ("asm-generic: pgalloc: provide generic
>> pmd_alloc_one() and pmd_free_one()"), it is easy to enable
>> ARCH_ENABLE_SPLIT_PMD_PTLOCK for RV64.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> arch/riscv/Kconfig | 1 +
>> arch/riscv/mm/init.c | 3 ++-
>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 8fcceb8eda07..c3e456fc7108 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -12,6 +12,7 @@ config 32BIT
>> config RISCV
>> def_bool y
>> + select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
>> select ARCH_CLOCKSOURCE_INIT
>> select ARCH_SUPPORTS_ATOMIC_RMW
>> select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index e547e53cddd2..ce12905a0224 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -361,7 +361,8 @@ static phys_addr_t __init
>> alloc_pmd_late(uintptr_t va)
>> unsigned long vaddr;
>> vaddr = __get_free_page(GFP_KERNEL);
>> - BUG_ON(!vaddr);
>> + BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
>> +
>> return __pa(vaddr);
>> }
>>
>
> I took the time to check how the page table lock works, and indeed,
> the commit you mention makes it easy to enable this feature since the
> initialization of the lock for the general case is done there and your
> patch seems correct as this is the only place we allocate a PMD page,
> and the PTE page allocation already calls pgtable_pte_page_ctor.
>
> Maybe your commit message would need some of the explanation I gave
> above, or something similar, but this is up to you.
There is a Documentation/vm/split_page_table_lock.rst doc about this
feature, we could learn more from changelog with the feature introduced.
>
> You can add:
>
> Reviewed-by: Alexandre Ghiti <alex@ghiti.fr>
Thanks, Alex ;)
>
> Thanks,
>
> Alex
> .
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: mm: Enable PMD split page table lock for RV64
2021-07-30 13:11 [PATCH] riscv: mm: Enable PMD split page table lock for RV64 Kefeng Wang
2021-08-05 11:51 ` Alex Ghiti
@ 2021-08-27 15:18 ` Kefeng Wang
1 sibling, 0 replies; 4+ messages in thread
From: Kefeng Wang @ 2021-08-27 15:18 UTC (permalink / raw)
To: Palmer Dabbelt, linux-riscv; +Cc: palmerdabbelt, paul.walmsley, aou, alex
Hi Palmer, ping ...
On 2021/7/30 21:11, Kefeng Wang wrote:
> After commit 1355c31eeb7e ("asm-generic: pgalloc: provide generic
> pmd_alloc_one() and pmd_free_one()"), it is easy to enable
> ARCH_ENABLE_SPLIT_PMD_PTLOCK for RV64.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> arch/riscv/Kconfig | 1 +
> arch/riscv/mm/init.c | 3 ++-
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 8fcceb8eda07..c3e456fc7108 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -12,6 +12,7 @@ config 32BIT
>
> config RISCV
> def_bool y
> + select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
> select ARCH_CLOCKSOURCE_INIT
> select ARCH_SUPPORTS_ATOMIC_RMW
> select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index e547e53cddd2..ce12905a0224 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -361,7 +361,8 @@ static phys_addr_t __init alloc_pmd_late(uintptr_t va)
> unsigned long vaddr;
>
> vaddr = __get_free_page(GFP_KERNEL);
> - BUG_ON(!vaddr);
> + BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page(vaddr)));
> +
> return __pa(vaddr);
> }
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-27 15:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 13:11 [PATCH] riscv: mm: Enable PMD split page table lock for RV64 Kefeng Wang
2021-08-05 11:51 ` Alex Ghiti
2021-08-05 16:24 ` Kefeng Wang
2021-08-27 15:18 ` Kefeng Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).