Commit ba89f9c8 authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

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: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 3391538f
Loading
Loading
Loading
Loading
+92 −2
Original line number Diff line number Diff line
@@ -1078,17 +1078,107 @@ config HAVE_ARCH_COMPAT_MMAP_BASES
	  and vice-versa 32-bit applications to call 64-bit mmap().
	  Required for applications doing different bitness syscalls.

config HAVE_PAGE_SIZE_4KB
	bool

config HAVE_PAGE_SIZE_8KB
	bool

config HAVE_PAGE_SIZE_16KB
	bool

config HAVE_PAGE_SIZE_32KB
	bool

config HAVE_PAGE_SIZE_64KB
	bool

config HAVE_PAGE_SIZE_256KB
	bool

choice
	prompt "MMU page size"

config PAGE_SIZE_4KB
	bool "4KiB pages"
	depends on HAVE_PAGE_SIZE_4KB
	help
	  This option select the standard 4KiB Linux page size and the only
	  available option on many architectures. Using 4KiB page size will
	  minimize memory consumption and is therefore recommended for low
	  memory systems.
	  Some software that is written for x86 systems makes incorrect
	  assumptions about the page size and only runs on 4KiB pages.

config PAGE_SIZE_8KB
	bool "8KiB pages"
	depends on HAVE_PAGE_SIZE_8KB
	help
	  This option is the only supported page size on a few older
	  processors, and can be slightly faster than 4KiB pages.

config PAGE_SIZE_16KB
	bool "16KiB pages"
	depends on HAVE_PAGE_SIZE_16KB
	help
	  This option is usually a good compromise between memory
	  consumption and performance for typical desktop and server
	  workloads, often saving a level of page table lookups compared
	  to 4KB pages as well as reducing TLB pressure and overhead of
	  per-page operations in the kernel at the expense of a larger
	  page cache.

config PAGE_SIZE_32KB
	bool "32KiB pages"
	depends on HAVE_PAGE_SIZE_32KB
	help
	  Using 32KiB page size will result in slightly higher performance
	  kernel at the price of higher memory consumption compared to
	  16KiB pages.	This option is available only on cnMIPS cores.
	  Note that you will need a suitable Linux distribution to
	  support this.

config PAGE_SIZE_64KB
	bool "64KiB pages"
	depends on HAVE_PAGE_SIZE_64KB
	help
	  Using 64KiB page size will result in slightly higher performance
	  kernel at the price of much higher memory consumption compared to
	  4KiB or 16KiB pages.
	  This is not suitable for general-purpose workloads but the
	  better performance may be worth the cost for certain types of
	  supercomputing or database applications that work mostly with
	  large in-memory data rather than small files.

config PAGE_SIZE_256KB
	bool "256KiB pages"
	depends on HAVE_PAGE_SIZE_256KB
	help
	  256KiB pages have little practical value due to their extreme
	  memory usage.  The kernel will only be able to run applications
	  that have been compiled with '-zmax-page-size' set to 256KiB
	  (the default is 64KiB or 4KiB on most architectures).

endchoice

config PAGE_SIZE_LESS_THAN_64KB
	def_bool y
	depends on !ARM64_64K_PAGES
	depends on !PAGE_SIZE_64KB
	depends on !PARISC_PAGE_SIZE_64KB
	depends on PAGE_SIZE_LESS_THAN_256KB

config PAGE_SIZE_LESS_THAN_256KB
	def_bool y
	depends on !PAGE_SIZE_256KB

config PAGE_SHIFT
	int
	default 12 if PAGE_SIZE_4KB
	default 13 if PAGE_SIZE_8KB
	default 14 if PAGE_SIZE_16KB
	default 15 if PAGE_SIZE_32KB
	default 16 if PAGE_SIZE_64KB
	default 18 if PAGE_SIZE_256KB

# This allows to use a set of generic functions to determine mmap base
# address by giving priority to top-down scheme only if the process
# is not in legacy mode (compat task, unlimited stack size or
+4 −20
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ config HEXAGON
	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
	select ARCH_NO_PREEMPT
	select DMA_GLOBAL_POOL
	select HAVE_PAGE_SIZE_4KB
	select HAVE_PAGE_SIZE_16KB
	select HAVE_PAGE_SIZE_64KB
	select HAVE_PAGE_SIZE_256KB
	# Other pending projects/to-do items.
	# select HAVE_REGS_AND_STACK_ACCESS_API
	# select HAVE_HW_BREAKPOINT if PERF_EVENTS
