Skip to content

Commit b0284cd

Browse files
ctmarinasMarc Zyngier
authored andcommitted
mm: Do not enable PG_arch_2 for all 64-bit architectures
Commit 4beba94 ("mm: Add PG_arch_2 page flag") introduced a new page flag for all 64-bit architectures. However, even if an architecture is 64-bit, it may still have limited spare bits in the 'flags' member of 'struct page'. This may happen if an architecture enables SPARSEMEM without SPARSEMEM_VMEMMAP as is the case with the newly added loongarch. This architecture port needs 19 more bits for the sparsemem section information and, while it is currently fine with PG_arch_2, adding any more PG_arch_* flags will trigger build-time warnings. Add a new CONFIG_ARCH_USES_PG_ARCH_X option which can be selected by architectures that need more PG_arch_* flags beyond PG_arch_1. Select it on arm64. Signed-off-by: Catalin Marinas <[email protected]> [[email protected]: fix build with CONFIG_ARM64_MTE disabled] Signed-off-by: Peter Collingbourne <[email protected]> Reported-by: kernel test robot <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Steven Price <[email protected]> Reviewed-by: Steven Price <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 30a0b95 commit b0284cd

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@ config ARM64_MTE
19651965
depends on ARM64_PAN
19661966
select ARCH_HAS_SUBPAGE_FAULTS
19671967
select ARCH_USES_HIGH_VMA_FLAGS
1968+
select ARCH_USES_PG_ARCH_X
19681969
help
19691970
Memory Tagging (part of the ARMv8.5 Extensions) provides
19701971
architectural support for run-time, always-on detection of

fs/proc/page.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ u64 stable_page_flags(struct page *page)
219219
u |= kpf_copy_bit(k, KPF_PRIVATE_2, PG_private_2);
220220
u |= kpf_copy_bit(k, KPF_OWNER_PRIVATE, PG_owner_priv_1);
221221
u |= kpf_copy_bit(k, KPF_ARCH, PG_arch_1);
222-
#ifdef CONFIG_64BIT
222+
#ifdef CONFIG_ARCH_USES_PG_ARCH_X
223223
u |= kpf_copy_bit(k, KPF_ARCH_2, PG_arch_2);
224224
#endif
225225

include/linux/page-flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ enum pageflags {
132132
PG_young,
133133
PG_idle,
134134
#endif
135-
#ifdef CONFIG_64BIT
135+
#ifdef CONFIG_ARCH_USES_PG_ARCH_X
136136
PG_arch_2,
137137
#endif
138138
#ifdef CONFIG_KASAN_HW_TAGS

include/trace/events/mmflags.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@
9191
#define IF_HAVE_PG_IDLE(flag,string)
9292
#endif
9393

94-
#ifdef CONFIG_64BIT
95-
#define IF_HAVE_PG_ARCH_2(flag,string) ,{1UL << flag, string}
94+
#ifdef CONFIG_ARCH_USES_PG_ARCH_X
95+
#define IF_HAVE_PG_ARCH_X(flag,string) ,{1UL << flag, string}
9696
#else
97-
#define IF_HAVE_PG_ARCH_2(flag,string)
97+
#define IF_HAVE_PG_ARCH_X(flag,string)
9898
#endif
9999

100100
#ifdef CONFIG_KASAN_HW_TAGS
@@ -130,7 +130,7 @@ IF_HAVE_PG_UNCACHED(PG_uncached, "uncached" ) \
130130
IF_HAVE_PG_HWPOISON(PG_hwpoison, "hwpoison" ) \
131131
IF_HAVE_PG_IDLE(PG_young, "young" ) \
132132
IF_HAVE_PG_IDLE(PG_idle, "idle" ) \
133-
IF_HAVE_PG_ARCH_2(PG_arch_2, "arch_2" ) \
133+
IF_HAVE_PG_ARCH_X(PG_arch_2, "arch_2" ) \
134134
IF_HAVE_PG_SKIP_KASAN_POISON(PG_skip_kasan_poison, "skip_kasan_poison")
135135

136136
#define show_page_flags(flags) \

mm/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,14 @@ config ARCH_USES_HIGH_VMA_FLAGS
10051005
config ARCH_HAS_PKEYS
10061006
bool
10071007

1008+
config ARCH_USES_PG_ARCH_X
1009+
bool
1010+
help
1011+
Enable the definition of PG_arch_x page flags with x > 1. Only
1012+
suitable for 64-bit architectures with CONFIG_FLATMEM or
1013+
CONFIG_SPARSEMEM_VMEMMAP enabled, otherwise there may not be
1014+
enough room for additional bits in page->flags.
1015+
10081016
config VM_EVENT_COUNTERS
10091017
default y
10101018
bool "Enable VM event counters for /proc/vmstat" if EXPERT

mm/huge_memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ static void __split_huge_page_tail(struct page *head, int tail,
24442444
(1L << PG_workingset) |
24452445
(1L << PG_locked) |
24462446
(1L << PG_unevictable) |
2447-
#ifdef CONFIG_64BIT
2447+
#ifdef CONFIG_ARCH_USES_PG_ARCH_X
24482448
(1L << PG_arch_2) |
24492449
#endif
24502450
(1L << PG_dirty) |

0 commit comments

Comments
 (0)