Skip to content

Commit ba89f9c

Browse files
committed
arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
These four architectures define the same Kconfig symbols for configuring the page size. Move the logic into a common place where it can be shared with all other architectures. Reviewed-by: Thomas Gleixner <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 3391538 commit ba89f9c

File tree

9 files changed

+123
-161
lines changed

9 files changed

+123
-161
lines changed

arch/Kconfig

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,17 +1078,107 @@ config HAVE_ARCH_COMPAT_MMAP_BASES
10781078
and vice-versa 32-bit applications to call 64-bit mmap().
10791079
Required for applications doing different bitness syscalls.
10801080

1081+
config HAVE_PAGE_SIZE_4KB
1082+
bool
1083+
1084+
config HAVE_PAGE_SIZE_8KB
1085+
bool
1086+
1087+
config HAVE_PAGE_SIZE_16KB
1088+
bool
1089+
1090+
config HAVE_PAGE_SIZE_32KB
1091+
bool
1092+
1093+
config HAVE_PAGE_SIZE_64KB
1094+
bool
1095+
1096+
config HAVE_PAGE_SIZE_256KB
1097+
bool
1098+
1099+
choice
1100+
prompt "MMU page size"
1101+
1102+
config PAGE_SIZE_4KB
1103+
bool "4KiB pages"
1104+
depends on HAVE_PAGE_SIZE_4KB
1105+
help
1106+
This option select the standard 4KiB Linux page size and the only
1107+
available option on many architectures. Using 4KiB page size will
1108+
minimize memory consumption and is therefore recommended for low
1109+
memory systems.
1110+
Some software that is written for x86 systems makes incorrect
1111+
assumptions about the page size and only runs on 4KiB pages.
1112+
1113+
config PAGE_SIZE_8KB
1114+
bool "8KiB pages"
1115+
depends on HAVE_PAGE_SIZE_8KB
1116+
help
1117+
This option is the only supported page size on a few older
1118+
processors, and can be slightly faster than 4KiB pages.
1119+
1120+
config PAGE_SIZE_16KB
1121+
bool "16KiB pages"
1122+
depends on HAVE_PAGE_SIZE_16KB
1123+
help
1124+
This option is usually a good compromise between memory
1125+
consumption and performance for typical desktop and server
1126+
workloads, often saving a level of page table lookups compared
1127+
to 4KB pages as well as reducing TLB pressure and overhead of
1128+
per-page operations in the kernel at the expense of a larger
1129+
page cache.
1130+
1131+
config PAGE_SIZE_32KB
1132+
bool "32KiB pages"
1133+
depends on HAVE_PAGE_SIZE_32KB
1134+
help
1135+
Using 32KiB page size will result in slightly higher performance
1136+
kernel at the price of higher memory consumption compared to
1137+
16KiB pages. This option is available only on cnMIPS cores.
1138+
Note that you will need a suitable Linux distribution to
1139+
support this.
1140+
1141+
config PAGE_SIZE_64KB
1142+
bool "64KiB pages"
1143+
depends on HAVE_PAGE_SIZE_64KB
1144+
help
1145+
Using 64KiB page size will result in slightly higher performance
1146+
kernel at the price of much higher memory consumption compared to
1147+
4KiB or 16KiB pages.
1148+
This is not suitable for general-purpose workloads but the
1149+
better performance may be worth the cost for certain types of
1150+
supercomputing or database applications that work mostly with
1151+
large in-memory data rather than small files.
1152+
1153+
config PAGE_SIZE_256KB
1154+
bool "256KiB pages"
1155+
depends on HAVE_PAGE_SIZE_256KB
1156+
help
1157+
256KiB pages have little practical value due to their extreme
1158+
memory usage. The kernel will only be able to run applications
1159+
that have been compiled with '-zmax-page-size' set to 256KiB
1160+
(the default is 64KiB or 4KiB on most architectures).
1161+
1162+
endchoice
1163+
10811164
config PAGE_SIZE_LESS_THAN_64KB
10821165
def_bool y
1083-
depends on !ARM64_64K_PAGES
10841166
depends on !PAGE_SIZE_64KB
1085-
depends on !PARISC_PAGE_SIZE_64KB
10861167
depends on PAGE_SIZE_LESS_THAN_256KB
10871168

