linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] arch: mm, vdso: consolidate PAGE_SIZE definition
@ 2024-02-26 16:14 Arnd Bergmann
  2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-26 16:14 UTC (permalink / raw)
  To: Thomas Gleixner, Vincenzo Frascino, Kees Cook, Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

From: Arnd Bergmann <arnd@arndb.de>

Naresh noticed that the newly added usage of the PAGE_SIZE macro in
include/vdso/datapage.h introduced a build regression. I had an older
patch that I revived to have this defined through Kconfig rather than
through including asm/page.h, which is not allowed in vdso code.

I rebased and tested on top of the tip/timers/core branch that
introduced the regression. If these patches get added, the
compat VDSOs all build again, but the changes are a bit invasive.

      Arnd

Link: https://lore.kernel.org/lkml/CA+G9fYtrXXm_KO9fNPz3XaRxHV7UD_yQp-TEuPQrNRHU+_0W_Q@mail.gmail.com/
Link: https://lore.kernel.org/all/65dc6c14.170a0220.f4a3f.91dd@mx.google.com/

Arnd Bergmann (4):
  arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  arch: simplify architecture specific page size configuration
  arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  vdso: avoid including asm/page.h

 arch/Kconfig                       | 58 ++++++++++++++++++++++++++++--
 arch/alpha/Kconfig                 |  1 +
 arch/alpha/include/asm/page.h      |  2 +-
 arch/arc/Kconfig                   |  3 ++
 arch/arc/include/uapi/asm/page.h   |  6 ++--
 arch/arm/Kconfig                   |  1 +
 arch/arm/include/asm/page.h        |  2 +-
 arch/arm64/Kconfig                 | 29 +++++++--------
 arch/arm64/include/asm/page-def.h  |  2 +-
 arch/csky/Kconfig                  |  1 +
 arch/csky/include/asm/page.h       |  2 +-
 arch/hexagon/Kconfig               | 25 +++----------
 arch/hexagon/include/asm/page.h    |  6 +---
 arch/loongarch/Kconfig             | 21 ++++-------
 arch/loongarch/include/asm/page.h  | 10 +-----
 arch/m68k/Kconfig                  |  3 ++
 arch/m68k/Kconfig.cpu              |  2 ++
 arch/m68k/include/asm/page.h       |  6 +---
 arch/microblaze/Kconfig            |  1 +
 arch/microblaze/include/asm/page.h |  2 +-
 arch/mips/Kconfig                  | 58 +++---------------------------
 arch/mips/include/asm/page.h       | 16 +--------
 arch/nios2/Kconfig                 |  1 +
 arch/nios2/include/asm/page.h      |  2 +-
 arch/openrisc/Kconfig              |  1 +
 arch/openrisc/include/asm/page.h   |  2 +-
 arch/parisc/Kconfig                |  3 ++
 arch/parisc/include/asm/page.h     | 10 +-----
 arch/powerpc/Kconfig               | 31 ++++------------
 arch/powerpc/include/asm/page.h    |  2 +-
 arch/riscv/Kconfig                 |  1 +
 arch/riscv/include/asm/page.h      |  2 +-
 arch/s390/Kconfig                  |  1 +
 arch/s390/include/asm/page.h       |  2 +-
 arch/sh/include/asm/page.h         | 13 +------
 arch/sh/mm/Kconfig                 | 42 +++++++---------------
 arch/sparc/Kconfig                 |  2 ++
 arch/sparc/include/asm/page_32.h   |  2 +-
 arch/sparc/include/asm/page_64.h   |  3 +-
 arch/um/Kconfig                    |  1 +
 arch/um/include/asm/page.h         |  2 +-
 arch/x86/Kconfig                   |  1 +
 arch/x86/include/asm/page_types.h  |  2 +-
 arch/xtensa/Kconfig                |  1 +
 arch/xtensa/include/asm/page.h     |  2 +-
 include/vdso/datapage.h            |  4 +--
 scripts/gdb/linux/constants.py.in  |  2 +-
 scripts/gdb/linux/mm.py            |  2 +-
 48 files changed, 153 insertions(+), 241 deletions(-)

-- 
2.39.2
To: Thomas Gleixner <tglx@linutronix.de>
To: Vincenzo Frascino <vincenzo.frascino@arm.com>
To: Kees Cook <keescook@chromium.org>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Brian Cain <bcain@quicinc.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Helge Deller <deller@gmx.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: x86@kernel.org
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-alpha@vger.kernel.org
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-csky@vger.kernel.org
Cc: linux-hexagon@vger.kernel.org
Cc: loongarch@lists.linux.dev
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-openrisc@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-um@lists.infradead.org

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-26 16:14 [PATCH 0/4] arch: mm, vdso: consolidate PAGE_SIZE definition Arnd Bergmann
@ 2024-02-26 16:14 ` Arnd Bergmann
  2024-02-26 16:55   ` Samuel Holland
                     ` (2 more replies)
  2024-02-26 16:14 ` [PATCH 2/4] arch: simplify architecture specific page size configuration Arnd Bergmann
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-26 16:14 UTC (permalink / raw)
  To: Thomas Gleixner, Vincenzo Frascino, Kees Cook, Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

From: Arnd Bergmann <arnd@arndb.de>

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/Kconfig                      | 58 +++++++++++++++++++++++++++++--
 arch/hexagon/Kconfig              | 25 +++----------
 arch/hexagon/include/asm/page.h   |  6 +---
 arch/loongarch/Kconfig            | 21 ++++-------
 arch/loongarch/include/asm/page.h | 10 +-----
 arch/mips/Kconfig                 | 58 +++----------------------------
 arch/mips/include/asm/page.h      | 16 +--------
 arch/sh/include/asm/page.h        | 13 +------
 arch/sh/mm/Kconfig                | 42 +++++++---------------
 9 files changed, 88 insertions(+), 161 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index a5af0edd3eb8..237cea01ed9b 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1078,17 +1078,71 @@ 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 "4KB pages"
+	depends on HAVE_PAGE_SIZE_4KB
+
+config PAGE_SIZE_8KB
+	bool "8KB pages"
+	depends on HAVE_PAGE_SIZE_8KB
+
+config PAGE_SIZE_16KB
+	bool "16KB pages"
+	depends on HAVE_PAGE_SIZE_16KB
+
+config PAGE_SIZE_32KB
+	bool "32KB pages"
+	depends on HAVE_PAGE_SIZE_32KB
+
+config PAGE_SIZE_64KB
+	bool "64KB pages"
+	depends on HAVE_PAGE_SIZE_64KB
+
+config PAGE_SIZE_256KB
+	bool "256KB pages"
+	depends on HAVE_PAGE_SIZE_256KB
+
+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
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index a880ee067d2e..aac46ee1a000 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -8,6 +8,11 @@ config HEXAGON
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_NO_PREEMPT
 	select DMA_GLOBAL_POOL
+	select FRAME_POINTER
+	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 +125,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
diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h
index 10f1bc07423c..65c9bac639fa 100644
--- a/arch/hexagon/include/asm/page.h
+++ b/arch/hexagon/include/asm/page.h
@@ -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))
 
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 929f68926b34..b274784c2e26 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -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
diff --git a/arch/loongarch/include/asm/page.h b/arch/loongarch/include/asm/page.h
index 63f137ce82a4..afb6fa16b826 100644
--- a/arch/loongarch/include/asm/page.h
+++ b/arch/loongarch/include/asm/page.h
@@ -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))
 
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 797ae590ebdb..24bac93affee 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -81,6 +81,9 @@ config MIPS
 	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI
+	select HAVE_PAGE_SIZE_4KB if !CPU_LOONGSON2EF && !CPU_LOONGSON64
+	select HAVE_PAGE_SIZE_16KB if !CPU_R3000
+	select HAVE_PAGE_SIZE_64KB if !CPU_R3000
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
@@ -1608,6 +1611,8 @@ config CPU_CAVIUM_OCTEON
 	depends on SYS_HAS_CPU_CAVIUM_OCTEON
 	select CPU_HAS_PREFETCH
 	select CPU_SUPPORTS_64BIT_KERNEL
+	select HAVE_PAGE_SIZE_8KB if !MIPS_VA_BITS_48
+	select HAVE_PAGE_SIZE_32KB if !MIPS_VA_BITS_48
 	select WEAK_ORDERING
 	select CPU_SUPPORTS_HIGHMEM
 	select CPU_SUPPORTS_HUGEPAGES
@@ -2029,59 +2034,6 @@ config ZBOOT_LOAD_ADDRESS
 
 	  This is only used if non-zero.
 
-choice
-	prompt "Kernel page size"
-	default PAGE_SIZE_4KB
-
-config PAGE_SIZE_4KB
-	bool "4kB"
-	depends on !CPU_LOONGSON2EF && !CPU_LOONGSON64
-	help
-	  This option select the standard 4kB Linux page size.  On some
-	  R3000-family processors this is the only available page size.  Using
-	  4kB page size will minimize memory consumption and is therefore
-	  recommended for low memory systems.
-
-config PAGE_SIZE_8KB
-	bool "8kB"
-	depends on CPU_CAVIUM_OCTEON
-	depends on !MIPS_VA_BITS_48
-	help
-	  Using 8kB page size will result in higher performance kernel at
-	  the price of higher memory consumption.  This option is available
-	  only on cnMIPS processors.  Note that you will need a suitable Linux
-	  distribution to support this.
-
-config PAGE_SIZE_16KB
-	bool "16kB"
-	depends on !CPU_R3000
-	help
-	  Using 16kB page size will result in higher performance kernel at
-	  the price of higher memory consumption.  This option is available on
-	  all non-R3000 family processors.  Note that you will need a suitable
-	  Linux distribution to support this.
-
-config PAGE_SIZE_32KB
-	bool "32kB"
-	depends on CPU_CAVIUM_OCTEON
-	depends on !MIPS_VA_BITS_48
-	help
-	  Using 32kB page size will result in higher performance kernel at
-	  the price of higher memory consumption.  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 "64kB"
-	depends on !CPU_R3000
-	help
-	  Using 64kB page size will result in higher performance kernel at
-	  the price of higher memory consumption.  This option is available on
-	  all non-R3000 family processor.  Not that at the time of this
-	  writing this option is still high experimental.
-
-endchoice
-
 config ARCH_FORCE_MAX_ORDER
 	int "Maximum zone order"
 	default "13" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index ef9585d96f6b..4609cb0326cf 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -17,21 +17,7 @@
 /*
  * PAGE_SHIFT determines the page size
  */
-#ifdef CONFIG_PAGE_SIZE_4KB
-#define PAGE_SHIFT	12
-#endif
-#ifdef CONFIG_PAGE_SIZE_8KB
-#define PAGE_SHIFT	13
-#endif
-#ifdef CONFIG_PAGE_SIZE_16KB
-#define PAGE_SHIFT	14
-#endif
-#ifdef CONFIG_PAGE_SIZE_32KB
-#define PAGE_SHIFT	15
-#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	(~((1 << PAGE_SHIFT) - 1))
 
diff --git a/arch/sh/include/asm/page.h b/arch/sh/include/asm/page.h
index 62f4b9edcb98..f780b467e75d 100644
--- a/arch/sh/include/asm/page.h
+++ b/arch/sh/include/asm/page.h
@@ -9,18 +9,7 @@
 #include <linux/const.h>
 
 /* PAGE_SHIFT determines the page size */
-#if defined(CONFIG_PAGE_SIZE_4KB)
-# define PAGE_SHIFT	12
-#elif defined(CONFIG_PAGE_SIZE_8KB)
-# define PAGE_SHIFT	13
-#elif defined(CONFIG_PAGE_SIZE_16KB)
-# define PAGE_SHIFT	14
-#elif defined(CONFIG_PAGE_SIZE_64KB)
-# define PAGE_SHIFT	16
-#else
-# error "Bogus kernel page size?"
-#endif
-
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 #define PTE_MASK	PAGE_MASK
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 455311d9a5e9..f32a1963ff0c 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -4,6 +4,9 @@ menu "Memory management options"
 config MMU
         bool "Support for memory management hardware"
 	depends on !CPU_SH2
+	select HAVE_PAGE_SIZE_4KB
+	select HAVE_PAGE_SIZE_8KB if X2TLB
+	select HAVE_PAGE_SIZE_64KB if CPU_SH4
 	default y
 	help
 	  Some SH processors (such as SH-2/SH-2A) lack an MMU. In order to
@@ -13,6 +16,15 @@ config MMU
 	  turning this off will boot the kernel on these machines with the
 	  MMU implicitly switched off.
 
+config NOMMU
+	def_bool !MMU
+	select HAVE_PAGE_SIZE_4KB
+	select HAVE_PAGE_SIZE_8KB
+	select HAVE_PAGE_SIZE_16KB
+	select HAVE_PAGE_SIZE_64KB
+	help
+	  On MMU-less systems, any of these page sizes can be selected
+
 config PAGE_OFFSET
 	hex
 	default "0x80000000" if MMU
@@ -147,36 +159,6 @@ config HAVE_SRAM_POOL
 	bool
 	select GENERIC_ALLOCATOR
 
-choice
-	prompt "Kernel page size"
-	default PAGE_SIZE_4KB
-
-config PAGE_SIZE_4KB
-	bool "4kB"
-	help
-	  This is the default page size used by all SuperH CPUs.
-
-config PAGE_SIZE_8KB
-	bool "8kB"
-	depends on !MMU || X2TLB
-	help
-	  This enables 8kB pages as supported by SH-X2 and later MMUs.
-
-config PAGE_SIZE_16KB
-	bool "16kB"
-	depends on !MMU
-	help
-	  This enables 16kB pages on MMU-less SH systems.
-
-config PAGE_SIZE_64KB
-	bool "64kB"
-	depends on !MMU || CPU_SH4
-	help
-	  This enables support for 64kB pages, possible on all SH-4
-	  CPUs and later.
-
-endchoice
-
 choice
 	prompt "HugeTLB page size"
 	depends on HUGETLB_PAGE
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 2/4] arch: simplify architecture specific page size configuration
  2024-02-26 16:14 [PATCH 0/4] arch: mm, vdso: consolidate PAGE_SIZE definition Arnd Bergmann
  2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
@ 2024-02-26 16:14 ` Arnd Bergmann
  2024-02-26 19:05   ` Christophe Leroy
                     ` (2 more replies)
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
  2024-02-26 16:14 ` [PATCH 4/4] vdso: avoid including asm/page.h Arnd Bergmann
  3 siblings, 3 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-26 16:14 UTC (permalink / raw)
  To: Thomas Gleixner, Vincenzo Frascino, Kees Cook, Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