@@ -120,26 +124,6 @@ config NR_CPUS
	  This is purely to save memory - each supported CPU adds
	  approximately eight kilobytes to the kernel image.

choice
	prompt "Kernel page size"
	default PAGE_SIZE_4KB
	help
	  Changes the default page size; use with caution.

config PAGE_SIZE_4KB
	bool "4KB"

config PAGE_SIZE_16KB
	bool "16KB"

config PAGE_SIZE_64KB
	bool "64KB"

config PAGE_SIZE_256KB
	bool "256KB"

endchoice

source "kernel/Kconfig.hz"

endmenu
+1 −5
Original line number Diff line number Diff line
@@ -13,27 +13,22 @@
/*  This is probably not the most graceful way to handle this.  */

#ifdef CONFIG_PAGE_SIZE_4KB
#define PAGE_SHIFT 12
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_4KB
#endif

#ifdef CONFIG_PAGE_SIZE_16KB
#define PAGE_SHIFT 14
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_16KB
#endif

#ifdef CONFIG_PAGE_SIZE_64KB
#define PAGE_SHIFT 16
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_64KB
#endif

#ifdef CONFIG_PAGE_SIZE_256KB
#define PAGE_SHIFT 18
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_256KB
#endif

#ifdef CONFIG_PAGE_SIZE_1MB
#define PAGE_SHIFT 20
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_1MB
#endif

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

#define PAGE_SHIFT CONFIG_PAGE_SHIFT
#define PAGE_SIZE  (1UL << PAGE_SHIFT)
#define PAGE_MASK  (~((1 << PAGE_SHIFT) - 1))

+6 −15
Original line number Diff line number Diff line
@@ -227,15 +227,6 @@ config MACH_LOONGSON64
config FIX_EARLYCON_MEM
	def_bool y

config PAGE_SIZE_4KB
	bool

config PAGE_SIZE_16KB
	bool

config PAGE_SIZE_64KB
	bool

config PGTABLE_2LEVEL
	bool

@@ -288,7 +279,7 @@ choice

config 4KB_3LEVEL
	bool "4KB with 3 levels"
	select PAGE_SIZE_4KB
	select HAVE_PAGE_SIZE_4KB
	select PGTABLE_3LEVEL
	help
	  This option selects 4KB page size with 3 level page tables, which
@@ -296,7 +287,7 @@ config 4KB_3LEVEL

config 4KB_4LEVEL
	bool "4KB with 4 levels"
	select PAGE_SIZE_4KB
	select HAVE_PAGE_SIZE_4KB
	select PGTABLE_4LEVEL
	help
	  This option selects 4KB page size with 4 level page tables, which
@@ -304,7 +295,7 @@ config 4KB_4LEVEL

config 16KB_2LEVEL
	bool "16KB with 2 levels"
	select PAGE_SIZE_16KB
	select HAVE_PAGE_SIZE_16KB
	select PGTABLE_2LEVEL
	help
	  This option selects 16KB page size with 2 level page tables, which
@@ -312,7 +303,7 @@ config 16KB_2LEVEL

config 16KB_3LEVEL
	bool "16KB with 3 levels"
	select PAGE_SIZE_16KB
	select HAVE_PAGE_SIZE_16KB
	select PGTABLE_3LEVEL
	help
	  This option selects 16KB page size with 3 level page tables, which
@@ -320,7 +311,7 @@ config 16KB_3LEVEL

config 64KB_2LEVEL
	bool "64KB with 2 levels"
	select PAGE_SIZE_64KB
	select HAVE_PAGE_SIZE_64KB
	select PGTABLE_2LEVEL
	help
	  This option selects 64KB page size with 2 level page tables, which
@@ -328,7 +319,7 @@ config 64KB_2LEVEL

config 64KB_3LEVEL
	bool "64KB with 3 levels"
	select PAGE_SIZE_64KB
	select HAVE_PAGE_SIZE_64KB
	select PGTABLE_3LEVEL
	help
	  This option selects 64KB page size with 3 level page tables, which
+1 −9
Original line number Diff line number Diff line
@@ -11,15 +11,7 @@
/*
 * PAGE_SHIFT determines the page size
 */
#ifdef CONFIG_PAGE_SIZE_4KB
#define PAGE_SHIFT	12
#endif
#ifdef CONFIG_PAGE_SIZE_16KB
#define PAGE_SHIFT	14
#endif
#ifdef CONFIG_PAGE_SIZE_64KB
#define PAGE_SHIFT	16
#endif
#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
#define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
#define PAGE_MASK	(~(PAGE_SIZE - 1))

Loading