10881169
config PAGE_SIZE_LESS_THAN_256KB
10891170
def_bool y
10901171
depends on !PAGE_SIZE_256KB
10911172

1173+
config PAGE_SHIFT
1174+
int
1175+
default 12 if PAGE_SIZE_4KB
1176+
default 13 if PAGE_SIZE_8KB
1177+
default 14 if PAGE_SIZE_16KB
1178+
default 15 if PAGE_SIZE_32KB
1179+
default 16 if PAGE_SIZE_64KB
1180+
default 18 if PAGE_SIZE_256KB
1181+
10921182
# This allows to use a set of generic functions to determine mmap base
10931183
# address by giving priority to top-down scheme only if the process
10941184
# is not in legacy mode (compat task, unlimited stack size or

arch/hexagon/Kconfig

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ config HEXAGON
88
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
99
select ARCH_NO_PREEMPT
1010
select DMA_GLOBAL_POOL
11+
select HAVE_PAGE_SIZE_4KB
12+
select HAVE_PAGE_SIZE_16KB
13+
select HAVE_PAGE_SIZE_64KB
14+
select HAVE_PAGE_SIZE_256KB
1115
# Other pending projects/to-do items.
1216
# select HAVE_REGS_AND_STACK_ACCESS_API
1317
# select HAVE_HW_BREAKPOINT if PERF_EVENTS
@@ -120,26 +124,6 @@ config NR_CPUS
120124
This is purely to save memory - each supported CPU adds
121125
approximately eight kilobytes to the kernel image.
122126

123-
choice
124-
prompt "Kernel page size"
125-
default PAGE_SIZE_4KB
126-
help
127-
Changes the default page size; use with caution.
128-
129-
config PAGE_SIZE_4KB
130-
bool "4KB"
131-
132-
config PAGE_SIZE_16KB
133-
bool "16KB"
134-
135-
config PAGE_SIZE_64KB
136-
bool "64KB"
137-
138-
config PAGE_SIZE_256KB
139-
bool "256KB"
140-
141-
endchoice
142-
143127
source "kernel/Kconfig.hz"
144128

145129
endmenu

arch/hexagon/include/asm/page.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,22 @@
1313
/* This is probably not the most graceful way to handle this. */
1414

1515
#ifdef CONFIG_PAGE_SIZE_4KB
16-
#define PAGE_SHIFT 12
1716
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_4KB
1817
#endif
1918

2019
#ifdef CONFIG_PAGE_SIZE_16KB
21-
#define PAGE_SHIFT 14
2220
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_16KB
2321
#endif
2422

2523
#ifdef CONFIG_PAGE_SIZE_64KB
26-
#define PAGE_SHIFT 16
2724
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_64KB
2825
#endif
2926

3027
#ifdef CONFIG_PAGE_SIZE_256KB
31-
#define PAGE_SHIFT 18
3228
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_256KB
3329
#endif
3430

3531
#ifdef CONFIG_PAGE_SIZE_1MB
36-
#define PAGE_SHIFT 20
3732
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_1MB
3833
#endif
3934

@@ -50,6 +45,7 @@
5045
#define HVM_HUGEPAGE_SIZE 0x5
5146
#endif
5247

48+
#define PAGE_SHIFT CONFIG_PAGE_SHIFT
5349
#define PAGE_SIZE (1UL << PAGE_SHIFT)
5450
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
5551

arch/loongarch/Kconfig

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,6 @@ config MACH_LOONGSON64
227227
config FIX_EARLYCON_MEM
228228
def_bool y
229229

230-
config PAGE_SIZE_4KB
231-
bool
232-
233-
config PAGE_SIZE_16KB
234-
bool
235-
236-
config PAGE_SIZE_64KB
237-
bool
238-
239230
config PGTABLE_2LEVEL
240231
bool
241232

@@ -288,47 +279,47 @@ choice
288279