From: Arnd Bergmann <arnd@arndb.de>

arc, arm64, parisc and powerpc all have their own Kconfig symbols
in place of the common CONFIG_PAGE_SIZE_4KB symbols. Change these
so the common symbols are the ones that are actually used, while
leaving the arhcitecture specific ones as the user visible
place for configuring it, to avoid breaking user configs.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arc/Kconfig                  |  3 +++
 arch/arc/include/uapi/asm/page.h  |  6 ++----
 arch/arm64/Kconfig                | 29 +++++++++++++----------------
 arch/arm64/include/asm/page-def.h |  2 +-
 arch/parisc/Kconfig               |  3 +++
 arch/parisc/include/asm/page.h    | 10 +---------
 arch/powerpc/Kconfig              | 31 ++++++-------------------------
 arch/powerpc/include/asm/page.h   |  2 +-
 scripts/gdb/linux/constants.py.in |  2 +-
 scripts/gdb/linux/mm.py           |  2 +-
 10 files changed, 32 insertions(+), 58 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 1b0483c51cc1..4092bec198be 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -284,14 +284,17 @@ choice
 
 config ARC_PAGE_SIZE_8K
 	bool "8KB"
+	select HAVE_PAGE_SIZE_8KB
 	help
 	  Choose between 8k vs 16k
 
 config ARC_PAGE_SIZE_16K
+	select HAVE_PAGE_SIZE_16KB
 	bool "16KB"
 
 config ARC_PAGE_SIZE_4K
 	bool "4KB"
+	select HAVE_PAGE_SIZE_4KB
 	depends on ARC_MMU_V3 || ARC_MMU_V4
 
 endchoice
diff --git a/arch/arc/include/uapi/asm/page.h b/arch/arc/include/uapi/asm/page.h
index 2a4ad619abfb..7fd9e741b527 100644
--- a/arch/arc/include/uapi/asm/page.h
+++ b/arch/arc/include/uapi/asm/page.h
@@ -13,10 +13,8 @@
 #include <linux/const.h>
 
 /* PAGE_SHIFT determines the page size */
-#if defined(CONFIG_ARC_PAGE_SIZE_16K)
-#define PAGE_SHIFT 14
-#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
-#define PAGE_SHIFT 12
+#ifdef __KERNEL__
+#define PAGE_SHIFT CONFIG_PAGE_SHIFT
 #else
 /*
  * Default 8k
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index aa7c1d435139..29290b8cb36d 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -277,27 +277,21 @@ config 64BIT
 config MMU
 	def_bool y
 
-config ARM64_PAGE_SHIFT
-	int
-	default 16 if ARM64_64K_PAGES
-	default 14 if ARM64_16K_PAGES
-	default 12
-
 config ARM64_CONT_PTE_SHIFT
 	int
-	default 5 if ARM64_64K_PAGES
-	default 7 if ARM64_16K_PAGES
+	default 5 if PAGE_SIZE_64KB
+	default 7 if PAGE_SIZE_16KB
 	default 4
 
 config ARM64_CONT_PMD_SHIFT
 	int
-	default 5 if ARM64_64K_PAGES
-	default 5 if ARM64_16K_PAGES
+	default 5 if PAGE_SIZE_64KB
+	default 5 if PAGE_SIZE_16KB
 	default 4
 
 config ARCH_MMAP_RND_BITS_MIN
-	default 14 if ARM64_64K_PAGES
-	default 16 if ARM64_16K_PAGES
+	default 14 if PAGE_SIZE_64KB
+	default 16 if PAGE_SIZE_16KB
 	default 18
 
 # max bits determined by the following formula:
@@ -1259,11 +1253,13 @@ choice
 
 config ARM64_4K_PAGES
 	bool "4KB"
+	select HAVE_PAGE_SIZE_4KB
 	help
 	  This feature enables 4KB pages support.
 
 config ARM64_16K_PAGES
 	bool "16KB"
+	select HAVE_PAGE_SIZE_16KB
 	help
 	  The system will use 16KB pages support. AArch32 emulation
 	  requires applications compiled with 16K (or a multiple of 16K)
@@ -1271,6 +1267,7 @@ config ARM64_16K_PAGES
 
 config ARM64_64K_PAGES
 	bool "64KB"
+	select HAVE_PAGE_SIZE_64KB
 	help
 	  This feature enables 64KB pages support (4KB by default)
 	  allowing only two levels of page tables and faster TLB
@@ -1291,19 +1288,19 @@ choice
 
 config ARM64_VA_BITS_36
 	bool "36-bit" if EXPERT
-	depends on ARM64_16K_PAGES
+	depends on PAGE_SIZE_16KB
 
 config ARM64_VA_BITS_39
 	bool "39-bit"
-	depends on ARM64_4K_PAGES
+	depends on PAGE_SIZE_4KB
 
 config ARM64_VA_BITS_42
 	bool "42-bit"
-	depends on ARM64_64K_PAGES
+	depends on PAGE_SIZE_64KB
 
 config ARM64_VA_BITS_47
 	bool "47-bit"
-	depends on ARM64_16K_PAGES
+	depends on PAGE_SIZE_16KB
 
 config ARM64_VA_BITS_48
 	bool "48-bit"
diff --git a/arch/arm64/include/asm/page-def.h b/arch/arm64/include/asm/page-def.h
index 2403f7b4cdbf..792e9fe881dc 100644
--- a/arch/arm64/include/asm/page-def.h
+++ b/arch/arm64/include/asm/page-def.h
@@ -11,7 +11,7 @@
 #include <linux/const.h>
 
 /* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT		CONFIG_ARM64_PAGE_SHIFT
+#define PAGE_SHIFT		CONFIG_PAGE_SHIFT
 #define PAGE_SIZE		(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK		(~(PAGE_SIZE-1))
 
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 5c845e8d59d9..b180e684fa0d 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -273,6 +273,7 @@ choice
 
 config PARISC_PAGE_SIZE_4KB
 	bool "4KB"
+	select HAVE_PAGE_SIZE_4KB
 	help
 	  This lets you select the page size of the kernel.  For best
 	  performance, a page size of 16KB is recommended.  For best
@@ -288,10 +289,12 @@ config PARISC_PAGE_SIZE_4KB
 
 config PARISC_PAGE_SIZE_16KB
 	bool "16KB"
+	select HAVE_PAGE_SIZE_16KB
 	depends on PA8X00 && BROKEN && !KFENCE
 
 config PARISC_PAGE_SIZE_64KB
 	bool "64KB"
+	select HAVE_PAGE_SIZE_64KB
 	depends on PA8X00 && BROKEN && !KFENCE
 
 endchoice
diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
index 667e703c0e8f..ad4e15d12ed1 100644
--- a/arch/parisc/include/asm/page.h
+++ b/arch/parisc/include/asm/page.h
@@ -4,15 +4,7 @@
 
 #include <linux/const.h>
 
-#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
-# define PAGE_SHIFT	12
-#elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
-# define PAGE_SHIFT	14
-#elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
-# define PAGE_SHIFT	16
-#else
-# error "unknown default kernel page size"
-#endif
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b9fc064d38d2..8fad4e5d7ad5 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -212,7 +212,7 @@ config PPC
 	select HAVE_ARCH_HUGE_VMAP		if PPC_RADIX_MMU || PPC_8xx
 	select HAVE_ARCH_JUMP_LABEL
 	select HAVE_ARCH_JUMP_LABEL_RELATIVE
-	select HAVE_ARCH_KASAN			if PPC32 && PPC_PAGE_SHIFT <= 14
+	select HAVE_ARCH_KASAN			if PPC32 && PAGE_SHIFT <= 14
 	select HAVE_ARCH_KASAN			if PPC_RADIX_MMU
 	select HAVE_ARCH_KASAN			if PPC_BOOK3E_64
 	select HAVE_ARCH_KASAN_VMALLOC		if HAVE_ARCH_KASAN
@@ -809,19 +809,23 @@ choice
 config PPC_4K_PAGES
 	bool "4k page size"
 	select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
+	select HAVE_PAGE_SIZE_4KB
 
 config PPC_16K_PAGES
 	bool "16k page size"
 	depends on 44x || PPC_8xx
+	select HAVE_PAGE_SIZE_16KB
 
 config PPC_64K_PAGES
 	bool "64k page size"
 	depends on 44x || PPC_BOOK3S_64
 	select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
+	select HAVE_PAGE_SIZE_64KB
 
 config PPC_256K_PAGES
 	bool "256k page size (Requires non-standard binutils settings)"
 	depends on 44x && !PPC_47x
+	select HAVE_PAGE_SIZE_256KB
 	help
 	  Make the page size 256k.
 
@@ -832,29 +836,6 @@ config PPC_256K_PAGES
 
 endchoice
 
-config PAGE_SIZE_4KB
-	def_bool y
-	depends on PPC_4K_PAGES
-
-config PAGE_SIZE_16KB
-	def_bool y
-	depends on PPC_16K_PAGES
-
-config PAGE_SIZE_64KB
-	def_bool y
-	depends on PPC_64K_PAGES
-
-config PAGE_SIZE_256KB
-	def_bool y
-	depends on PPC_256K_PAGES
-
-config PPC_PAGE_SHIFT
-	int
-	default 18 if PPC_256K_PAGES
-	default 16 if PPC_64K_PAGES
-	default 14 if PPC_16K_PAGES
-	default 12
-
 config THREAD_SHIFT
 	int "Thread shift" if EXPERT
 	range 13 15
@@ -891,7 +872,7 @@ config DATA_SHIFT
 	default 23 if (DEBUG_PAGEALLOC || KFENCE) && PPC_8xx && PIN_TLB_DATA
 	default 19 if (DEBUG_PAGEALLOC || KFENCE) && PPC_8xx
 	default 24 if STRICT_KERNEL_RWX && PPC_85xx
-	default PPC_PAGE_SHIFT
+	default PAGE_SHIFT
 	help
 	  On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO.
 	  Smaller is the alignment, greater is the number of necessary DBATs.
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index e5fcc79b5bfb..e411e5a70ea3 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -21,7 +21,7 @@
  * page size. When using 64K pages however, whether we are really supporting
  * 64K pages in HW or not is irrelevant to those definitions.
  */
-#define PAGE_SHIFT		CONFIG_PPC_PAGE_SHIFT
+#define PAGE_SHIFT		CONFIG_PAGE_SHIFT
 #define PAGE_SIZE		(ASM_CONST(1) << PAGE_SHIFT)
 
 #ifndef __ASSEMBLY__
diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
index e810e0c27ff1..10fadc238719 100644
--- a/scripts/gdb/linux/constants.py.in
+++ b/scripts/gdb/linux/constants.py.in
@@ -139,7 +139,7 @@ LX_CONFIG(CONFIG_ARM64_64K_PAGES)
 if IS_BUILTIN(CONFIG_ARM64):
     LX_VALUE(CONFIG_ARM64_PA_BITS)
     LX_VALUE(CONFIG_ARM64_VA_BITS)
-    LX_VALUE(CONFIG_ARM64_PAGE_SHIFT)
+    LX_VALUE(CONFIG_PAGE_SHIFT)
     LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER)
 LX_CONFIG(CONFIG_SPARSEMEM)
 LX_CONFIG(CONFIG_SPARSEMEM_EXTREME)
diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
index ad5641dcb068..515730fd4c9d 100644
--- a/scripts/gdb/linux/mm.py
+++ b/scripts/gdb/linux/mm.py
@@ -41,7 +41,7 @@ class aarch64_page_ops():
             self.SECTION_SIZE_BITS = 27
         self.MAX_PHYSMEM_BITS = constants.LX_CONFIG_ARM64_VA_BITS
 
