Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: don't special case !MMU for is_zero_pfn() and my_zero_pfn()

Patch series "arch, mm: consolidate empty_zero_page", v3.

These patches cleanup handling of ZERO_PAGE() and zero_pfn.


This patch (of 4):

nommu architectures have empty_zero_page and define ZERO_PAGE() and
although they don't really use it to populate page tables, there is no
reason to hardwire !MMU implementation of is_zero_pfn() and my_zero_pfn()
to 0.

Drop #ifdef CONFIG_MMU around implementations of is_zero_pfn() and
my_zero_pfn() and remove !MMU version.

While on it, make zero_pfn __ro_after_init.

Link: https://lkml.kernel.org/r/20260211103141.3215197-1-rppt@kernel.org
Link: https://lkml.kernel.org/r/20260211103141.3215197-2-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Magnus Lindholm <linmag7@gmail.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Cc: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mike Rapoport (Microsoft) and committed by
Andrew Morton
652d12bc 7498bdda

+11 -26
+1 -13
include/linux/pgtable.h
··· 1917 1917 pfnmap_setup_cachemode(pfn, PAGE_SIZE, prot); 1918 1918 } 1919 1919 1920 - #ifdef CONFIG_MMU 1921 1920 #ifdef __HAVE_COLOR_ZERO_PAGE 1922 1921 static inline int is_zero_pfn(unsigned long pfn) 1923 1922 { ··· 1939 1940 extern unsigned long zero_pfn; 1940 1941 return zero_pfn; 1941 1942 } 1942 - #endif 1943 - #else 1944 - static inline int is_zero_pfn(unsigned long pfn) 1945 - { 1946 - return 0; 1947 - } 1948 - 1949 - static inline unsigned long my_zero_pfn(unsigned long addr) 1950 - { 1951 - return 0; 1952 - } 1953 - #endif /* CONFIG_MMU */ 1943 + #endif /* __HAVE_COLOR_ZERO_PAGE */ 1954 1944 1955 1945 #ifdef CONFIG_MMU 1956 1946
-13
mm/memory.c
··· 162 162 } 163 163 __setup("norandmaps", disable_randmaps); 164 164 165 - unsigned long zero_pfn __read_mostly; 166 - EXPORT_SYMBOL(zero_pfn); 167 - 168 165 unsigned long highest_memmap_pfn __read_mostly; 169 - 170 - /* 171 - * CONFIG_MMU architectures set up ZERO_PAGE in their paging_init() 172 - */ 173 - static int __init init_zero_pfn(void) 174 - { 175 - zero_pfn = page_to_pfn(ZERO_PAGE(0)); 176 - return 0; 177 - } 178 - early_initcall(init_zero_pfn); 179 166 180 167 void mm_trace_rss_stat(struct mm_struct *mm, int member) 181 168 {
+10
mm/mm_init.c
··· 53 53 void *high_memory; 54 54 EXPORT_SYMBOL(high_memory); 55 55 56 + unsigned long zero_pfn __ro_after_init; 57 + EXPORT_SYMBOL(zero_pfn); 58 + 56 59 #ifdef CONFIG_DEBUG_MEMORY_INIT 57 60 int __meminitdata mminit_loglevel; 58 61 ··· 2674 2671 #endif 2675 2672 ); 2676 2673 } 2674 + 2675 + static int __init init_zero_pfn(void) 2676 + { 2677 + zero_pfn = page_to_pfn(ZERO_PAGE(0)); 2678 + return 0; 2679 + } 2680 + early_initcall(init_zero_pfn); 2677 2681 2678 2682 void __init __weak arch_mm_preinit(void) 2679 2683 {