289280
config 4KB_3LEVEL
290281
bool "4KB with 3 levels"
291-
select PAGE_SIZE_4KB
282+
select HAVE_PAGE_SIZE_4KB
292283
select PGTABLE_3LEVEL
293284
help
294285
This option selects 4KB page size with 3 level page tables, which
295286
support a maximum of 39 bits of application virtual memory.
296287

297288
config 4KB_4LEVEL
298289
bool "4KB with 4 levels"
299-
select PAGE_SIZE_4KB
290+
select HAVE_PAGE_SIZE_4KB
300291
select PGTABLE_4LEVEL
301292
help
302293
This option selects 4KB page size with 4 level page tables, which
303294
support a maximum of 48 bits of application virtual memory.
304295

305296
config 16KB_2LEVEL
306297
bool "16KB with 2 levels"
307-
select PAGE_SIZE_16KB
298+
select HAVE_PAGE_SIZE_16KB
308299
select PGTABLE_2LEVEL
309300
help
310301
This option selects 16KB page size with 2 level page tables, which
311302
support a maximum of 36 bits of application virtual memory.
312303

313304
config 16KB_3LEVEL
314305
bool "16KB with 3 levels"
315-
select PAGE_SIZE_16KB
306+
select HAVE_PAGE_SIZE_16KB
316307
select PGTABLE_3LEVEL
317308
help
318309
This option selects 16KB page size with 3 level page tables, which
319310
support a maximum of 47 bits of application virtual memory.
320311

321312
config 64KB_2LEVEL
322313
bool "64KB with 2 levels"
323-
select PAGE_SIZE_64KB
314+
select HAVE_PAGE_SIZE_64KB
324315
select PGTABLE_2LEVEL
325316
help
326317
This option selects 64KB page size with 2 level page tables, which
327318
support a maximum of 42 bits of application virtual memory.
328319

329320
config 64KB_3LEVEL
330321
bool "64KB with 3 levels"
331-
select PAGE_SIZE_64KB
322+
select HAVE_PAGE_SIZE_64KB
332323
select PGTABLE_3LEVEL
333324
help
334325
This option selects 64KB page size with 3 level page tables, which

arch/loongarch/include/asm/page.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@
1111
/*
1212
* PAGE_SHIFT determines the page size
1313
*/
14-
#ifdef CONFIG_PAGE_SIZE_4KB
15-
#define PAGE_SHIFT 12
16-
#endif
17-
#ifdef CONFIG_PAGE_SIZE_16KB
18-
#define PAGE_SHIFT 14
19-
#endif
20-
#ifdef CONFIG_PAGE_SIZE_64KB
21-
#define PAGE_SHIFT 16
22-
#endif
14+
#define PAGE_SHIFT CONFIG_PAGE_SHIFT
2315
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
2416
#define PAGE_MASK (~(PAGE_SIZE - 1))
2517

arch/mips/Kconfig

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ config MIPS
8181
select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
8282
select HAVE_MOD_ARCH_SPECIFIC
8383
select HAVE_NMI
84+
select HAVE_PAGE_SIZE_4KB if !CPU_LOONGSON2EF && !CPU_LOONGSON64
85+
select HAVE_PAGE_SIZE_16KB if !CPU_R3000
86+
select HAVE_PAGE_SIZE_64KB if !CPU_R3000
8487
select HAVE_PERF_EVENTS
8588
select HAVE_PERF_REGS
8689
select HAVE_PERF_USER_STACK_DUMP
@@ -1608,6 +1611,8 @@ config CPU_CAVIUM_OCTEON
16081611
depends on SYS_HAS_CPU_CAVIUM_OCTEON
16091612
select CPU_HAS_PREFETCH
16101613
select CPU_SUPPORTS_64BIT_KERNEL
1614+
select HAVE_PAGE_SIZE_8KB if !MIPS_VA_BITS_48
1615+
select HAVE_PAGE_SIZE_32KB if !MIPS_VA_BITS_48
16111616
select WEAK_ORDERING
16121617
select CPU_SUPPORTS_HIGHMEM
16131618
select CPU_SUPPORTS_HUGEPAGES
@@ -2029,59 +2034,6 @@ config ZBOOT_LOAD_ADDRESS
20292034

20302035
This is only used if non-zero.
20312036