-        self.PAGE_SHIFT = constants.LX_CONFIG_ARM64_PAGE_SHIFT
+        self.PAGE_SHIFT = constants.LX_CONFIG_PAGE_SHIFT
         self.PAGE_SIZE = 1 << self.PAGE_SHIFT
         self.PAGE_MASK = (~(self.PAGE_SIZE - 1)) & ((1 << 64) - 1)
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-26 16:14 [PATCH 0/4] arch: mm, vdso: consolidate PAGE_SIZE definition Arnd Bergmann
  2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
  2024-02-26 16:14 ` [PATCH 2/4] arch: simplify architecture specific page size configuration Arnd Bergmann
@ 2024-02-26 16:14 ` Arnd Bergmann
  2024-02-27  0:49   ` Guo Ren
                     ` (4 more replies)
  2024-02-26 16:14 ` [PATCH 4/4] vdso: avoid including asm/page.h Arnd Bergmann
  3 siblings, 5 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-26 16:14 UTC (permalink / raw)
  To: Thomas Gleixner, Vincenzo Frascino, Kees Cook, Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

From: Arnd Bergmann <arnd@arndb.de>

Most architectures only support a single hardcoded page size. In order
to ensure that each one of these sets the corresponding Kconfig symbols,
change over the PAGE_SHIFT definition to the common one and allow
only the hardware page size to be selected.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/alpha/Kconfig                 | 1 +
 arch/alpha/include/asm/page.h      | 2 +-
 arch/arm/Kconfig                   | 1 +
 arch/arm/include/asm/page.h        | 2 +-
 arch/csky/Kconfig                  | 1 +
 arch/csky/include/asm/page.h       | 2 +-
 arch/m68k/Kconfig                  | 3 +++
 arch/m68k/Kconfig.cpu              | 2 ++
 arch/m68k/include/asm/page.h       | 6 +-----
 arch/microblaze/Kconfig            | 1 +
 arch/microblaze/include/asm/page.h | 2 +-
 arch/nios2/Kconfig                 | 1 +
 arch/nios2/include/asm/page.h      | 2 +-
 arch/openrisc/Kconfig              | 1 +
 arch/openrisc/include/asm/page.h   | 2 +-
 arch/riscv/Kconfig                 | 1 +
 arch/riscv/include/asm/page.h      | 2 +-
 arch/s390/Kconfig                  | 1 +
 arch/s390/include/asm/page.h       | 2 +-
 arch/sparc/Kconfig                 | 2 ++
 arch/sparc/include/asm/page_32.h   | 2 +-
 arch/sparc/include/asm/page_64.h   | 3 +--
 arch/um/Kconfig                    | 1 +
 arch/um/include/asm/page.h         | 2 +-
 arch/x86/Kconfig                   | 1 +
 arch/x86/include/asm/page_types.h  | 2 +-
 arch/xtensa/Kconfig                | 1 +
 arch/xtensa/include/asm/page.h     | 2 +-
 28 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index d6968d090d49..4f490250d323 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -14,6 +14,7 @@ config ALPHA
 	select PCI_DOMAINS if PCI
 	select PCI_SYSCALL if PCI
 	select HAVE_ASM_MODVERSIONS
+	select HAVE_PAGE_SIZE_8KB
 	select HAVE_PCSPKR_PLATFORM
 	select HAVE_PERF_EVENTS
 	select NEED_DMA_MAP_STATE
diff --git a/arch/alpha/include/asm/page.h b/arch/alpha/include/asm/page.h
index 4db1ebc0ed99..70419e6be1a3 100644
--- a/arch/alpha/include/asm/page.h
+++ b/arch/alpha/include/asm/page.h
@@ -6,7 +6,7 @@
 #include <asm/pal.h>
 
 /* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT	13
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0af6709570d1..9d52ba3a8ad1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -116,6 +116,7 @@ config ARM
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI
 	select HAVE_OPTPROBES if !THUMB2_KERNEL
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PCI if MMU
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index 119aa85d1feb..62af9f7f9e96 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -8,7 +8,7 @@
 #define _ASMARM_PAGE_H
 
 /* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT		12
+#define PAGE_SHIFT		CONFIG_PAGE_SHIFT
 #define PAGE_SIZE		(_AC(1,UL) << PAGE_SHIFT)
 #define PAGE_MASK		(~((1 << PAGE_SHIFT) - 1))
 
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index cf2a6fd7dff8..9c2723ab1c94 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -89,6 +89,7 @@ config CSKY
 	select HAVE_KPROBES if !CPU_CK610
 	select HAVE_KPROBES_ON_FTRACE if !CPU_CK610
 	select HAVE_KRETPROBES if !CPU_CK610
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h
index 4a0502e324a6..f70f37402d75 100644
--- a/arch/csky/include/asm/page.h
+++ b/arch/csky/include/asm/page.h
@@ -10,7 +10,7 @@
 /*
  * PAGE_SHIFT determines the page size: 4KB
  */
-#define PAGE_SHIFT	12
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE - 1))
 #define THREAD_SIZE	(PAGE_SIZE * 2)
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 4b3e93cac723..7b709453d5e7 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -84,12 +84,15 @@ config MMU
 
 config MMU_MOTOROLA
 	bool
+	select HAVE_PAGE_SIZE_4KB
 
 config MMU_COLDFIRE
+	select HAVE_PAGE_SIZE_8KB
 	bool
 
 config MMU_SUN3
 	bool
+	select HAVE_PAGE_SIZE_8KB
 	depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
 
 config ARCH_SUPPORTS_KEXEC
diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 9dcf245c9cbf..c777a129768a 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -30,6 +30,7 @@ config COLDFIRE
 	select GENERIC_CSUM
 	select GPIOLIB
 	select HAVE_LEGACY_CLK
+	select HAVE_PAGE_SIZE_8KB if !MMU
 
 endchoice
 
@@ -45,6 +46,7 @@ config M68000
 	select GENERIC_CSUM
 	select CPU_NO_EFFICIENT_FFS
 	select HAVE_ARCH_HASH
+	select HAVE_PAGE_SIZE_4KB
 	select LEGACY_TIMER_TICK
 	help
 	  The Freescale (was Motorola) 68000 CPU is the first generation of
diff --git a/arch/m68k/include/asm/page.h b/arch/m68k/include/asm/page.h
index a5993ad83ed8..8cfb84b49975 100644
--- a/arch/m68k/include/asm/page.h
+++ b/arch/m68k/include/asm/page.h
@@ -7,11 +7,7 @@
 #include <asm/page_offset.h>
 
 /* PAGE_SHIFT determines the page size */
-#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE)
-#define PAGE_SHIFT	13
-#else
-#define PAGE_SHIFT	12
-#endif
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 #define PAGE_OFFSET	(PAGE_OFFSET_RAW)
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 211f338d6235..f18ec02ddeb2 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -31,6 +31,7 @@ config MICROBLAZE
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_TRACER
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PCI
 	select IRQ_DOMAIN
 	select XILINX_INTC
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index 86a4ce07c192..8810f4f1c3b0 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -20,7 +20,7 @@
 #ifdef __KERNEL__
 
 /* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT		12
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(ASM_CONST(1) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index 58d9565dc2c7..79d3039b29f1 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -15,6 +15,7 @@ config NIOS2
 	select GENERIC_IRQ_SHOW
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_KGDB
+	select HAVE_PAGE_SIZE_4KB
 	select IRQ_DOMAIN
 	select LOCK_MM_AND_FIND_VMA
 	select MODULES_USE_ELF_RELA
diff --git a/arch/nios2/include/asm/page.h b/arch/nios2/include/asm/page.h
index 0ae7d9ce369b..0722f88e63cc 100644
--- a/arch/nios2/include/asm/page.h
+++ b/arch/nios2/include/asm/page.h
@@ -21,7 +21,7 @@
 /*
  * PAGE_SHIFT determines the page size
  */
-#define PAGE_SHIFT	12
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE - 1))
 
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index fd9bb76a610b..3586cda55bde 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -25,6 +25,7 @@ config OPENRISC
 	select GENERIC_CPU_DEVICES
 	select HAVE_PCI
 	select HAVE_UID16
+	select HAVE_PAGE_SIZE_8KB
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS_BROADCAST
 	select GENERIC_SMP_IDLE_THREAD
diff --git a/arch/openrisc/include/asm/page.h b/arch/openrisc/include/asm/page.h
index 44fc1fd56717..7925ce09ab5a 100644
--- a/arch/openrisc/include/asm/page.h
+++ b/arch/openrisc/include/asm/page.h
@@ -18,7 +18,7 @@
 
 /* PAGE_SHIFT determines the page size */
 
-#define PAGE_SHIFT      13
+#define PAGE_SHIFT      CONFIG_PAGE_SHIFT
 #ifdef __ASSEMBLY__
 #define PAGE_SIZE       (1 << PAGE_SHIFT)
 #else
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index bffbd869a068..792a337548f6 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -136,6 +136,7 @@ config RISCV
 	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD
 	select HAVE_MOVE_PMD
 	select HAVE_MOVE_PUD
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PCI
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
index 57e887bfa34c..2947423b5082 100644
--- a/arch/riscv/include/asm/page.h
+++ b/arch/riscv/include/asm/page.h
@@ -12,7 +12,7 @@
 #include <linux/pfn.h>
 #include <linux/const.h>
 
-#define PAGE_SHIFT	(12)
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE - 1))
 
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index fe565f3a3a91..b61c74c10050 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -199,6 +199,7 @@ config S390
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAVE_NMI
 	select HAVE_NOP_MCOUNT
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PCI
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
index 73b9c3bf377f..ded9548d11d9 100644
--- a/arch/s390/include/asm/page.h
+++ b/arch/s390/include/asm/page.h
@@ -11,7 +11,7 @@
 #include <linux/const.h>
 #include <asm/types.h>
 
-#define _PAGE_SHIFT	12
+#define _PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define _PAGE_SIZE	(_AC(1, UL) << _PAGE_SHIFT)
 #define _PAGE_MASK	(~(_PAGE_SIZE - 1))
 
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 204c43cb3d43..7e6bc6fff76b 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -58,6 +58,7 @@ config SPARC32
 	select DMA_DIRECT_REMAP
 	select GENERIC_ATOMIC64
 	select HAVE_UID16
+	select HAVE_PAGE_SIZE_4KB
 	select LOCK_MM_AND_FIND_VMA
 	select OLD_SIGACTION
 	select ZONE_DMA
@@ -75,6 +76,7 @@ config SPARC64
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
+	select HAVE_PAGE_SIZE_8KB
 	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_CONTEXT_TRACKING_USER
 	select HAVE_TIF_NOHZ
diff --git a/arch/sparc/include/asm/page_32.h b/arch/sparc/include/asm/page_32.h
index 6be6f683f98f..9977c77374cd 100644
--- a/arch/sparc/include/asm/page_32.h
+++ b/arch/sparc/include/asm/page_32.h
@@ -11,7 +11,7 @@
 
 #include <linux/const.h>
 
-#define PAGE_SHIFT   12
+#define PAGE_SHIFT   CONFIG_PAGE_SHIFT
 #define PAGE_SIZE    (_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK    (~(PAGE_SIZE-1))
 
diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h
index 254dffd85fb1..e9bd24821c93 100644
--- a/arch/sparc/include/asm/page_64.h
+++ b/arch/sparc/include/asm/page_64.h
@@ -4,8 +4,7 @@
 
 #include <linux/const.h>
 
-#define PAGE_SHIFT   13
-
+#define PAGE_SHIFT   CONFIG_PAGE_SHIFT
 #define PAGE_SIZE    (_AC(1,UL) << PAGE_SHIFT)
 #define PAGE_MASK    (~(PAGE_SIZE-1))
 
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index b5e179360534..93a5a8999b07 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -20,6 +20,7 @@ config UML
 	select HAVE_UID16
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DEBUG_BUGVERBOSE
+	select HAVE_PAGE_SIZE_4KB
 	select NO_DMA if !UML_DMA_EMULATION
 	select OF_EARLY_FLATTREE if OF
 	select GENERIC_IRQ_SHOW
diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
index 84866127d074..9ef9a8aedfa6 100644
--- a/arch/um/include/asm/page.h
+++ b/arch/um/include/asm/page.h
@@ -10,7 +10,7 @@
 #include <linux/const.h>
 
 /* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT	12
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5edec175b9bf..ba57eb362ec8 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -255,6 +255,7 @@ config X86
 	select HAVE_NOINSTR_VALIDATION		if HAVE_OBJTOOL
 	select HAVE_OBJTOOL			if X86_64
 	select HAVE_OPTPROBES
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PCSPKR_PLATFORM
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_EVENTS_NMI
diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
index 86bd4311daf8..9da9c8a2f1df 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -7,7 +7,7 @@
 #include <linux/mem_encrypt.h>
 
 /* PAGE_SHIFT determines the page size */
-#define PAGE_SHIFT		12
+#define PAGE_SHIFT		CONFIG_PAGE_SHIFT
 #define PAGE_SIZE		(_AC(1,UL) << PAGE_SHIFT)
 #define PAGE_MASK		(~(PAGE_SIZE-1))
 
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 6f248d87e496..87ec35b3363b 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -44,6 +44,7 @@ config XTENSA
 	select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
 	select HAVE_IRQ_TIME_ACCOUNTING
+	select HAVE_PAGE_SIZE_4KB
 	select HAVE_PCI
 	select HAVE_PERF_EVENTS
 	select HAVE_STACKPROTECTOR
diff --git a/arch/xtensa/include/asm/page.h b/arch/xtensa/include/asm/page.h
index a77d04972eb9..4db56ef052d2 100644
--- a/arch/xtensa/include/asm/page.h
+++ b/arch/xtensa/include/asm/page.h
@@ -22,7 +22,7 @@
  * PAGE_SHIFT determines the page size
  */
 
-#define PAGE_SHIFT	12
+#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
 #define PAGE_SIZE	(__XTENSA_UL_CONST(1) << PAGE_SHIFT)
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 4/4] vdso: avoid including asm/page.h
  2024-02-26 16:14 [PATCH 0/4] arch: mm, vdso: consolidate PAGE_SIZE definition Arnd Bergmann
                   ` (2 preceding siblings ...)
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
@ 2024-02-26 16:14 ` Arnd Bergmann
  2024-02-26 18:53   ` Christophe Leroy
  2024-02-27 13:46   ` Catalin Marinas
  3 siblings, 2 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-26 16:14 UTC (permalink / raw)
  To: Thomas Gleixner, Vincenzo Frascino, Kees Cook, Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um, Linux Kernel Functional Testing

From: Arnd Bergmann <arnd@arndb.de>

The recent change to the vdso_data_store broke building compat VDSO
on at least arm64 because it includes headers outside of the include/vdso/
namespace:

In file included from arch/arm64/include/asm/lse.h:5,
                 from arch/arm64/include/asm/cmpxchg.h:14,
                 from arch/arm64/include/asm/atomic.h:16,
                 from include/linux/atomic.h:7,
                 from include/asm-generic/bitops/atomic.h:5,
                 from arch/arm64/include/asm/bitops.h:25,
                 from include/linux/bitops.h:68,
                 from arch/arm64/include/asm/memory.h:209,
                 from arch/arm64/include/asm/page.h:46,
                 from include/vdso/datapage.h:22,
                 from lib/vdso/gettimeofday.c:5,
                 from <command-line>:
arch/arm64/include/asm/atomic_ll_sc.h:298:9: error: unknown type name 'u128'
  298 |         u128 full;

Use an open-coded page size calculation based on the new CONFIG_PAGE_SHIFT
Kconfig symbol instead.

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Fixes: a0d2fcd62ac2 ("vdso/ARM: Make union vdso_data_store available for all architectures")
Link: https://lore.kernel.org/lkml/CA+G9fYtrXXm_KO9fNPz3XaRxHV7UD_yQp-TEuPQrNRHU+_0W_Q@mail.gmail.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/vdso/datapage.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index 7ba44379a095..2c39a67d7e23 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -19,8 +19,6 @@
 #include <vdso/time32.h>
 #include <vdso/time64.h>
 
-#include <asm/page.h>
-
 #ifdef CONFIG_ARCH_HAS_VDSO_DATA
 #include <asm/vdso/data.h>
 #else
@@ -128,7 +126,7 @@ extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden
  */
 union vdso_data_store {
 	struct vdso_data	data[CS_BASES];
-	u8			page[PAGE_SIZE];
+	u8			page[1ul << CONFIG_PAGE_SHIFT];
 };
 
 /*
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
@ 2024-02-26 16:55   ` Samuel Holland
  2024-02-27 15:40     ` Arnd Bergmann
  2024-02-26 19:02   ` Christophe Leroy
  2024-02-27  8:45   ` Geert Uytterhoeven
  2 siblings, 1 reply; 27+ messages in thread
From: Samuel Holland @ 2024-02-26 16:55 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On 2024-02-26 10:14 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/Kconfig                      | 58 +++++++++++++++++++++++++++++--
>  arch/hexagon/Kconfig              | 25 +++----------
>  arch/hexagon/include/asm/page.h   |  6 +---
>  arch/loongarch/Kconfig            | 21 ++++-------
>  arch/loongarch/include/asm/page.h | 10 +-----
>  arch/mips/Kconfig                 | 58 +++----------------------------
>  arch/mips/include/asm/page.h      | 16 +--------
>  arch/sh/include/asm/page.h        | 13 +------
>  arch/sh/mm/Kconfig                | 42 +++++++---------------
>  9 files changed, 88 insertions(+), 161 deletions(-)
> 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index a5af0edd3eb8..237cea01ed9b 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -1078,17 +1078,71 @@ 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"

Should this have some generic help text (at least a warning about compatibility)?

> +
> +config PAGE_SIZE_4KB
> +	bool "4KB pages"
> +	depends on HAVE_PAGE_SIZE_4KB
> +
> +config PAGE_SIZE_8KB
> +	bool "8KB pages"
> +	depends on HAVE_PAGE_SIZE_8KB
> +
> +config PAGE_SIZE_16KB
> +	bool "16KB pages"
> +	depends on HAVE_PAGE_SIZE_16KB
> +
> +config PAGE_SIZE_32KB
> +	bool "32KB pages"
> +	depends on HAVE_PAGE_SIZE_32KB
> +
> +config PAGE_SIZE_64KB
> +	bool "64KB pages"
> +	depends on HAVE_PAGE_SIZE_64KB
> +
> +config PAGE_SIZE_256KB
> +	bool "256KB pages"
> +	depends on HAVE_PAGE_SIZE_256KB
> +
> +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
> diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
> index a880ee067d2e..aac46ee1a000 100644
> --- a/arch/hexagon/Kconfig
> +++ b/arch/hexagon/Kconfig
> @@ -8,6 +8,11 @@ config HEXAGON
>  	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
>  	select ARCH_NO_PREEMPT
>  	select DMA_GLOBAL_POOL
> +	select FRAME_POINTER

Looks like a paste error.

> +	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 +125,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
> diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h
> index 10f1bc07423c..65c9bac639fa 100644
> --- a/arch/hexagon/include/asm/page.h
> +++ b/arch/hexagon/include/asm/page.h
> @@ -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

The corresponding Kconfig option does not exist (and did not exist before this
patch).

>  
> @@ -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))
>  


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] vdso: avoid including asm/page.h
  2024-02-26 16:14 ` [PATCH 4/4] vdso: avoid including asm/page.h Arnd Bergmann
