* [PATCH V2] arm64/mm: Add pud_sect_supported()
@ 2021-09-20 9:29 Anshuman Khandual
2021-09-20 15:41 ` Catalin Marinas
2021-09-29 17:48 ` Will Deacon
0 siblings, 2 replies; 7+ messages in thread
From: Anshuman Khandual @ 2021-09-20 9:29 UTC (permalink / raw)
To: linux-arm-kernel
Cc: mark.rutland, suzuki.poulose, Anshuman Khandual, Catalin Marinas,
Will Deacon, linux-kernel
Section mapping at PUD level is supported only on 4K pages and currently it
gets verified with explicit #ifdef or IS_ENABLED() constructs. This adds a
new helper pud_sect_supported() for this purpose, which particularly cleans
up the HugeTLB code path. It updates relevant switch statements with checks
for __PAGETABLE_PMD_FOLDED in order to avoid build failures caused with two
identical switch case values in those code blocks.
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on v5.15-rc2
Changes in V2:
- Replaced __PAGETABLE_PUD_FOLDED with __PAGETABLE_PMD_FOLDED per Catalin
Changes in V1:
https://lore.kernel.org/all/1631677459-28383-1-git-send-email-anshuman.khandual@arm.com/
arch/arm64/include/asm/pgtable.h | 5 +++++
arch/arm64/include/asm/vmalloc.h | 4 ++--
arch/arm64/mm/hugetlbpage.c | 26 +++++++++++++++-----------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index dfa76afa0ccf..84fbb52b4224 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -1022,6 +1022,11 @@ static inline pgprot_t arch_filter_pgprot(pgprot_t prot)
return PAGE_READONLY_EXEC;
}
+static inline bool pud_sect_supported(void)
+{
+ return PAGE_SIZE == SZ_4K;
+}
+
#endif /* !__ASSEMBLY__ */
diff --git a/arch/arm64/include/asm/vmalloc.h b/arch/arm64/include/asm/vmalloc.h
index 7a22aeea9bb5..b9185503feae 100644
--- a/arch/arm64/include/asm/vmalloc.h
+++ b/arch/arm64/include/asm/vmalloc.h
@@ -2,6 +2,7 @@
#define _ASM_ARM64_VMALLOC_H
#include <asm/page.h>
+#include <asm/pgtable.h>
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
@@ -9,10 +10,9 @@
static inline bool arch_vmap_pud_supported(pgprot_t prot)
{
/*
- * Only 4k granule supports level 1 block mappings.
* SW table walks can't handle removal of intermediate entries.
*/
- return IS_ENABLED(CONFIG_ARM64_4K_PAGES) &&
+ return pud_sect_supported() &&
!IS_ENABLED(CONFIG_PTDUMP_DEBUGFS);
}
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 23505fc35324..029cf5e42c4c 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -40,11 +40,10 @@ void __init arm64_hugetlb_cma_reserve(void)
{
int order;
-#ifdef CONFIG_ARM64_4K_PAGES
- order = PUD_SHIFT - PAGE_SHIFT;
-#else
- order = CONT_PMD_SHIFT + PMD_SHIFT - PAGE_SHIFT;
-#endif
+ if (pud_sect_supported())
+ order = PUD_SHIFT - PAGE_SHIFT;
+ else
+ order = CONT_PMD_SHIFT + PMD_SHIFT - PAGE_SHIFT;
/*
* HugeTLB CMA reservation is required for gigantic
* huge pages which could not be allocated via the
@@ -62,8 +61,9 @@ bool arch_hugetlb_migration_supported(struct hstate *h)
size_t pagesize = huge_page_size(h);
switch (pagesize) {
-#ifdef CONFIG_ARM64_4K_PAGES
+#ifndef __PAGETABLE_PMD_FOLDED
case PUD_SIZE:
+ return pud_sect_supported();
#endif
case PMD_SIZE:
case CONT_PMD_SIZE:
@@ -126,8 +126,11 @@ static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
*pgsize = size;
switch (size) {
-#ifdef CONFIG_ARM64_4K_PAGES
+#ifndef __PAGETABLE_PMD_FOLDED
case PUD_SIZE:
+ if (pud_sect_supported())
+ contig_ptes = 1;
+ break;
#endif
case PMD_SIZE:
contig_ptes = 1;
@@ -489,9 +492,9 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma,
static int __init hugetlbpage_init(void)
{
-#ifdef CONFIG_ARM64_4K_PAGES
- hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
-#endif
+ if (pud_sect_supported())
+ hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
+
hugetlb_add_hstate(CONT_PMD_SHIFT - PAGE_SHIFT);
hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
hugetlb_add_hstate(CONT_PTE_SHIFT - PAGE_SHIFT);
@@ -503,8 +506,9 @@ arch_initcall(hugetlbpage_init);
bool __init arch_hugetlb_valid_size(unsigned long size)
{
switch (size) {
-#ifdef CONFIG_ARM64_4K_PAGES
+#ifndef __PAGETABLE_PMD_FOLDED
case PUD_SIZE:
+ return pud_sect_supported();
#endif
case CONT_PMD_SIZE:
case PMD_SIZE:
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V2] arm64/mm: Add pud_sect_supported()
2021-09-20 9:29 [PATCH V2] arm64/mm: Add pud_sect_supported() Anshuman Khandual
@ 2021-09-20 15:41 ` Catalin Marinas
2021-09-22 4:44 ` Anshuman Khandual
2021-09-29 17:48 ` Will Deacon
1 sibling, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2021-09-20 15:41 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-arm-kernel, mark.rutland, suzuki.poulose, Will Deacon,
linux-kernel
On Mon, Sep 20, 2021 at 02:59:31PM +0530, Anshuman Khandual wrote:
> Section mapping at PUD level is supported only on 4K pages and currently it
> gets verified with explicit #ifdef or IS_ENABLED() constructs. This adds a
> new helper pud_sect_supported() for this purpose, which particularly cleans
> up the HugeTLB code path. It updates relevant switch statements with checks
> for __PAGETABLE_PMD_FOLDED in order to avoid build failures caused with two
> identical switch case values in those code blocks.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Assuming that you tested the corresponding configurations,
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] arm64/mm: Add pud_sect_supported()
2021-09-20 15:41 ` Catalin Marinas
@ 2021-09-22 4:44 ` Anshuman Khandual
2021-09-22 4:52 ` Itaru Kitayama
0 siblings, 1 reply; 7+ messages in thread
From: Anshuman Khandual @ 2021-09-22 4:44 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-arm-kernel, mark.rutland, suzuki.poulose, Will Deacon,
linux-kernel
On 9/20/21 9:11 PM, Catalin Marinas wrote:
> On Mon, Sep 20, 2021 at 02:59:31PM +0530, Anshuman Khandual wrote:
>> Section mapping at PUD level is supported only on 4K pages and currently it
>> gets verified with explicit #ifdef or IS_ENABLED() constructs. This adds a
>> new helper pud_sect_supported() for this purpose, which particularly cleans
>> up the HugeTLB code path. It updates relevant switch statements with checks
>> for __PAGETABLE_PMD_FOLDED in order to avoid build failures caused with two
>> identical switch case values in those code blocks.
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Suggested-by: Mark Rutland <mark.rutland@arm.com>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>
> Assuming that you tested the corresponding configurations,
Right, I did test this on all page size and VA bits configurations
, including the specific ones which were problematic.
>
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] arm64/mm: Add pud_sect_supported()
2021-09-22 4:44 ` Anshuman Khandual
@ 2021-09-22 4:52 ` Itaru Kitayama
2021-09-22 5:07 ` Anshuman Khandual
2021-09-22 9:52 ` Catalin Marinas
0 siblings, 2 replies; 7+ messages in thread
From: Itaru Kitayama @ 2021-09-22 4:52 UTC (permalink / raw)
To: Anshuman Khandual
Cc: Catalin Marinas, Linux ARM, Mark Rutland, Suzuki K Poulose,
Will Deacon, linux-kernel
How did you test the 16K page size configurations? In QEMU? I wasn't
aware of hardware that's capable 16KB page size.
On Wed, Sep 22, 2021 at 1:47 PM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
>
>
> On 9/20/21 9:11 PM, Catalin Marinas wrote:
> > On Mon, Sep 20, 2021 at 02:59:31PM +0530, Anshuman Khandual wrote:
> >> Section mapping at PUD level is supported only on 4K pages and currently it
> >> gets verified with explicit #ifdef or IS_ENABLED() constructs. This adds a
> >> new helper pud_sect_supported() for this purpose, which particularly cleans
> >> up the HugeTLB code path. It updates relevant switch statements with checks
> >> for __PAGETABLE_PMD_FOLDED in order to avoid build failures caused with two
> >> identical switch case values in those code blocks.
> >>
> >> Cc: Catalin Marinas <catalin.marinas@arm.com>
> >> Cc: Will Deacon <will@kernel.org>
> >> Cc: linux-arm-kernel@lists.infradead.org
> >> Cc: linux-kernel@vger.kernel.org
> >> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> >> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> >
> > Assuming that you tested the corresponding configurations,
>
> Right, I did test this on all page size and VA bits configurations
> , including the specific ones which were problematic.
>
> >
> > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> >
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] arm64/mm: Add pud_sect_supported()
2021-09-22 4:52 ` Itaru Kitayama
@ 2021-09-22 5:07 ` Anshuman Khandual
2021-09-22 9:52 ` Catalin Marinas
1 sibling, 0 replies; 7+ messages in thread
From: Anshuman Khandual @ 2021-09-22 5:07 UTC (permalink / raw)
To: Itaru Kitayama
Cc: Catalin Marinas, Linux ARM, Mark Rutland, Suzuki K Poulose,
Will Deacon, linux-kernel
On 9/22/21 10:22 AM, Itaru Kitayama wrote:
> How did you test the 16K page size configurations? In QEMU? I wasn't
> aware of hardware that's capable 16KB page size.
FVP (Fixed Virtual Platforms).
>
> On Wed, Sep 22, 2021 at 1:47 PM Anshuman Khandual
> <anshuman.khandual@arm.com> wrote:
>>
>>
>>
>> On 9/20/21 9:11 PM, Catalin Marinas wrote:
>>> On Mon, Sep 20, 2021 at 02:59:31PM +0530, Anshuman Khandual wrote:
>>>> Section mapping at PUD level is supported only on 4K pages and currently it
>>>> gets verified with explicit #ifdef or IS_ENABLED() constructs. This adds a
>>>> new helper pud_sect_supported() for this purpose, which particularly cleans
>>>> up the HugeTLB code path. It updates relevant switch statements with checks
>>>> for __PAGETABLE_PMD_FOLDED in order to avoid build failures caused with two
>>>> identical switch case values in those code blocks.
>>>>
>>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>>> Cc: Will Deacon <will@kernel.org>
>>>> Cc: linux-arm-kernel@lists.infradead.org
>>>> Cc: linux-kernel@vger.kernel.org
>>>> Suggested-by: Mark Rutland <mark.rutland@arm.com>
>>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>>
>>> Assuming that you tested the corresponding configurations,
>>
>> Right, I did test this on all page size and VA bits configurations
>> , including the specific ones which were problematic.
>>
>>>
>>> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
>>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] arm64/mm: Add pud_sect_supported()
2021-09-22 4:52 ` Itaru Kitayama
2021-09-22 5:07 ` Anshuman Khandual
@ 2021-09-22 9:52 ` Catalin Marinas
1 sibling, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2021-09-22 9:52 UTC (permalink / raw)
To: Itaru Kitayama
Cc: Anshuman Khandual, Linux ARM, Mark Rutland, Suzuki K Poulose,
Will Deacon, linux-kernel
On Wed, Sep 22, 2021 at 01:52:21PM +0900, Itaru Kitayama wrote:
> How did you test the 16K page size configurations? In QEMU? I wasn't
> aware of hardware that's capable 16KB page size.
Apple M1 (the easiest is to run Linux in a VM).
--
Catalin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] arm64/mm: Add pud_sect_supported()
2021-09-20 9:29 [PATCH V2] arm64/mm: Add pud_sect_supported() Anshuman Khandual
2021-09-20 15:41 ` Catalin Marinas
@ 2021-09-29 17:48 ` Will Deacon
1 sibling, 0 replies; 7+ messages in thread
From: Will Deacon @ 2021-09-29 17:48 UTC (permalink / raw)
To: Anshuman Khandual, linux-arm-kernel
Cc: catalin.marinas, kernel-team, Will Deacon, suzuki.poulose,
linux-kernel, mark.rutland
On Mon, 20 Sep 2021 14:59:31 +0530, Anshuman Khandual wrote:
> Section mapping at PUD level is supported only on 4K pages and currently it
> gets verified with explicit #ifdef or IS_ENABLED() constructs. This adds a
> new helper pud_sect_supported() for this purpose, which particularly cleans
> up the HugeTLB code path. It updates relevant switch statements with checks
> for __PAGETABLE_PMD_FOLDED in order to avoid build failures caused with two
> identical switch case values in those code blocks.
>
> [...]
Applied to arm64 (for-next/mm), thanks!
[1/1] arm64/mm: Add pud_sect_supported()
https://git.kernel.org/arm64/c/f8b46c4b51ab
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-09-29 17:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 9:29 [PATCH V2] arm64/mm: Add pud_sect_supported() Anshuman Khandual
2021-09-20 15:41 ` Catalin Marinas
2021-09-22 4:44 ` Anshuman Khandual
2021-09-22 4:52 ` Itaru Kitayama
2021-09-22 5:07 ` Anshuman Khandual
2021-09-22 9:52 ` Catalin Marinas
2021-09-29 17:48 ` Will Deacon
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).