Skip to contentSkip to conversation

mm/arm64: Drop dead code for pud special bit handling

PATCH Applied Peter Xu 4 participants 5 messages Mar 20, 2025 – Mar 28, 2025

Subsystems (2)
lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH 1/1 mm/arm64: Drop dead code for pud special bit handling

Keith Busch observed some incorrect macros defined in arm64 code [1].

It turns out the two lines should never be needed and won't be exposed to anyone, because aarch64 doesn't select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD, hence ARCH_SUPPORTS_PUD_PFNMAP is always N. The only archs that support THP PUDs so far are x86 and powerpc.

Instead of fixing the lines (with no way to test it..), remove the two lines that are in reality dead code, to avoid confusing readers.

Fixes tag is attached to reflect where the wrong macros were introduced, but explicitly not copying stable, because there's no real issue to be fixed. So it's only about removing the dead code so far.

[1] https://lore.kernel.org/all/[email protected]/#t

Cc Alex Williamson <[email protected]>
Cc Donald Dutile <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Fixes 3e509c9b03f9 ("mm/arm64: support large pfn mappings")
---
 arch/arm64/include/asm/pgtable.h | 5 -----
 1 file changed, 5 deletions(-)
arch/arm64/include/asm/pgtable.h +0 -5
index 0b2a2ad1b9e8..15211f74b035 100644
@@ -620,11 +620,6 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd)
 #define pud_pfn(pud)		((__pud_to_phys(pud) & PUD_MASK) >> PAGE_SHIFT)
 #define pfn_pud(pfn,prot)	__pud(__phys_to_pud_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
-#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
-#define pud_special(pte)	pte_special(pud_pte(pud))
-#define pud_mkspecial(pte)	pte_pud(pte_mkspecial(pud_pte(pud)))
-#endif
-
 #define pmd_pgprot pmd_pgprot
 static inline pgprot_t pmd_pgprot(pmd_t pmd)
 {
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw

Peter,

Thanks for the cc, as I have the original commit in a recent, proposed backport that now needs an edit... or, since harmless, maybe this patch to additionally backport, once committed. :-)

Quoted 33 lines · Peter Xu

Keith Busch observed some incorrect macros defined in arm64 code [1].

It turns out the two lines should never be needed and won't be exposed to anyone, because aarch64 doesn't select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD, hence ARCH_SUPPORTS_PUD_PFNMAP is always N. The only archs that support THP PUDs so far are x86 and powerpc.

Instead of fixing the lines (with no way to test it..), remove the two lines that are in reality dead code, to avoid confusing readers.

Fixes tag is attached to reflect where the wrong macros were introduced, but explicitly not copying stable, because there's no real issue to be fixed. So it's only about removing the dead code so far.

[1] https://lore.kernel.org/all/[email protected]/#t

Cc Alex Williamson <[email protected]>
Cc Donald Dutile <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Fixes 3e509c9b03f9 ("mm/arm64: support large pfn mappings")
---
  arch/arm64/include/asm/pgtable.h | 5 -----
  1 file changed, 5 deletions(-)
arch/arm64/include/asm/pgtable.h +0 -0
index 0b2a2ad1b9e8..15211f74b035 100644
@@ -620,11 +620,6 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd)
  #define pud_pfn(pud)		((__pud_to_phys(pud) & PUD_MASK) >> PAGE_SHIFT)

arch/arm64/include/asm/pgtable.h static inline pmd_t pmd_mkspecial(pmd_t pmd) · line 625

Quoted 10 lines
arch/arm64/include/asm/pgtable.h +0 -5
  #define pfn_pud(pfn,prot)	__pud(__phys_to_pud_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
-#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
-#define pud_special(pte)	pte_special(pud_pte(pud))
-#define pud_mkspecial(pte)	pte_pud(pte_mkspecial(pud_pte(pud)))
-#endif
-
  #define pmd_pgprot pmd_pgprot
  static inline pgprot_t pmd_pgprot(pmd_t pmd)
  {
author
#2 lore raw
Quoted 1 line · Donald Dutile

Peter,

Hello, Don,

Quoted 3 lines

Thanks for the cc, as I have the original commit in a recent, proposed backport that now needs an edit... or, since harmless, maybe this patch to additionally backport, once committed. :-)

I would suggest not having the backport blocked by this. :)

Thanks for the quick review!

Signature · 1 line
Peter Xu
Reviewed-by on v1 1/1
#3 lore raw
In reply to Peter Xu
Quoted 6 lines · Peter Xu

Keith Busch observed some incorrect macros defined in arm64 code [1].

It turns out the two lines should never be needed and won't be exposed to anyone, because aarch64 doesn't select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD, hence ARCH_SUPPORTS_PUD_PFNMAP is always N. The only archs that support THP PUDs so far are x86 and powerpc.

Correct.

Quoted 3 lines

Instead of fixing the lines (with no way to test it..), remove the two lines that are in reality dead code, to avoid confusing readers.

Agreed. Because ARCH_SUPPORTS_PUD_PFNMAP is always N and hence these lines are never reachable. So removing these lines will be preferred than fixing.

Quoted 4 lines

Fixes tag is attached to reflect where the wrong macros were introduced, but explicitly not copying stable, because there's no real issue to be fixed. So it's only about removing the dead code so far.

Makes sense.

Quoted 8 lines

[1] https://lore.kernel.org/all/[email protected]/#t

Cc Alex Williamson <[email protected]>
Cc Donald Dutile <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Fixes 3e509c9b03f9 ("mm/arm64: support large pfn mappings")

The commit ID checks out.

Quoted 12 lines
---
 arch/arm64/include/asm/pgtable.h | 5 -----
 1 file changed, 5 deletions(-)
arch/arm64/include/asm/pgtable.h +0 -0
index 0b2a2ad1b9e8..15211f74b035 100644
@@ -620,11 +620,6 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd)
 #define pud_pfn(pud)		((__pud_to_phys(pud) & PUD_MASK) >> PAGE_SHIFT)

arch/arm64/include/asm/pgtable.h static inline pmd_t pmd_mkspecial(pmd_t pmd) · line 625

Quoted 10 lines
arch/arm64/include/asm/pgtable.h +0 -5
 #define pfn_pud(pfn,prot)	__pud(__phys_to_pud_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
-#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
-#define pud_special(pte)	pte_special(pud_pte(pud))
-#define pud_mkspecial(pte)	pte_pud(pte_mkspecial(pud_pte(pud)))
-#endif
-
 #define pmd_pgprot pmd_pgprot
 static inline pgprot_t pmd_pgprot(pmd_t pmd)
 {

LGTM

maintainer Applied
#4 lore raw
In reply to Peter Xu
Quoted 8 lines · Peter Xu

Keith Busch observed some incorrect macros defined in arm64 code [1].

It turns out the two lines should never be needed and won't be exposed to anyone, because aarch64 doesn't select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD, hence ARCH_SUPPORTS_PUD_PFNMAP is always N. The only archs that support THP PUDs so far are x86 and powerpc.

[...]

Applied to arm64 (for-next/core), thanks!

[1/1] mm/arm64: Drop dead code for pud special bit handling

      https://git.kernel.org/arm64/c/0fff2aa96f6b
Signature · 1 line
Catalin