@ 2024-02-26 18:53   ` Christophe Leroy
  2024-02-27 12:57     ` Michael Ellerman
  2024-02-27 13:46   ` Catalin Marinas
  1 sibling, 1 reply; 27+ messages in thread
From: Christophe Leroy @ 2024-02-26 18:53 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um, Linux Kernel Functional Testing



Le 26/02/2024 à 17:14, Arnd Bergmann a écrit :
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The recent change to the vdso_data_store broke building compat VDSO
> on at least arm64 because it includes headers outside of the include/vdso/
> namespace:

I understand that powerpc64 also has an issue, see 
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20231221120410.2226678-1-mpe@ellerman.id.au/

> 
> In file included from arch/arm64/include/asm/lse.h:5,
>                   from arch/arm64/include/asm/cmpxchg.h:14,
>                   from arch/arm64/include/asm/atomic.h:16,
>                   from include/linux/atomic.h:7,
>                   from include/asm-generic/bitops/atomic.h:5,
>                   from arch/arm64/include/asm/bitops.h:25,
>                   from include/linux/bitops.h:68,
>                   from arch/arm64/include/asm/memory.h:209,
>                   from arch/arm64/include/asm/page.h:46,
>                   from include/vdso/datapage.h:22,
>                   from lib/vdso/gettimeofday.c:5,
>                   from <command-line>:
> arch/arm64/include/asm/atomic_ll_sc.h:298:9: error: unknown type name 'u128'
>    298 |         u128 full;
> 
> Use an open-coded page size calculation based on the new CONFIG_PAGE_SHIFT
> Kconfig symbol instead.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Fixes: a0d2fcd62ac2 ("vdso/ARM: Make union vdso_data_store available for all architectures")
> Link: https://lore.kernel.org/lkml/CA+G9fYtrXXm_KO9fNPz3XaRxHV7UD_yQp-TEuPQrNRHU+_0W_Q@mail.gmail.com/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   include/vdso/datapage.h | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
> index 7ba44379a095..2c39a67d7e23 100644
> --- a/include/vdso/datapage.h
> +++ b/include/vdso/datapage.h
> @@ -19,8 +19,6 @@
>   #include <vdso/time32.h>
>   #include <vdso/time64.h>
>   
> -#include <asm/page.h>
> -
>   #ifdef CONFIG_ARCH_HAS_VDSO_DATA
>   #include <asm/vdso/data.h>
>   #else
> @@ -128,7 +126,7 @@ extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden
>    */
>   union vdso_data_store {
>   	struct vdso_data	data[CS_BASES];
> -	u8			page[PAGE_SIZE];
> +	u8			page[1ul << CONFIG_PAGE_SHIFT];

Usually 1UL is used (capital letter)

Maybe better to (re)define PAGE_SIZE instead, something like:

#define PAGE_SIZE (1UL << CONFIG_PAGE_SHIFT)


>   };
>   
>   /*

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
  2024-02-26 16:55   ` Samuel Holland
@ 2024-02-26 19:02   ` Christophe Leroy
  2024-02-27 15:42     ` Arnd Bergmann
  2024-02-27  8:45   ` Geert Uytterhoeven
  2 siblings, 1 reply; 27+ messages in thread
From: Christophe Leroy @ 2024-02-26 19:02 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um



Le 26/02/2024 à 17:14, Arnd Bergmann a écrit :
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   arch/Kconfig                      | 58 +++++++++++++++++++++++++++++--
>   arch/hexagon/Kconfig              | 25 +++----------
>   arch/hexagon/include/asm/page.h   |  6 +---
>   arch/loongarch/Kconfig            | 21 ++++-------
>   arch/loongarch/include/asm/page.h | 10 +-----
>   arch/mips/Kconfig                 | 58 +++----------------------------
>   arch/mips/include/asm/page.h      | 16 +--------
>   arch/sh/include/asm/page.h        | 13 +------
>   arch/sh/mm/Kconfig                | 42 +++++++---------------
>   9 files changed, 88 insertions(+), 161 deletions(-)
> 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index a5af0edd3eb8..237cea01ed9b 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -1078,17 +1078,71 @@ 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"
> +

That's a nice re-factor.

The only drawback I see is that we are loosing several interesting 
arch-specific comments/help text. Don't know if there could be an easy 
way to keep them.


> +config PAGE_SIZE_4KB
> +	bool "4KB pages"
> +	depends on HAVE_PAGE_SIZE_4KB
> +
> +config PAGE_SIZE_8KB
> +	bool "8KB pages"
> +	depends on HAVE_PAGE_SIZE_8KB
> +
> +config PAGE_SIZE_16KB
> +	bool "16KB pages"
> +	depends on HAVE_PAGE_SIZE_16KB
> +
> +config PAGE_SIZE_32KB
> +	bool "32KB pages"
> +	depends on HAVE_PAGE_SIZE_32KB
> +
> +config PAGE_SIZE_64KB
> +	bool "64KB pages"
> +	depends on HAVE_PAGE_SIZE_64KB
> +
> +config PAGE_SIZE_256KB
> +	bool "256KB pages"
> +	depends on HAVE_PAGE_SIZE_256KB

Hexagon seem to also use CONFIG_PAGE_SIZE_1MB ?

> +
> +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
> diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
> index a880ee067d2e..aac46ee1a000 100644
> --- a/arch/hexagon/Kconfig
> +++ b/arch/hexagon/Kconfig
> @@ -8,6 +8,11 @@ config HEXAGON
>   	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
>   	select ARCH_NO_PREEMPT
>   	select DMA_GLOBAL_POOL
> +	select FRAME_POINTER
> +	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 +125,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
> diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h
> index 10f1bc07423c..65c9bac639fa 100644
> --- a/arch/hexagon/include/asm/page.h
> +++ b/arch/hexagon/include/asm/page.h
> @@ -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))
>   

Could we move PAGE_SIZE and PAGE_MASK in a generic/core header instead 
of having it duplicated for each arch ?

Christophe

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/4] arch: simplify architecture specific page size configuration
  2024-02-26 16:14 ` [PATCH 2/4] arch: simplify architecture specific page size configuration Arnd Bergmann
