[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9aae81d0-dfaf-423c-8ceb-72829a98420d@csgroup.eu>
Date: Mon, 26 Feb 2024 19:02:29 +0000
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Arnd Bergmann <arnd@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Vincenzo Frascino <vincenzo.frascino@....com>, Kees Cook
<keescook@...omium.org>, Anna-Maria Behnsen <anna-maria@...utronix.de>
CC: Arnd Bergmann <arnd@...db.de>, Matt Turner <mattst88@...il.com>, Vineet
Gupta <vgupta@...nel.org>, Russell King <linux@...linux.org.uk>, Catalin
Marinas <catalin.marinas@....com>, Guo Ren <guoren@...nel.org>, Brian Cain
<bcain@...cinc.com>, Huacai Chen <chenhuacai@...nel.org>, Geert Uytterhoeven
<geert@...ux-m68k.org>, Michal Simek <monstr@...str.eu>, Thomas Bogendoerfer
<tsbogend@...ha.franken.de>, Helge Deller <deller@....de>, Michael Ellerman
<mpe@...erman.id.au>, Palmer Dabbelt <palmer@...belt.com>, John Paul Adrian
Glaubitz <glaubitz@...sik.fu-berlin.de>, Andreas Larsson
<andreas@...sler.com>, Richard Weinberger <richard@....at>, "x86@...nel.org"
<x86@...nel.org>, Max Filippov <jcmvbkbc@...il.com>, Andy Lutomirski
<luto@...nel.org>, Jan Kiszka <jan.kiszka@...mens.com>, Kieran Bingham
<kbingham@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-alpha@...r.kernel.org" <linux-alpha@...r.kernel.org>,
"linux-snps-arc@...ts.infradead.org" <linux-snps-arc@...ts.infradead.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-csky@...r.kernel.org"
<linux-csky@...r.kernel.org>, "linux-hexagon@...r.kernel.org"
<linux-hexagon@...r.kernel.org>, "loongarch@...ts.linux.dev"
<loongarch@...ts.linux.dev>, "linux-m68k@...ts.linux-m68k.org"
<linux-m68k@...ts.linux-m68k.org>, "linux-mips@...r.kernel.org"
<linux-mips@...r.kernel.org>, "linux-openrisc@...r.kernel.org"
<linux-openrisc@...r.kernel.org>, "linux-parisc@...r.kernel.org"
<linux-parisc@...r.kernel.org>, "linuxppc-dev@...ts.ozlabs.org"
<linuxppc-dev@...ts.ozlabs.org>, "linux-riscv@...ts.infradead.org"
<linux-riscv@...ts.infradead.org>, "linux-s390@...r.kernel.org"
<linux-s390@...r.kernel.org>, "linux-sh@...r.kernel.org"
<linux-sh@...r.kernel.org>, "sparclinux@...r.kernel.org"
<sparclinux@...r.kernel.org>, "linux-um@...ts.infradead.org"
<linux-um@...ts.infradead.org>
Subject: Re: [PATCH 1/4] arch: consolidate existing CONFIG_PAGE_SIZE_*KB
definitions
Le 26/02/2024 à 17:14, Arnd Bergmann a écrit :
> From: Arnd Bergmann <arnd@...db.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@...db.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
Powered by blists - more mailing lists