Skip to content

Commit 8268af3

Browse files
rpptakpm00
authored andcommitted
arch, mm: set max_mapnr when allocating memory map for FLATMEM
max_mapnr is essentially the size of the memory map for systems that use FLATMEM. There is no reason to calculate it in each and every architecture when it's anyway calculated in alloc_node_mem_map(). Drop setting of max_mapnr from architecture code and set it once in alloc_node_mem_map(). While on it, move definition of mem_map and max_mapnr to mm/mm_init.c so there won't be two copies for MMU and !MMU variants. Link: https://lkml.kernel.org/r/20250313135003.836600-10-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> [x86] Tested-by: Mark Brown <broonie@kernel.org> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Andreas Larsson <andreas@gaisler.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Borislav Betkov <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: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Guo Ren (csky) <guoren@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Richard Weinberger <richard@nod.at> Cc: Russel King <linux@armlinux.org.uk> Cc: Stafford Horne <shorne@gmail.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleinxer <tglx@linutronix.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vineet Gupta <vgupta@kernel.org> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent d319c8b commit 8268af3

File tree

26 files changed

+21
-86
lines changed

26 files changed

+21
-86
lines changed

arch/alpha/mm/init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ srm_paging_stop (void)
276276
void __init
277277
mem_init(void)
278278
{
279-
set_max_mapnr(max_low_pfn);
280279
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
281280
memblock_free_all();
282281
}

arch/arc/mm/init.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,6 @@ void __init setup_arch_memory(void)
154154

155155
arch_pfn_offset = min(min_low_pfn, min_high_pfn);
156156
kmap_init();
157-
158-
#else /* CONFIG_HIGHMEM */
159-
/* pfn_valid() uses this when FLATMEM=y and HIGHMEM=n */
160-
max_mapnr = max_low_pfn - min_low_pfn;
161-
162157
#endif /* CONFIG_HIGHMEM */
163158

164159
free_area_init(max_zone_pfn);

arch/arm/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,6 @@ void __init mem_init(void)
275275
swiotlb_init(max_pfn > arm_dma_pfn_limit, SWIOTLB_VERBOSE);
276276
#endif
277277

278-
set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
279-
280278
#ifdef CONFIG_SA1111
281279
/* now that our DMA memory is actually so designated, we can free it */
282280
memblock_phys_free(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);

arch/csky/mm/init.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ void __init mem_init(void)
4646
{
4747
#ifdef CONFIG_HIGHMEM
4848
unsigned long tmp;
49-
50-
set_max_mapnr(highend_pfn - ARCH_PFN_OFFSET);
51-
#else
52-
set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET);
5349
#endif
5450
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
5551

arch/loongarch/mm/init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ void __init paging_init(void)
7878

7979
void __init mem_init(void)
8080
{
81-
max_mapnr = max_low_pfn;
8281
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
8382

8483
memblock_free_all();

arch/microblaze/mm/init.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,13 @@ void __init setup_memory(void)
104104
*
105105
* min_low_pfn - the first page (mm/bootmem.c - node_boot_start)
106106
* max_low_pfn
107-
* max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn)
108107
*/
109108

110109
/* memory start is from the kernel end (aligned) to higher addr */
111110
min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */
112-
/* RAM is assumed contiguous */
113-
max_mapnr = memory_size >> PAGE_SHIFT;
114111
max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT;
115112
max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT;
116113

117-
pr_info("%s: max_mapnr: %#lx\n", __func__, max_mapnr);
118114
pr_info("%s: min_low_pfn: %#lx\n", __func__, min_low_pfn);
119115
pr_info("%s: max_low_pfn: %#lx\n", __func__, max_low_pfn);
120116
pr_info("%s: max_pfn: %#lx\n", __func__, max_pfn);

arch/mips/mm/init.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,7 @@ void __init paging_init(void)
415415
" %ldk highmem ignored\n",
416416
(highend_pfn - max_low_pfn) << (PAGE_SHIFT - 10));
417417
max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn;
418-
419-
max_mapnr = max_low_pfn;
420-
} else if (highend_pfn) {
421-
max_mapnr = highend_pfn;
422-
} else {
423-
max_mapnr = max_low_pfn;
424418
}
425-
#else
426-
max_mapnr = max_low_pfn;
427419
#endif
428420
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
429421

arch/nios2/kernel/setup.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ void __init setup_arch(char **cmdline_p)
158158
*cmdline_p = boot_command_line;
159159

160160
find_limits(&min_low_pfn, &max_low_pfn, &max_pfn);
161-
max_mapnr = max_low_pfn;
162161

163162
memblock_reserve(__pa_symbol(_stext), _end - _stext);
164163
#ifdef CONFIG_BLK_DEV_INITRD

arch/nios2/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void __init paging_init(void)
5151
pagetable_init();
5252
pgd_current = swapper_pg_dir;
5353

54-
max_zone_pfn[ZONE_NORMAL] = max_mapnr;
54+
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
5555

5656
/* pass the memory from the bootmem allocator to the main allocator */
5757
free_area_init(max_zone_pfn);

arch/openrisc/mm/init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ void __init mem_init(void)
193193
{
194194
BUG_ON(!mem_map);
195195

196-
max_mapnr = max_low_pfn;
197196
high_memory = (void *)__va(max_low_pfn * PAGE_SIZE);
198197

199198
/* clear the zero-page */

0 commit comments

Comments
 (0)