@ 2024-02-26 19:05   ` Christophe Leroy
  2024-02-27 13:46   ` Catalin Marinas
  2024-02-27 13:53   ` Helge Deller
  2 siblings, 0 replies; 27+ messages in thread
From: Christophe Leroy @ 2024-02-26 19:05 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um



Le 26/02/2024 à 17:14, Arnd Bergmann a écrit :
> From: Arnd Bergmann <arnd@arndb.de>
> 
> arc, arm64, parisc and powerpc all have their own Kconfig symbols
> in place of the common CONFIG_PAGE_SIZE_4KB symbols. Change these
> so the common symbols are the ones that are actually used, while
> leaving the arhcitecture specific ones as the user visible
> place for configuring it, to avoid breaking user configs.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> (powerpc32)

> ---
>   arch/arc/Kconfig                  |  3 +++
>   arch/arc/include/uapi/asm/page.h  |  6 ++----
>   arch/arm64/Kconfig                | 29 +++++++++++++----------------
>   arch/arm64/include/asm/page-def.h |  2 +-
>   arch/parisc/Kconfig               |  3 +++
>   arch/parisc/include/asm/page.h    | 10 +---------
>   arch/powerpc/Kconfig              | 31 ++++++-------------------------
>   arch/powerpc/include/asm/page.h   |  2 +-
>   scripts/gdb/linux/constants.py.in |  2 +-
>   scripts/gdb/linux/mm.py           |  2 +-
>   10 files changed, 32 insertions(+), 58 deletions(-)
> 
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 1b0483c51cc1..4092bec198be 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -284,14 +284,17 @@ choice
>   
>   config ARC_PAGE_SIZE_8K
>   	bool "8KB"
> +	select HAVE_PAGE_SIZE_8KB
>   	help
>   	  Choose between 8k vs 16k
>   
>   config ARC_PAGE_SIZE_16K
> +	select HAVE_PAGE_SIZE_16KB
>   	bool "16KB"
>   
>   config ARC_PAGE_SIZE_4K
>   	bool "4KB"
> +	select HAVE_PAGE_SIZE_4KB
>   	depends on ARC_MMU_V3 || ARC_MMU_V4
>   
>   endchoice
> diff --git a/arch/arc/include/uapi/asm/page.h b/arch/arc/include/uapi/asm/page.h
> index 2a4ad619abfb..7fd9e741b527 100644
> --- a/arch/arc/include/uapi/asm/page.h
> +++ b/arch/arc/include/uapi/asm/page.h
> @@ -13,10 +13,8 @@
>   #include <linux/const.h>
>   
>   /* PAGE_SHIFT determines the page size */
> -#if defined(CONFIG_ARC_PAGE_SIZE_16K)
> -#define PAGE_SHIFT 14
> -#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
> -#define PAGE_SHIFT 12
> +#ifdef __KERNEL__
> +#define PAGE_SHIFT CONFIG_PAGE_SHIFT
>   #else
>   /*
>    * Default 8k
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index aa7c1d435139..29290b8cb36d 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -277,27 +277,21 @@ config 64BIT
>   config MMU
>   	def_bool y
>   
> -config ARM64_PAGE_SHIFT
> -	int
> -	default 16 if ARM64_64K_PAGES
> -	default 14 if ARM64_16K_PAGES
> -	default 12
> -
>   config ARM64_CONT_PTE_SHIFT
>   	int
> -	default 5 if ARM64_64K_PAGES
> -	default 7 if ARM64_16K_PAGES
> +	default 5 if PAGE_SIZE_64KB
> +	default 7 if PAGE_SIZE_16KB
>   	default 4
>   
>   config ARM64_CONT_PMD_SHIFT
>   	int
> -	default 5 if ARM64_64K_PAGES
> -	default 5 if ARM64_16K_PAGES
> +	default 5 if PAGE_SIZE_64KB
> +	default 5 if PAGE_SIZE_16KB
>   	default 4
>   
>   config ARCH_MMAP_RND_BITS_MIN
> -	default 14 if ARM64_64K_PAGES
> -	default 16 if ARM64_16K_PAGES
> +	default 14 if PAGE_SIZE_64KB
> +	default 16 if PAGE_SIZE_16KB
>   	default 18
>   
>   # max bits determined by the following formula:
> @@ -1259,11 +1253,13 @@ choice
>   
>   config ARM64_4K_PAGES
>   	bool "4KB"
> +	select HAVE_PAGE_SIZE_4KB
>   	help
>   	  This feature enables 4KB pages support.
>   
>   config ARM64_16K_PAGES
>   	bool "16KB"
> +	select HAVE_PAGE_SIZE_16KB
>   	help
>   	  The system will use 16KB pages support. AArch32 emulation
>   	  requires applications compiled with 16K (or a multiple of 16K)
> @@ -1271,6 +1267,7 @@ config ARM64_16K_PAGES
>   
>   config ARM64_64K_PAGES
>   	bool "64KB"
> +	select HAVE_PAGE_SIZE_64KB
>   	help
>   	  This feature enables 64KB pages support (4KB by default)
>   	  allowing only two levels of page tables and faster TLB
> @@ -1291,19 +1288,19 @@ choice
>   
>   config ARM64_VA_BITS_36
>   	bool "36-bit" if EXPERT
> -	depends on ARM64_16K_PAGES
> +	depends on PAGE_SIZE_16KB
>   
>   config ARM64_VA_BITS_39
>   	bool "39-bit"
> -	depends on ARM64_4K_PAGES
> +	depends on PAGE_SIZE_4KB
>   
>   config ARM64_VA_BITS_42
>   	bool "42-bit"
> -	depends on ARM64_64K_PAGES
> +	depends on PAGE_SIZE_64KB
>   
>   config ARM64_VA_BITS_47
>   	bool "47-bit"
> -	depends on ARM64_16K_PAGES
> +	depends on PAGE_SIZE_16KB
>   
>   config ARM64_VA_BITS_48
>   	bool "48-bit"
> diff --git a/arch/arm64/include/asm/page-def.h b/arch/arm64/include/asm/page-def.h
> index 2403f7b4cdbf..792e9fe881dc 100644
> --- a/arch/arm64/include/asm/page-def.h
> +++ b/arch/arm64/include/asm/page-def.h
> @@ -11,7 +11,7 @@
>   #include <linux/const.h>
>   
>   /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT		CONFIG_ARM64_PAGE_SHIFT
> +#define PAGE_SHIFT		CONFIG_PAGE_SHIFT
>   #define PAGE_SIZE		(_AC(1, UL) << PAGE_SHIFT)
>   #define PAGE_MASK		(~(PAGE_SIZE-1))
>   
> diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> index 5c845e8d59d9..b180e684fa0d 100644
> --- a/arch/parisc/Kconfig
> +++ b/arch/parisc/Kconfig
> @@ -273,6 +273,7 @@ choice
>   
>   config PARISC_PAGE_SIZE_4KB
>   	bool "4KB"
> +	select HAVE_PAGE_SIZE_4KB
>   	help
>   	  This lets you select the page size of the kernel.  For best
>   	  performance, a page size of 16KB is recommended.  For best
> @@ -288,10 +289,12 @@ config PARISC_PAGE_SIZE_4KB
>   
>   config PARISC_PAGE_SIZE_16KB
>   	bool "16KB"
> +	select HAVE_PAGE_SIZE_16KB
>   	depends on PA8X00 && BROKEN && !KFENCE
>   
>   config PARISC_PAGE_SIZE_64KB
>   	bool "64KB"
> +	select HAVE_PAGE_SIZE_64KB
>   	depends on PA8X00 && BROKEN && !KFENCE
>   
>   endchoice
> diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
> index 667e703c0e8f..ad4e15d12ed1 100644
> --- a/arch/parisc/include/asm/page.h
> +++ b/arch/parisc/include/asm/page.h
> @@ -4,15 +4,7 @@
>   
>   #include <linux/const.h>
>   
> -#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
> -# define PAGE_SHIFT	12
> -#elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
> -# define PAGE_SHIFT	14
> -#elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
> -# define PAGE_SHIFT	16
> -#else
> -# error "unknown default kernel page size"
> -#endif
> +#define PAGE_SHIFT	CONFIG_PAGE_SHIFT
>   #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
>   #define PAGE_MASK	(~(PAGE_SIZE-1))
>   
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index b9fc064d38d2..8fad4e5d7ad5 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -212,7 +212,7 @@ config PPC
>   	select HAVE_ARCH_HUGE_VMAP		if PPC_RADIX_MMU || PPC_8xx
>   	select HAVE_ARCH_JUMP_LABEL
>   	select HAVE_ARCH_JUMP_LABEL_RELATIVE
> -	select HAVE_ARCH_KASAN			if PPC32 && PPC_PAGE_SHIFT <= 14
> +	select HAVE_ARCH_KASAN			if PPC32 && PAGE_SHIFT <= 14
>   	select HAVE_ARCH_KASAN			if PPC_RADIX_MMU
>   	select HAVE_ARCH_KASAN			if PPC_BOOK3E_64
>   	select HAVE_ARCH_KASAN_VMALLOC		if HAVE_ARCH_KASAN
> @@ -809,19 +809,23 @@ choice
>   config PPC_4K_PAGES
>   	bool "4k page size"
>   	select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
> +	select HAVE_PAGE_SIZE_4KB
>   
>   config PPC_16K_PAGES
>   	bool "16k page size"
>   	depends on 44x || PPC_8xx
> +	select HAVE_PAGE_SIZE_16KB
>   
>   config PPC_64K_PAGES
>   	bool "64k page size"
>   	depends on 44x || PPC_BOOK3S_64
>   	select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
> +	select HAVE_PAGE_SIZE_64KB
>   
>   config PPC_256K_PAGES
>   	bool "256k page size (Requires non-standard binutils settings)"
>   	depends on 44x && !PPC_47x
> +	select HAVE_PAGE_SIZE_256KB
>   	help
>   	  Make the page size 256k.
>   
> @@ -832,29 +836,6 @@ config PPC_256K_PAGES
>   
>   endchoice
>   
> -config PAGE_SIZE_4KB
> -	def_bool y
> -	depends on PPC_4K_PAGES
> -
> -config PAGE_SIZE_16KB
> -	def_bool y
> -	depends on PPC_16K_PAGES
> -
> -config PAGE_SIZE_64KB
> -	def_bool y
> -	depends on PPC_64K_PAGES
> -
> -config PAGE_SIZE_256KB
> -	def_bool y
> -	depends on PPC_256K_PAGES
> -
> -config PPC_PAGE_SHIFT
> -	int
> -	default 18 if PPC_256K_PAGES
> -	default 16 if PPC_64K_PAGES
> -	default 14 if PPC_16K_PAGES
> -	default 12
> -
>   config THREAD_SHIFT
>   	int "Thread shift" if EXPERT
>   	range 13 15
> @@ -891,7 +872,7 @@ config DATA_SHIFT
>   	default 23 if (DEBUG_PAGEALLOC || KFENCE) && PPC_8xx && PIN_TLB_DATA
>   	default 19 if (DEBUG_PAGEALLOC || KFENCE) && PPC_8xx
>   	default 24 if STRICT_KERNEL_RWX && PPC_85xx
> -	default PPC_PAGE_SHIFT
> +	default PAGE_SHIFT
>   	help
>   	  On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO.
>   	  Smaller is the alignment, greater is the number of necessary DBATs.
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index e5fcc79b5bfb..e411e5a70ea3 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -21,7 +21,7 @@
>    * page size. When using 64K pages however, whether we are really supporting
>    * 64K pages in HW or not is irrelevant to those definitions.
>    */
> -#define PAGE_SHIFT		CONFIG_PPC_PAGE_SHIFT
> +#define PAGE_SHIFT		CONFIG_PAGE_SHIFT
>   #define PAGE_SIZE		(ASM_CONST(1) << PAGE_SHIFT)
>   
>   #ifndef __ASSEMBLY__
> diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
> index e810e0c27ff1..10fadc238719 100644
> --- a/scripts/gdb/linux/constants.py.in
> +++ b/scripts/gdb/linux/constants.py.in
> @@ -139,7 +139,7 @@ LX_CONFIG(CONFIG_ARM64_64K_PAGES)
>   if IS_BUILTIN(CONFIG_ARM64):
>       LX_VALUE(CONFIG_ARM64_PA_BITS)
>       LX_VALUE(CONFIG_ARM64_VA_BITS)
> -    LX_VALUE(CONFIG_ARM64_PAGE_SHIFT)
> +    LX_VALUE(CONFIG_PAGE_SHIFT)
>       LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER)
>   LX_CONFIG(CONFIG_SPARSEMEM)
>   LX_CONFIG(CONFIG_SPARSEMEM_EXTREME)
> diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
> index ad5641dcb068..515730fd4c9d 100644
> --- a/scripts/gdb/linux/mm.py
> +++ b/scripts/gdb/linux/mm.py
> @@ -41,7 +41,7 @@ class aarch64_page_ops():
>               self.SECTION_SIZE_BITS = 27
>           self.MAX_PHYSMEM_BITS = constants.LX_CONFIG_ARM64_VA_BITS
>   
> -        self.PAGE_SHIFT = constants.LX_CONFIG_ARM64_PAGE_SHIFT
> +        self.PAGE_SHIFT = constants.LX_CONFIG_PAGE_SHIFT
>           self.PAGE_SIZE = 1 << self.PAGE_SHIFT
>           self.PAGE_MASK = (~(self.PAGE_SIZE - 1)) & ((1 << 64) - 1)
>   

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
@ 2024-02-27  0:49   ` Guo Ren
  2024-02-27  7:41   ` Heiko Carstens
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 27+ messages in thread
From: Guo Ren @ 2024-02-27  0:49 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Catalin Marinas, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On Tue, Feb 27, 2024 at 12:15 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures only support a single hardcoded page size. In order
> to ensure that each one of these sets the corresponding Kconfig symbols,
> change over the PAGE_SHIFT definition to the common one and allow
> only the hardware page size to be selected.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/alpha/Kconfig                 | 1 +
>  arch/alpha/include/asm/page.h      | 2 +-
>  arch/arm/Kconfig                   | 1 +
>  arch/arm/include/asm/page.h        | 2 +-
>  arch/csky/Kconfig                  | 1 +
>  arch/csky/include/asm/page.h       | 2 +-
>  arch/m68k/Kconfig                  | 3 +++
>  arch/m68k/Kconfig.cpu              | 2 ++
>  arch/m68k/include/asm/page.h       | 6 +-----
>  arch/microblaze/Kconfig            | 1 +
>  arch/microblaze/include/asm/page.h | 2 +-
>  arch/nios2/Kconfig                 | 1 +
>  arch/nios2/include/asm/page.h      | 2 +-
>  arch/openrisc/Kconfig              | 1 +
>  arch/openrisc/include/asm/page.h   | 2 +-
>  arch/riscv/Kconfig                 | 1 +
>  arch/riscv/include/asm/page.h      | 2 +-
>  arch/s390/Kconfig                  | 1 +
>  arch/s390/include/asm/page.h       | 2 +-
>  arch/sparc/Kconfig                 | 2 ++
>  arch/sparc/include/asm/page_32.h   | 2 +-
>  arch/sparc/include/asm/page_64.h   | 3 +--
>  arch/um/Kconfig                    | 1 +
>  arch/um/include/asm/page.h         | 2 +-
>  arch/x86/Kconfig                   | 1 +
>  arch/x86/include/asm/page_types.h  | 2 +-
>  arch/xtensa/Kconfig                | 1 +
>  arch/xtensa/include/asm/page.h     | 2 +-
>  28 files changed, 32 insertions(+), 19 deletions(-)
>
> diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> index d6968d090d49..4f490250d323 100644
> --- a/arch/alpha/Kconfig
> +++ b/arch/alpha/Kconfig
> @@ -14,6 +14,7 @@ config ALPHA
>         select PCI_DOMAINS if PCI
>         select PCI_SYSCALL if PCI
>         select HAVE_ASM_MODVERSIONS
> +       select HAVE_PAGE_SIZE_8KB
>         select HAVE_PCSPKR_PLATFORM
>         select HAVE_PERF_EVENTS
>         select NEED_DMA_MAP_STATE
> diff --git a/arch/alpha/include/asm/page.h b/arch/alpha/include/asm/page.h
> index 4db1ebc0ed99..70419e6be1a3 100644
> --- a/arch/alpha/include/asm/page.h
> +++ b/arch/alpha/include/asm/page.h
> @@ -6,7 +6,7 @@
>  #include <asm/pal.h>
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT     13
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE-1))
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 0af6709570d1..9d52ba3a8ad1 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -116,6 +116,7 @@ config ARM
>         select HAVE_MOD_ARCH_SPECIFIC
>         select HAVE_NMI
>         select HAVE_OPTPROBES if !THUMB2_KERNEL
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PCI if MMU
>         select HAVE_PERF_EVENTS
>         select HAVE_PERF_REGS
> diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
> index 119aa85d1feb..62af9f7f9e96 100644
> --- a/arch/arm/include/asm/page.h
> +++ b/arch/arm/include/asm/page.h
> @@ -8,7 +8,7 @@
>  #define _ASMARM_PAGE_H
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT             12
> +#define PAGE_SHIFT             CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE              (_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK              (~((1 << PAGE_SHIFT) - 1))
>
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index cf2a6fd7dff8..9c2723ab1c94 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -89,6 +89,7 @@ config CSKY
>         select HAVE_KPROBES if !CPU_CK610
>         select HAVE_KPROBES_ON_FTRACE if !CPU_CK610
>         select HAVE_KRETPROBES if !CPU_CK610
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PERF_EVENTS
>         select HAVE_PERF_REGS
>         select HAVE_PERF_USER_STACK_DUMP
> diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h
> index 4a0502e324a6..f70f37402d75 100644
> --- a/arch/csky/include/asm/page.h
> +++ b/arch/csky/include/asm/page.h
> @@ -10,7 +10,7 @@
>  /*
>   * PAGE_SHIFT determines the page size: 4KB
>   */
> -#define PAGE_SHIFT     12
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
LGTM, thx.
Acked-by: Guo Ren <guoren@kernel.org>

>  #define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE - 1))
>  #define THREAD_SIZE    (PAGE_SIZE * 2)
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index 4b3e93cac723..7b709453d5e7 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -84,12 +84,15 @@ config MMU
>
>  config MMU_MOTOROLA
>         bool
> +       select HAVE_PAGE_SIZE_4KB
>
>  config MMU_COLDFIRE
> +       select HAVE_PAGE_SIZE_8KB
>         bool
>
>  config MMU_SUN3
>         bool
> +       select HAVE_PAGE_SIZE_8KB
>         depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
>
>  config ARCH_SUPPORTS_KEXEC
> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> index 9dcf245c9cbf..c777a129768a 100644
> --- a/arch/m68k/Kconfig.cpu
> +++ b/arch/m68k/Kconfig.cpu
> @@ -30,6 +30,7 @@ config COLDFIRE
>         select GENERIC_CSUM
>         select GPIOLIB
>         select HAVE_LEGACY_CLK
> +       select HAVE_PAGE_SIZE_8KB if !MMU
>
>  endchoice
>
> @@ -45,6 +46,7 @@ config M68000
>         select GENERIC_CSUM
>         select CPU_NO_EFFICIENT_FFS
>         select HAVE_ARCH_HASH
> +       select HAVE_PAGE_SIZE_4KB
>         select LEGACY_TIMER_TICK
>         help
>           The Freescale (was Motorola) 68000 CPU is the first generation of
> diff --git a/arch/m68k/include/asm/page.h b/arch/m68k/include/asm/page.h
> index a5993ad83ed8..8cfb84b49975 100644
> --- a/arch/m68k/include/asm/page.h
> +++ b/arch/m68k/include/asm/page.h
> @@ -7,11 +7,7 @@
>  #include <asm/page_offset.h>
>
>  /* PAGE_SHIFT determines the page size */
> -#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE)
> -#define PAGE_SHIFT     13
> -#else
> -#define PAGE_SHIFT     12
> -#endif
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE-1))
>  #define PAGE_OFFSET    (PAGE_OFFSET_RAW)
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 211f338d6235..f18ec02ddeb2 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -31,6 +31,7 @@ config MICROBLAZE
>         select HAVE_FTRACE_MCOUNT_RECORD
>         select HAVE_FUNCTION_GRAPH_TRACER
>         select HAVE_FUNCTION_TRACER
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PCI
>         select IRQ_DOMAIN
>         select XILINX_INTC
> diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
> index 86a4ce07c192..8810f4f1c3b0 100644
> --- a/arch/microblaze/include/asm/page.h
> +++ b/arch/microblaze/include/asm/page.h
> @@ -20,7 +20,7 @@
>  #ifdef __KERNEL__
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT             12
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (ASM_CONST(1) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE-1))
>
> diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
> index 58d9565dc2c7..79d3039b29f1 100644
> --- a/arch/nios2/Kconfig
> +++ b/arch/nios2/Kconfig
> @@ -15,6 +15,7 @@ config NIOS2
>         select GENERIC_IRQ_SHOW
>         select HAVE_ARCH_TRACEHOOK
>         select HAVE_ARCH_KGDB
> +       select HAVE_PAGE_SIZE_4KB
>         select IRQ_DOMAIN
>         select LOCK_MM_AND_FIND_VMA
>         select MODULES_USE_ELF_RELA
> diff --git a/arch/nios2/include/asm/page.h b/arch/nios2/include/asm/page.h
> index 0ae7d9ce369b..0722f88e63cc 100644
> --- a/arch/nios2/include/asm/page.h
> +++ b/arch/nios2/include/asm/page.h
> @@ -21,7 +21,7 @@
>  /*
>   * PAGE_SHIFT determines the page size
>   */
> -#define PAGE_SHIFT     12
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE - 1))
>
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index fd9bb76a610b..3586cda55bde 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -25,6 +25,7 @@ config OPENRISC
>         select GENERIC_CPU_DEVICES
>         select HAVE_PCI
>         select HAVE_UID16
> +       select HAVE_PAGE_SIZE_8KB
>         select GENERIC_ATOMIC64
>         select GENERIC_CLOCKEVENTS_BROADCAST
>         select GENERIC_SMP_IDLE_THREAD
> diff --git a/arch/openrisc/include/asm/page.h b/arch/openrisc/include/asm/page.h
> index 44fc1fd56717..7925ce09ab5a 100644
> --- a/arch/openrisc/include/asm/page.h
> +++ b/arch/openrisc/include/asm/page.h
> @@ -18,7 +18,7 @@
>
>  /* PAGE_SHIFT determines the page size */
>
> -#define PAGE_SHIFT      13
> +#define PAGE_SHIFT      CONFIG_PAGE_SHIFT
>  #ifdef __ASSEMBLY__
>  #define PAGE_SIZE       (1 << PAGE_SHIFT)
>  #else
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index bffbd869a068..792a337548f6 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -136,6 +136,7 @@ config RISCV
>         select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD
>         select HAVE_MOVE_PMD
>         select HAVE_MOVE_PUD
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PCI
>         select HAVE_PERF_EVENTS
>         select HAVE_PERF_REGS
> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> index 57e887bfa34c..2947423b5082 100644
> --- a/arch/riscv/include/asm/page.h
> +++ b/arch/riscv/include/asm/page.h
> @@ -12,7 +12,7 @@
>  #include <linux/pfn.h>
>  #include <linux/const.h>
>
> -#define PAGE_SHIFT     (12)
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE - 1))
>
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index fe565f3a3a91..b61c74c10050 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -199,6 +199,7 @@ config S390
>         select HAVE_MOD_ARCH_SPECIFIC
>         select HAVE_NMI
>         select HAVE_NOP_MCOUNT
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PCI
>         select HAVE_PERF_EVENTS
>         select HAVE_PERF_REGS
> diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
> index 73b9c3bf377f..ded9548d11d9 100644
> --- a/arch/s390/include/asm/page.h
> +++ b/arch/s390/include/asm/page.h
> @@ -11,7 +11,7 @@
>  #include <linux/const.h>
>  #include <asm/types.h>
>
> -#define _PAGE_SHIFT    12
> +#define _PAGE_SHIFT    CONFIG_PAGE_SHIFT
>  #define _PAGE_SIZE     (_AC(1, UL) << _PAGE_SHIFT)
>  #define _PAGE_MASK     (~(_PAGE_SIZE - 1))
>
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index 204c43cb3d43..7e6bc6fff76b 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -58,6 +58,7 @@ config SPARC32
>         select DMA_DIRECT_REMAP
>         select GENERIC_ATOMIC64
>         select HAVE_UID16
> +       select HAVE_PAGE_SIZE_4KB
>         select LOCK_MM_AND_FIND_VMA
>         select OLD_SIGACTION
>         select ZONE_DMA
> @@ -75,6 +76,7 @@ config SPARC64
>         select HAVE_ARCH_TRANSPARENT_HUGEPAGE
>         select HAVE_DYNAMIC_FTRACE
>         select HAVE_FTRACE_MCOUNT_RECORD
> +       select HAVE_PAGE_SIZE_8KB
>         select HAVE_SYSCALL_TRACEPOINTS
>         select HAVE_CONTEXT_TRACKING_USER
>         select HAVE_TIF_NOHZ
> diff --git a/arch/sparc/include/asm/page_32.h b/arch/sparc/include/asm/page_32.h
> index 6be6f683f98f..9977c77374cd 100644
> --- a/arch/sparc/include/asm/page_32.h
> +++ b/arch/sparc/include/asm/page_32.h
> @@ -11,7 +11,7 @@
>
>  #include <linux/const.h>
>
> -#define PAGE_SHIFT   12
> +#define PAGE_SHIFT   CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE    (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK    (~(PAGE_SIZE-1))
>
> diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h
> index 254dffd85fb1..e9bd24821c93 100644
> --- a/arch/sparc/include/asm/page_64.h
> +++ b/arch/sparc/include/asm/page_64.h
> @@ -4,8 +4,7 @@
>
>  #include <linux/const.h>
>
> -#define PAGE_SHIFT   13
> -
> +#define PAGE_SHIFT   CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE    (_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK    (~(PAGE_SIZE-1))
>
> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
> index b5e179360534..93a5a8999b07 100644
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -20,6 +20,7 @@ config UML
>         select HAVE_UID16
>         select HAVE_DEBUG_KMEMLEAK
>         select HAVE_DEBUG_BUGVERBOSE
> +       select HAVE_PAGE_SIZE_4KB
>         select NO_DMA if !UML_DMA_EMULATION
>         select OF_EARLY_FLATTREE if OF
>         select GENERIC_IRQ_SHOW
> diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
> index 84866127d074..9ef9a8aedfa6 100644
> --- a/arch/um/include/asm/page.h
> +++ b/arch/um/include/asm/page.h
> @@ -10,7 +10,7 @@
>  #include <linux/const.h>
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT     12
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (_AC(1, UL) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE-1))
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 5edec175b9bf..ba57eb362ec8 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -255,6 +255,7 @@ config X86
>         select HAVE_NOINSTR_VALIDATION          if HAVE_OBJTOOL
>         select HAVE_OBJTOOL                     if X86_64
>         select HAVE_OPTPROBES
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PCSPKR_PLATFORM
>         select HAVE_PERF_EVENTS
>         select HAVE_PERF_EVENTS_NMI
> diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
> index 86bd4311daf8..9da9c8a2f1df 100644
> --- a/arch/x86/include/asm/page_types.h
> +++ b/arch/x86/include/asm/page_types.h
> @@ -7,7 +7,7 @@
>  #include <linux/mem_encrypt.h>
>
>  /* PAGE_SHIFT determines the page size */
> -#define PAGE_SHIFT             12
> +#define PAGE_SHIFT             CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE              (_AC(1,UL) << PAGE_SHIFT)
>  #define PAGE_MASK              (~(PAGE_SIZE-1))
>
> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
> index 6f248d87e496..87ec35b3363b 100644
> --- a/arch/xtensa/Kconfig
> +++ b/arch/xtensa/Kconfig
> @@ -44,6 +44,7 @@ config XTENSA
>         select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
>         select HAVE_HW_BREAKPOINT if PERF_EVENTS
>         select HAVE_IRQ_TIME_ACCOUNTING
> +       select HAVE_PAGE_SIZE_4KB
>         select HAVE_PCI
>         select HAVE_PERF_EVENTS
>         select HAVE_STACKPROTECTOR
> diff --git a/arch/xtensa/include/asm/page.h b/arch/xtensa/include/asm/page.h
> index a77d04972eb9..4db56ef052d2 100644
> --- a/arch/xtensa/include/asm/page.h
> +++ b/arch/xtensa/include/asm/page.h
> @@ -22,7 +22,7 @@
>   * PAGE_SHIFT determines the page size
>   */
>
> -#define PAGE_SHIFT     12
> +#define PAGE_SHIFT     CONFIG_PAGE_SHIFT
>  #define PAGE_SIZE      (__XTENSA_UL_CONST(1) << PAGE_SHIFT)
>  #define PAGE_MASK      (~(PAGE_SIZE-1))
>
> --
> 2.39.2
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
  2024-02-27  0:49   ` Guo Ren