2032-
choice
2033-
prompt "Kernel page size"
2034-
default PAGE_SIZE_4KB
2035-
2036-
config PAGE_SIZE_4KB
2037-
bool "4kB"
2038-
depends on !CPU_LOONGSON2EF && !CPU_LOONGSON64
2039-
help
2040-
This option select the standard 4kB Linux page size. On some
2041-
R3000-family processors this is the only available page size. Using
2042-
4kB page size will minimize memory consumption and is therefore
2043-
recommended for low memory systems.
2044-
2045-
config PAGE_SIZE_8KB
2046-
bool "8kB"
2047-
depends on CPU_CAVIUM_OCTEON
2048-
depends on !MIPS_VA_BITS_48
2049-
help
2050-
Using 8kB page size will result in higher performance kernel at
2051-
the price of higher memory consumption. This option is available
2052-
only on cnMIPS processors. Note that you will need a suitable Linux
2053-
distribution to support this.
2054-
2055-
config PAGE_SIZE_16KB
2056-
bool "16kB"
2057-
depends on !CPU_R3000
2058-
help
2059-
Using 16kB page size will result in higher performance kernel at
2060-
the price of higher memory consumption. This option is available on
2061-
all non-R3000 family processors. Note that you will need a suitable
2062-
Linux distribution to support this.
2063-
2064-
config PAGE_SIZE_32KB
2065-
bool "32kB"
2066-
depends on CPU_CAVIUM_OCTEON
2067-
depends on !MIPS_VA_BITS_48
2068-
help
2069-
Using 32kB page size will result in higher performance kernel at
2070-
the price of higher memory consumption. This option is available
2071-
only on cnMIPS cores. Note that you will need a suitable Linux
2072-
distribution to support this.
2073-
2074-
config PAGE_SIZE_64KB
2075-
bool "64kB"
2076-
depends on !CPU_R3000
2077-
help
2078-
Using 64kB page size will result in higher performance kernel at
2079-
the price of higher memory consumption. This option is available on
2080-
all non-R3000 family processor. Not that at the time of this
2081-
writing this option is still high experimental.
2082-
2083-
endchoice
2084-
20852037
config ARCH_FORCE_MAX_ORDER
20862038
int "Maximum zone order"
20872039
default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB

arch/mips/include/asm/page.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,7 @@
1717
/*
1818
* PAGE_SHIFT determines the page size
1919
*/
20-
#ifdef CONFIG_PAGE_SIZE_4KB
21-
#define PAGE_SHIFT 12
22-
#endif
23-
#ifdef CONFIG_PAGE_SIZE_8KB
24-
#define PAGE_SHIFT 13
25-
#endif
26-
#ifdef CONFIG_PAGE_SIZE_16KB
27-
#define PAGE_SHIFT 14
28-
#endif
29-
#ifdef CONFIG_PAGE_SIZE_32KB
30-
#define PAGE_SHIFT 15
31-
#endif
32-
#ifdef CONFIG_PAGE_SIZE_64KB
33-
#define PAGE_SHIFT 16
34-
#endif
20+
#define PAGE_SHIFT CONFIG_PAGE_SHIFT
3521
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
3622
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
3723

arch/sh/include/asm/page.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@
99
#include <linux/const.h>
1010

1111
/* PAGE_SHIFT determines the page size */
12-
#if defined(CONFIG_PAGE_SIZE_4KB)
13-
# define PAGE_SHIFT 12
14-
#elif defined(CONFIG_PAGE_SIZE_8KB)
15-
# define PAGE_SHIFT 13
16-
#elif defined(CONFIG_PAGE_SIZE_16KB)
17-
# define PAGE_SHIFT 14
18-
#elif defined(CONFIG_PAGE_SIZE_64KB)
19-
# define PAGE_SHIFT 16
20-
#else
21-
# error "Bogus kernel page size?"
22-
#endif
23-
12+
#define PAGE_SHIFT CONFIG_PAGE_SHIFT
2413
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
2514
#define PAGE_MASK (~(PAGE_SIZE-1))
2615
#define PTE_MASK PAGE_MASK

0 commit comments

Comments
 (0)