@ 2024-02-27  7:41   ` Heiko Carstens
  2024-02-27  8:54   ` Geert Uytterhoeven
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 27+ messages in thread
From: Heiko Carstens @ 2024-02-27  7:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On Mon, Feb 26, 2024 at 05:14:13PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most architectures only support a single hardcoded page size. In order
> to ensure that each one of these sets the corresponding Kconfig symbols,
> change over the PAGE_SHIFT definition to the common one and allow
> only the hardware page size to be selected.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
...
>  arch/s390/Kconfig                  | 1 +
>  arch/s390/include/asm/page.h       | 2 +-
...
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index fe565f3a3a91..b61c74c10050 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -199,6 +199,7 @@ config S390
>  	select HAVE_MOD_ARCH_SPECIFIC
>  	select HAVE_NMI
>  	select HAVE_NOP_MCOUNT
> +	select HAVE_PAGE_SIZE_4KB
>  	select HAVE_PCI
>  	select HAVE_PERF_EVENTS
>  	select HAVE_PERF_REGS
> diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
> index 73b9c3bf377f..ded9548d11d9 100644
> --- a/arch/s390/include/asm/page.h
> +++ b/arch/s390/include/asm/page.h
> @@ -11,7 +11,7 @@
>  #include <linux/const.h>
>  #include <asm/types.h>
>  
> -#define _PAGE_SHIFT	12
> +#define _PAGE_SHIFT	CONFIG_PAGE_SHIFT

Acked-by: Heiko Carstens <hca@linux.ibm.com>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
  2024-02-26 16:55   ` Samuel Holland
  2024-02-26 19:02   ` Christophe Leroy
@ 2024-02-27  8:45   ` Geert Uytterhoeven
  2024-02-27 15:43     ` Arnd Bergmann
  2 siblings, 1 reply; 27+ messages in thread
From: Geert Uytterhoeven @ 2024-02-27  8:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Michal Simek, Thomas Bogendoerfer, Helge Deller,
	Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

Hi Arnd,

On Mon, Feb 26, 2024 at 5:14 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for your patch!

> --- a/arch/Kconfig
> +++ b/arch/Kconfig

> +config PAGE_SIZE_4KB
> +       bool "4KB pages"

Now you got rid of the 4000-byte ("4kB") pages and friends, please
do not replace these by Kelvin-bytes, and use the official binary
prefixes => "4 KiB".

> +       depends on HAVE_PAGE_SIZE_4KB

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
  2024-02-27  0:49   ` Guo Ren
  2024-02-27  7:41   ` Heiko Carstens
@ 2024-02-27  8:54   ` Geert Uytterhoeven
  2024-02-27 10:59     ` Arnd Bergmann
  2024-02-28 21:06   ` Stafford Horne
  2024-03-05 10:59   ` Johannes Berg
  4 siblings, 1 reply; 27+ messages in thread
From: Geert Uytterhoeven @ 2024-02-27  8:54 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Michal Simek, Thomas Bogendoerfer, Helge Deller,
	Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

Hi Arnd,

On Mon, Feb 26, 2024 at 5:15 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures only support a single hardcoded page size. In order
> to ensure that each one of these sets the corresponding Kconfig symbols,
> change over the PAGE_SHIFT definition to the common one and allow
> only the hardware page size to be selected.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for your patch!

> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -84,12 +84,15 @@ config MMU
>
>  config MMU_MOTOROLA
>         bool
> +       select HAVE_PAGE_SIZE_4KB
>
>  config MMU_COLDFIRE
> +       select HAVE_PAGE_SIZE_8KB

I think you can do without this...

>         bool
>
>  config MMU_SUN3
>         bool
> +       select HAVE_PAGE_SIZE_8KB
>         depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
>
>  config ARCH_SUPPORTS_KEXEC
> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> index 9dcf245c9cbf..c777a129768a 100644
> --- a/arch/m68k/Kconfig.cpu
> +++ b/arch/m68k/Kconfig.cpu
> @@ -30,6 +30,7 @@ config COLDFIRE
>         select GENERIC_CSUM
>         select GPIOLIB
>         select HAVE_LEGACY_CLK
> +       select HAVE_PAGE_SIZE_8KB if !MMU

.... if you would drop the !MMU-dependency here.

>
>  endchoice
>
> @@ -45,6 +46,7 @@ config M68000
>         select GENERIC_CSUM
>         select CPU_NO_EFFICIENT_FFS
>         select HAVE_ARCH_HASH
> +       select HAVE_PAGE_SIZE_4KB

Perhaps replace this by

    config M68KCLASSIC
            bool "Classic M68K CPU family support"
            select HAVE_ARCH_PFN_VALID
  +         select HAVE_PAGE_SIZE_4KB if !MMU

so it covers all 680x0 CPUs without MMU?

>         select LEGACY_TIMER_TICK
>         help
>           The Freescale (was Motorola) 68000 CPU is the first generation of

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-27  8:54   ` Geert Uytterhoeven
@ 2024-02-27 10:59     ` Arnd Bergmann
  2024-02-27 11:12       ` Geert Uytterhoeven
  0 siblings, 1 reply; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-27 10:59 UTC (permalink / raw)
  To: Geert Uytterhoeven, Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Gleixner, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, guoren, Brian Cain, Huacai Chen, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Christophe Leroy, Palmer Dabbelt, John Paul Adrian Glaubitz,
	Andreas Larsson, Richard Weinberger, x86, Max Filippov,
	Andy Lutomirski, Jan Kiszka, Kieran Bingham, Andrew Morton,
	linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
	linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
	linux-openrisc, linux-parisc, linuxppc-dev, linux-riscv,
	linux-s390, linux-sh, sparclinux, linux-um

On Tue, Feb 27, 2024, at 09:54, Geert Uytterhoeven wrote:
> Hi Arnd,
>> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
>> index 9dcf245c9cbf..c777a129768a 100644
>> --- a/arch/m68k/Kconfig.cpu
>> +++ b/arch/m68k/Kconfig.cpu
>> @@ -30,6 +30,7 @@ config COLDFIRE
>>         select GENERIC_CSUM
>>         select GPIOLIB
>>         select HAVE_LEGACY_CLK
>> +       select HAVE_PAGE_SIZE_8KB if !MMU
>
> .... if you would drop the !MMU-dependency here.
>
>>
>>  endchoice
>>
>> @@ -45,6 +46,7 @@ config M68000
>>         select GENERIC_CSUM
>>         select CPU_NO_EFFICIENT_FFS
>>         select HAVE_ARCH_HASH
>> +       select HAVE_PAGE_SIZE_4KB
>
> Perhaps replace this by
>
>     config M68KCLASSIC
>             bool "Classic M68K CPU family support"
>             select HAVE_ARCH_PFN_VALID
>   +         select HAVE_PAGE_SIZE_4KB if !MMU
>
> so it covers all 680x0 CPUs without MMU?

I was a bit unsure about how to best do this since there
is not really a need for a fixed page size on nommu kernels,
whereas the three MMU configs clearly tie the page size to
the MMU rather than the platform.

There should be no reason for coldfire to have a different
page size from dragonball if neither of them actually uses
hardware pages, so one of them could be changed later.

Let me know if that makes sense to you, or you still
prefer me to change it like you suggested.

      Arnd

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-27 10:59     ` Arnd Bergmann
@ 2024-02-27 11:12       ` Geert Uytterhoeven
  2024-02-27 14:18         ` Arnd Bergmann
  0 siblings, 1 reply; 27+ messages in thread
From: Geert Uytterhoeven @ 2024-02-27 11:12 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Gleixner, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, guoren, Brian Cain, Huacai Chen, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Christophe Leroy, Palmer Dabbelt, John Paul Adrian Glaubitz,
	Andreas Larsson, Richard Weinberger, x86, Max Filippov,
	Andy Lutomirski, Jan Kiszka, Kieran Bingham, Andrew Morton,
	linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
	linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
	linux-openrisc, linux-parisc, linuxppc-dev, linux-riscv,
	linux-s390, linux-sh, sparclinux, linux-um, Greg Ungerer

Hi Arnd,

CC Greg

On Tue, Feb 27, 2024 at 11:59 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Tue, Feb 27, 2024, at 09:54, Geert Uytterhoeven wrote:
> >> diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
> >> index 9dcf245c9cbf..c777a129768a 100644
> >> --- a/arch/m68k/Kconfig.cpu
> >> +++ b/arch/m68k/Kconfig.cpu
> >> @@ -30,6 +30,7 @@ config COLDFIRE
> >>         select GENERIC_CSUM
> >>         select GPIOLIB
> >>         select HAVE_LEGACY_CLK
> >> +       select HAVE_PAGE_SIZE_8KB if !MMU
> >
> > .... if you would drop the !MMU-dependency here.
> >
> >>
> >>  endchoice
> >>
> >> @@ -45,6 +46,7 @@ config M68000
> >>         select GENERIC_CSUM
> >>         select CPU_NO_EFFICIENT_FFS
> >>         select HAVE_ARCH_HASH
> >> +       select HAVE_PAGE_SIZE_4KB
> >
> > Perhaps replace this by
> >
> >     config M68KCLASSIC
> >             bool "Classic M68K CPU family support"
> >             select HAVE_ARCH_PFN_VALID
> >   +         select HAVE_PAGE_SIZE_4KB if !MMU
> >
> > so it covers all 680x0 CPUs without MMU?
>
> I was a bit unsure about how to best do this since there
> is not really a need for a fixed page size on nommu kernels,
> whereas the three MMU configs clearly tie the page size to
> the MMU rather than the platform.
>
> There should be no reason for coldfire to have a different
> page size from dragonball if neither of them actually uses
> hardware pages, so one of them could be changed later.

Indeed, in theory, PAGE_SIZE doesn't matter for nommu, but the concept
of pages is used all over the place in Linux.

I'm mostly worried about some Coldfire code relying on the actual value
of PAGE_SIZE in some other context. e.g. for configuring non-cacheable
regions.

And does this impact running nommu binaries on a system with MMU?
I.e. if nommu binaries were built with a 4 KiB PAGE_SIZE, do they
still run on MMU systems with an 8 KiB PAGE_SIZE (coldfire and sun3),
or are there some subtleties to take into account?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] vdso: avoid including asm/page.h
  2024-02-26 18:53   ` Christophe Leroy
@ 2024-02-27 12:57     ` Michael Ellerman
  0 siblings, 0 replies; 27+ messages in thread
From: Michael Ellerman @ 2024-02-27 12:57 UTC (permalink / raw)
  To: Christophe Leroy, Arnd Bergmann, Thomas Gleixner,
	Vincenzo Frascino, Kees Cook, Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Palmer Dabbelt, John Paul Adrian Glaubitz,
	Andreas Larsson, Richard Weinberger, x86, Max Filippov,
	Andy Lutomirski, Jan Kiszka, Kieran Bingham, Andrew Morton,
	linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
	linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
	linux-openrisc, linux-parisc, linuxppc-dev, linux-riscv,
	linux-s390, linux-sh, sparclinux, linux-um,
	Linux Kernel Functional Testing

Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 26/02/2024 à 17:14, Arnd Bergmann a écrit :
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> The recent change to the vdso_data_store broke building compat VDSO
>> on at least arm64 because it includes headers outside of the include/vdso/
>> namespace:
>
> I understand that powerpc64 also has an issue, see 
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20231221120410.2226678-1-mpe@ellerman.id.au/

Yeah, and that patch would silently conflict with this series, which is
not ideal.

I could delay merging my patch above until after this series goes in,
mine only fixes a fairly obscure build warning.

cheers

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/4] arch: simplify architecture specific page size configuration
  2024-02-26 16:14 ` [PATCH 2/4] arch: simplify architecture specific page size configuration Arnd Bergmann
  2024-02-26 19:05   ` Christophe Leroy
@ 2024-02-27 13:46   ` Catalin Marinas
  2024-02-27 13:53   ` Helge Deller
  2 siblings, 0 replies; 27+ messages in thread
From: Catalin Marinas @ 2024-02-27 13:46 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On Mon, Feb 26, 2024 at 05:14:12PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> arc, arm64, parisc and powerpc all have their own Kconfig symbols
> in place of the common CONFIG_PAGE_SIZE_4KB symbols. Change these
> so the common symbols are the ones that are actually used, while
> leaving the arhcitecture specific ones as the user visible
> place for configuring it, to avoid breaking user configs.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

For arm64:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/4] vdso: avoid including asm/page.h
  2024-02-26 16:14 ` [PATCH 4/4] vdso: avoid including asm/page.h Arnd Bergmann
  2024-02-26 18:53   ` Christophe Leroy
@ 2024-02-27 13:46   ` Catalin Marinas
  1 sibling, 0 replies; 27+ messages in thread
From: Catalin Marinas @ 2024-02-27 13:46 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um, Linux Kernel Functional Testing

On Mon, Feb 26, 2024 at 05:14:14PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The recent change to the vdso_data_store broke building compat VDSO
> on at least arm64 because it includes headers outside of the include/vdso/
> namespace:
> 
> In file included from arch/arm64/include/asm/lse.h:5,
>                  from arch/arm64/include/asm/cmpxchg.h:14,
>                  from arch/arm64/include/asm/atomic.h:16,
>                  from include/linux/atomic.h:7,
>                  from include/asm-generic/bitops/atomic.h:5,
>                  from arch/arm64/include/asm/bitops.h:25,
>                  from include/linux/bitops.h:68,
>                  from arch/arm64/include/asm/memory.h:209,
>                  from arch/arm64/include/asm/page.h:46,
>                  from include/vdso/datapage.h:22,
>                  from lib/vdso/gettimeofday.c:5,
>                  from <command-line>:
> arch/arm64/include/asm/atomic_ll_sc.h:298:9: error: unknown type name 'u128'
>   298 |         u128 full;
> 
> Use an open-coded page size calculation based on the new CONFIG_PAGE_SHIFT
> Kconfig symbol instead.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Fixes: a0d2fcd62ac2 ("vdso/ARM: Make union vdso_data_store available for all architectures")
> Link: https://lore.kernel.org/lkml/CA+G9fYtrXXm_KO9fNPz3XaRxHV7UD_yQp-TEuPQrNRHU+_0W_Q@mail.gmail.com/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/4] arch: simplify architecture specific page size configuration
  2024-02-26 16:14 ` [PATCH 2/4] arch: simplify architecture specific page size configuration Arnd Bergmann
  2024-02-26 19:05   ` Christophe Leroy
  2024-02-27 13:46   ` Catalin Marinas
@ 2024-02-27 13:53   ` Helge Deller
  2 siblings, 0 replies; 27+ messages in thread
From: Helge Deller @ 2024-02-27 13:53 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On 2/26/24 17:14, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> arc, arm64, parisc and powerpc all have their own Kconfig symbols
> in place of the common CONFIG_PAGE_SIZE_4KB symbols. Change these
> so the common symbols are the ones that are actually used, while
> leaving the arhcitecture specific ones as the user visible
> place for configuring it, to avoid breaking user configs.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   arch/arc/Kconfig                  |  3 +++
>   arch/arc/include/uapi/asm/page.h  |  6 ++----
>   arch/arm64/Kconfig                | 29 +++++++++++++----------------
>   arch/arm64/include/asm/page-def.h |  2 +-
>   arch/parisc/Kconfig               |  3 +++
>   arch/parisc/include/asm/page.h    | 10 +---------

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks for the cleanups!

Helge


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-27 11:12       ` Geert Uytterhoeven
@ 2024-02-27 14:18         ` Arnd Bergmann
  0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-27 14:18 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Gleixner, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, guoren, Brian Cain, Huacai Chen, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Christophe Leroy, Palmer Dabbelt, John Paul Adrian Glaubitz,
	Andreas Larsson, Richard Weinberger, x86, Max Filippov,
	Andy Lutomirski, Jan Kiszka, Kieran Bingham, Andrew Morton,
	linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
	linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
	linux-openrisc, linux-parisc, linuxppc-dev, linux-riscv,
	linux-s390, linux-sh, sparclinux, linux-um, Greg Ungerer

On Tue, Feb 27, 2024, at 12:12, Geert Uytterhoeven wrote:
> On Tue, Feb 27, 2024 at 11:59 AM Arnd Bergmann <arnd@arndb.de> wrote:
>> On Tue, Feb 27, 2024, at 09:54, Geert Uytterhoeven wrote:
>> I was a bit unsure about how to best do this since there
>> is not really a need for a fixed page size on nommu kernels,
>> whereas the three MMU configs clearly tie the page size to
>> the MMU rather than the platform.
>>
>> There should be no reason for coldfire to have a different
>> page size from dragonball if neither of them actually uses
>> hardware pages, so one of them could be changed later.
>
> Indeed, in theory, PAGE_SIZE doesn't matter for nommu, but the concept
> of pages is used all over the place in Linux.
>
> I'm mostly worried about some Coldfire code relying on the actual value
> of PAGE_SIZE in some other context. e.g. for configuring non-cacheable
> regions.

Right, any change here would have to be carefully tested. I would
expect that a 4K page size would reduce memory consumption even on
NOMMU systems that should have the same tradeoffs for representing
files in the page cache and in mem_map[].

> And does this impact running nommu binaries on a system with MMU?
> I.e. if nommu binaries were built with a 4 KiB PAGE_SIZE, do they
> still run on MMU systems with an 8 KiB PAGE_SIZE (coldfire and sun3),
> or are there some subtleties to take into account?

As far as I understand, binaries have to be built and linked for
the largest page size they can run on, so running them on a kernel
with smaller page size usually works.

One notable exception is sys_mmap2(), which on most architectures
takes units of 4KiB but on m68k is actually written to take
PAGE_SIZE units. As Al pointed out in f8b7256096a2 ("Unify
sys_mmap*"), it has always been wrong on sun3, presumably
because users of that predate modern glibc. Running coldfire
nommu binaries on coldfire mmu kernels would run into the same
bug if either of them changes PAGE_SIZE. If you can run
coldfire nommu binaries on classic m68k, that is already
broken in the same way.

      Arnd

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-26 16:55   ` Samuel Holland
@ 2024-02-27 15:40     ` Arnd Bergmann
  2024-02-27 15:44       ` Christophe Leroy
  0 siblings, 1 reply; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-27 15:40 UTC (permalink / raw)
  To: Samuel Holland, Arnd Bergmann, Thomas Gleixner,
	Vincenzo Frascino, Kees Cook, Anna-Maria Gleixner
  Cc: Matt Turner, Vineet Gupta, Russell King, Catalin Marinas, guoren,
	Brian Cain, Huacai Chen, Geert Uytterhoeven, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Christophe Leroy, Palmer Dabbelt, John Paul Adrian Glaubitz,
	Andreas Larsson, Richard Weinberger, x86, Max Filippov,
	Andy Lutomirski, Jan Kiszka, Kieran Bingham, Andrew Morton,
	linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
	linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
	linux-openrisc, linux-parisc, linuxppc-dev, linux-riscv,
	linux-s390, linux-sh, sparclinux, linux-um

On Mon, Feb 26, 2024, at 17:55, Samuel Holland wrote:
> On 2024-02-26 10:14 AM, Arnd Bergmann wrote:
>>  
>> +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"
>
> Should this have some generic help text (at least a warning about 
> compatibility)?

Good point. I've added some of this now, based on the mips
text with some generalizations for other architectures:

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
          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
          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
          256KB pages have little practical value due to their extreme
          memory usage.

>> diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
>> index a880ee067d2e..aac46ee1a000 100644
>> --- a/arch/hexagon/Kconfig
>> +++ b/arch/hexagon/Kconfig
>> @@ -8,6 +8,11 @@ config HEXAGON
>>  	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
>>  	select ARCH_NO_PREEMPT
>>  	select DMA_GLOBAL_POOL
>> +	select FRAME_POINTER
>
> Looks like a paste error.
>

Fixed, thanks! I think that happened during a rebase.

>>  #ifdef CONFIG_PAGE_SIZE_1MB
>> -#define PAGE_SHIFT 20
>>  #define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_1MB
>>  #endif
>
> The corresponding Kconfig option does not exist (and did not exist before this
> patch).

Yes, I noticed that as well. It's clearly harmless.

     Arnd

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-26 19:02   ` Christophe Leroy
@ 2024-02-27 15:42     ` Arnd Bergmann
  0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-27 15:42 UTC (permalink / raw)
  To: Christophe Leroy, Arnd Bergmann, Thomas Gleixner,
	Vincenzo Frascino, Kees Cook, Anna-Maria Gleixner
  Cc: Matt Turner, Vineet Gupta, Russell King, Catalin Marinas, guoren,
	Brian Cain, Huacai Chen, Geert Uytterhoeven, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Palmer Dabbelt, John Paul Adrian Glaubitz, Andreas Larsson,
	Richard Weinberger, x86, Max Filippov, Andy Lutomirski,
	Jan Kiszka, Kieran Bingham, Andrew Morton, linux-kernel,
	linux-alpha, linux-snps-arc, linux-arm-kernel, linux-csky,
	linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um

On Mon, Feb 26, 2024, at 20:02, Christophe Leroy wrote:
> Le 26/02/2024 à 17:14, Arnd Bergmann a écrit :
>> From: Arnd Bergmann <arnd@arndb.de>
>
> That's a nice re-factor.
>
> The only drawback I see is that we are loosing several interesting 
> arch-specific comments/help text. Don't know if there could be an easy 
> way to keep them.

This is what I have now, trying to write it as generic as
possible while still giving useful advice:

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
          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
          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
          256KB pages have little practical value due to their extreme
          memory usage.

Let me know if you think some of this should be adapted further.

>>   
>> +#define PAGE_SHIFT CONFIG_PAGE_SHIFT
>>   #define PAGE_SIZE  (1UL << PAGE_SHIFT)
>>   #define PAGE_MASK  (~((1 << PAGE_SHIFT) - 1))
>>   
>
> Could we move PAGE_SIZE and PAGE_MASK in a generic/core header instead 
> of having it duplicated for each arch ?

Yes, but I'm leaving this for a follow-up series, since I had
to stop somewhere and there is always room for cleanup up headers
further ;-)

      Arnd

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-27  8:45   ` Geert Uytterhoeven
@ 2024-02-27 15:43     ` Arnd Bergmann
  0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-27 15:43 UTC (permalink / raw)
  To: Geert Uytterhoeven, Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Gleixner, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, guoren, Brian Cain, Huacai Chen, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Christophe Leroy, Palmer Dabbelt, John Paul Adrian Glaubitz,
	Andreas Larsson, Richard Weinberger, x86, Max Filippov,
	Andy Lutomirski, Jan Kiszka, Kieran Bingham, Andrew Morton,
	linux-kernel, linux-alpha, linux-snps-arc, linux-arm-kernel,
	linux-csky, linux-hexagon, loongarch, linux-m68k, linux-mips,
	linux-openrisc, linux-parisc, linuxppc-dev, linux-riscv,
	linux-s390, linux-sh, sparclinux, linux-um

On Tue, Feb 27, 2024, at 09:45, Geert Uytterhoeven wrote:
>
>> +config PAGE_SIZE_4KB
>> +       bool "4KB pages"
>
> Now you got rid of the 4000-byte ("4kB") pages and friends, please
> do not replace these by Kelvin-bytes, and use the official binary
> prefixes => "4 KiB".
>

Done, thanks.

    Arnd

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-27 15:40     ` Arnd Bergmann
@ 2024-02-27 15:44       ` Christophe Leroy
  2024-02-27 15:48         ` Arnd Bergmann
  0 siblings, 1 reply; 27+ messages in thread
From: Christophe Leroy @ 2024-02-27 15:44 UTC (permalink / raw)
  To: Arnd Bergmann, Samuel Holland, Arnd Bergmann, Thomas Gleixner,
	Vincenzo Frascino, Kees Cook, Anna-Maria Gleixner
  Cc: Matt Turner, Vineet Gupta, Russell King, Catalin Marinas, guoren,
	Brian Cain, Huacai Chen, Geert Uytterhoeven, Michal Simek,
	Thomas Bogendoerfer, Helge Deller, Michael Ellerman,
	Palmer Dabbelt, John Paul Adrian Glaubitz, Andreas Larsson,
	Richard Weinberger, x86, Max Filippov, Andy Lutomirski,
	Jan Kiszka, Kieran Bingham, Andrew Morton, linux-kernel,
	linux-alpha, linux-snps-arc, linux-arm-kernel, linux-csky,
	linux-hexagon, loongarch, linux-m68k, linux-mips, linux-openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um



Le 27/02/2024 à 16:40, Arnd Bergmann a écrit :
> On Mon, Feb 26, 2024, at 17:55, Samuel Holland wrote:
>> On 2024-02-26 10:14 AM, Arnd Bergmann wrote:
>>>   
>>> +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"
>>
>> Should this have some generic help text (at least a warning about
>> compatibility)?
> 
> Good point. I've added some of this now, based on the mips
> text with some generalizations for other architectures:
> 
> 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
>            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
>            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
>            256KB pages have little practical value due to their extreme
>            memory usage.


For 256K pages, powerpc has the following help. I think you should have 
it too:

	  The kernel will only be able to run applications that have been
	  compiled with '-zmax-page-size' set to 256K (the default is 64K) using
	  binutils later than 2.17.50.0.3, or by patching the ELF_MAXPAGESIZE
	  definition from 0x10000 to 0x40000 in older versions.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions
  2024-02-27 15:44       ` Christophe Leroy
@ 2024-02-27 15:48         ` Arnd Bergmann
  0 siblings, 0 replies; 27+ messages in thread
From: Arnd Bergmann @ 2024-02-27 15:48 UTC (permalink / raw)
  To: Christophe Leroy, Samuel Holland, Arnd Bergmann, Thomas Gleixner,
	Vincenzo Frascino, Kees Cook, Anna-Maria Gleixner
  Cc: x86, loongarch, Andreas Larsson, Catalin Marinas, linux-mips,
	Max Filippov, guoren, sparclinux, linux-hexagon, linux-riscv,
	Jan Kiszka, linux-s390, linux-sh, Richard Weinberger,
	Helge Deller, Huacai Chen, Russell King, linux-csky,
	Geert Uytterhoeven, Vineet Gupta, Matt Turner, linux-snps-arc,
	linux-alpha, Kieran Bingham, linux-um, linux-m68k,
	Andy Lutomirski, John Paul Adrian Glaubitz, linux-arm-kernel,
	Brian Cain, Michal Simek, Thomas Bogendoerfer, linux-parisc,
	linux-openrisc, linux-kernel, Palmer Dabbelt, Andrew Morton,
	linuxppc-dev

On Tue, Feb 27, 2024, at 16:44, Christophe Leroy wrote:
> Le 27/02/2024 à 16:40, Arnd Bergmann a écrit :
>> On Mon, Feb 26, 2024, at 17:55, Samuel Holland wrote:
>
>
> For 256K pages, powerpc has the following help. I think you should have 
> it too:
>
> 	  The kernel will only be able to run applications that have been
> 	  compiled with '-zmax-page-size' set to 256K (the default is 64K) using
> 	  binutils later than 2.17.50.0.3, or by patching the ELF_MAXPAGESIZE
> 	  definition from 0x10000 to 0x40000 in older versions.

I don't think we need to mention pre-2.18 binutils any more, but the
rest seems useful, changed the text now to

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).

      Arnd

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
                     ` (2 preceding siblings ...)
  2024-02-27  8:54   ` Geert Uytterhoeven
@ 2024-02-28 21:06   ` Stafford Horne
  2024-03-05 10:59   ` Johannes Berg
  4 siblings, 0 replies; 27+ messages in thread
From: Stafford Horne @ 2024-02-28 21:06 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen, Arnd Bergmann, Matt Turner, Vineet Gupta,
	Russell King, Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On Mon, Feb 26, 2024 at 05:14:13PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most architectures only support a single hardcoded page size. In order
> to ensure that each one of these sets the corresponding Kconfig symbols,
> change over the PAGE_SHIFT definition to the common one and allow
> only the hardware page size to be selected.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/alpha/Kconfig                 | 1 +
>  arch/alpha/include/asm/page.h      | 2 +-
>  arch/arm/Kconfig                   | 1 +
>  arch/arm/include/asm/page.h        | 2 +-
>  arch/csky/Kconfig                  | 1 +
>  arch/csky/include/asm/page.h       | 2 +-
>  arch/m68k/Kconfig                  | 3 +++
>  arch/m68k/Kconfig.cpu              | 2 ++
>  arch/m68k/include/asm/page.h       | 6 +-----
>  arch/microblaze/Kconfig            | 1 +
>  arch/microblaze/include/asm/page.h | 2 +-
>  arch/nios2/Kconfig                 | 1 +
>  arch/nios2/include/asm/page.h      | 2 +-
>  arch/openrisc/Kconfig              | 1 +
>  arch/openrisc/include/asm/page.h   | 2 +-
>  arch/riscv/Kconfig                 | 1 +
>  arch/riscv/include/asm/page.h      | 2 +-
>  arch/s390/Kconfig                  | 1 +
>  arch/s390/include/asm/page.h       | 2 +-
>  arch/sparc/Kconfig                 | 2 ++
>  arch/sparc/include/asm/page_32.h   | 2 +-
>  arch/sparc/include/asm/page_64.h   | 3 +--
>  arch/um/Kconfig                    | 1 +
>  arch/um/include/asm/page.h         | 2 +-
>  arch/x86/Kconfig                   | 1 +
>  arch/x86/include/asm/page_types.h  | 2 +-
>  arch/xtensa/Kconfig                | 1 +
>  arch/xtensa/include/asm/page.h     | 2 +-
>  28 files changed, 32 insertions(+), 19 deletions(-)
....
> diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
> index fd9bb76a610b..3586cda55bde 100644
> --- a/arch/openrisc/Kconfig
> +++ b/arch/openrisc/Kconfig
> @@ -25,6 +25,7 @@ config OPENRISC
>  	select GENERIC_CPU_DEVICES
>  	select HAVE_PCI
>  	select HAVE_UID16
> +	select HAVE_PAGE_SIZE_8KB
>  	select GENERIC_ATOMIC64
>  	select GENERIC_CLOCKEVENTS_BROADCAST
>  	select GENERIC_SMP_IDLE_THREAD
> diff --git a/arch/openrisc/include/asm/page.h b/arch/openrisc/include/asm/page.h
> index 44fc1fd56717..7925ce09ab5a 100644
> --- a/arch/openrisc/include/asm/page.h
> +++ b/arch/openrisc/include/asm/page.h
> @@ -18,7 +18,7 @@
>  
>  /* PAGE_SHIFT determines the page size */
>  
> -#define PAGE_SHIFT      13
> +#define PAGE_SHIFT      CONFIG_PAGE_SHIFT
>  #ifdef __ASSEMBLY__
>  #define PAGE_SIZE       (1 << PAGE_SHIFT)
>  #else

For the openrisc bits,

Acked-by: Stafford Horne <shorne@gmail.com>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures
  2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
                     ` (3 preceding siblings ...)
  2024-02-28 21:06   ` Stafford Horne
@ 2024-03-05 10:59   ` Johannes Berg
  4 siblings, 0 replies; 27+ messages in thread
From: Johannes Berg @ 2024-03-05 10:59 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Vincenzo Frascino, Kees Cook,
	Anna-Maria Behnsen
  Cc: Arnd Bergmann, Matt Turner, Vineet Gupta, Russell King,
	Catalin Marinas, Guo Ren, Brian Cain, Huacai Chen,
	Geert Uytterhoeven, Michal Simek, Thomas Bogendoerfer,
	Helge Deller, Michael Ellerman, Christophe Leroy, Palmer Dabbelt,
	John Paul Adrian Glaubitz, Andreas Larsson, Richard Weinberger,
	x86, Max Filippov, Andy Lutomirski, Jan Kiszka, Kieran Bingham,
	Andrew Morton, linux-kernel, linux-alpha, linux-snps-arc,
	linux-arm-kernel, linux-csky, linux-hexagon, loongarch,
	linux-m68k, linux-mips, linux-openrisc, linux-parisc,
	linuxppc-dev, linux-riscv, linux-s390, linux-sh, sparclinux,
	linux-um

On Mon, 2024-02-26 at 17:14 +0100, Arnd Bergmann wrote:
> 
>  arch/um/Kconfig                    | 1 +
>  arch/um/include/asm/page.h         | 2 +-


LGTM, thanks.

Acked-by: Johannes Berg <johannes@sipsolutions.net>

johannes

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2024-03-05 10:59 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-26 16:14 [PATCH 0/4] arch: mm, vdso: consolidate PAGE_SIZE definition Arnd Bergmann
2024-02-26 16:14 ` [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions Arnd Bergmann
2024-02-26 16:55   ` Samuel Holland
2024-02-27 15:40     ` Arnd Bergmann
2024-02-27 15:44       ` Christophe Leroy
2024-02-27 15:48         ` Arnd Bergmann
2024-02-26 19:02   ` Christophe Leroy
2024-02-27 15:42     ` Arnd Bergmann
2024-02-27  8:45   ` Geert Uytterhoeven
2024-02-27 15:43     ` Arnd Bergmann
2024-02-26 16:14 ` [PATCH 2/4] arch: simplify architecture specific page size configuration Arnd Bergmann
2024-02-26 19:05   ` Christophe Leroy
2024-02-27 13:46   ` Catalin Marinas
2024-02-27 13:53   ` Helge Deller
2024-02-26 16:14 ` [PATCH 3/4] arch: define CONFIG_PAGE_SIZE_*KB on all architectures Arnd Bergmann
2024-02-27  0:49   ` Guo Ren
2024-02-27  7:41   ` Heiko Carstens
2024-02-27  8:54   ` Geert Uytterhoeven
2024-02-27 10:59     ` Arnd Bergmann
2024-02-27 11:12       ` Geert Uytterhoeven
2024-02-27 14:18         ` Arnd Bergmann
2024-02-28 21:06   ` Stafford Horne
2024-03-05 10:59   ` Johannes Berg
2024-02-26 16:14 ` [PATCH 4/4] vdso: avoid including asm/page.h Arnd Bergmann
2024-02-26 18:53   ` Christophe Leroy
2024-02-27 12:57     ` Michael Ellerman
2024-02-27 13:46   ` Catalin Marinas

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).