Skip to content

Commit e120d1b

Browse files
rpptakpm00
authored andcommitted
arch, mm: set high_memory in free_area_init()
high_memory defines upper bound on the directly mapped memory. This bound is defined by the beginning of ZONE_HIGHMEM when a system has high memory and by the end of memory otherwise. All this is known to generic memory management initialization code that can set high_memory while initializing core mm structures. Add a generic calculation of high_memory to free_area_init() and remove per-architecture calculation except for the architectures that set and use high_memory earlier than that. Link: https://lkml.kernel.org/r/20250313135003.836600-11-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 8268af3 commit e120d1b

File tree

25 files changed

+30
-62
lines changed

25 files changed

+30
-62
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-
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
280279
memblock_free_all();
281280
}
282281

arch/arc/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ void __init setup_arch_memory(void)
150150
*/
151151
max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
152152

153-
high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
154-
155153
arch_pfn_offset = min(min_low_pfn, min_high_pfn);
156154
kmap_init();
157155
#endif /* CONFIG_HIGHMEM */

arch/arm64/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ void __init arm64_memblock_init(void)
309309
}
310310

311311
early_init_fdt_scan_reserved_mem();
312-
313-
high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
314312
}
315313

316314
void __init bootmem_init(void)

arch/csky/mm/init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void __init mem_init(void)
4747
#ifdef CONFIG_HIGHMEM
4848
unsigned long tmp;
4949
#endif
50-
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
5150

5251
memblock_free_all();
5352

arch/hexagon/mm/init.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ static void __init paging_init(void)
100100
* initial kernel segment table's physical address.
101101
*/
102102
init_mm.context.ptbase = __pa(init_mm.pgd);
103-
104-
/*
105-
* Start of high memory area. Will probably need something more
106-
* fancy if we... get more fancy.
107-
*/
108-
high_memory = (void *)((bootmem_lastpg + 1) << PAGE_SHIFT);
109103
}
110104

111105
#ifndef DMA_RESERVE

arch/loongarch/kernel/numa.c

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

390390
void __init mem_init(void)
391391
{
392-
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
393392
memblock_free_all();
394393
}
395394

arch/loongarch/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ void __init paging_init(void)
7878

7979
void __init mem_init(void)
8080
{
81-
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
82-
8381
memblock_free_all();
8482
}
8583
#endif /* !CONFIG_NUMA */

arch/microblaze/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ void __init setup_memory(void)
120120

121121
void __init mem_init(void)
122122
{
123-
high_memory = (void *)__va(memory_start + lowmem_size - 1);
124-
125123
/* this will put all memory onto the freelists */
126124
memblock_free_all();
127125
#ifdef CONFIG_HIGHMEM

arch/mips/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ void __init paging_init(void)
417417
max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn;
418418
}
419419
#endif
420-
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
421420

422421
free_area_init(max_zone_pfns);
423422
}
@@ -469,7 +468,6 @@ void __init mem_init(void)
469468
#else /* CONFIG_NUMA */
470469
void __init mem_init(void)
471470
{
472-
high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
473471
setup_zero_pages(); /* This comes from node 0 */
474472
memblock_free_all();
475473
}

arch/nios2/mm/init.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ void __init paging_init(void)
6262

6363
void __init mem_init(void)
6464
{
65-
unsigned long end_mem = memory_end; /* this must not include
66-
kernel stack at top */
67-
68-
end_mem &= PAGE_MASK;
69-
high_memory = __va(end_mem);
70-
7165
/* this will put all memory onto the freelists */
7266
memblock_free_all();
7367
}

0 commit comments

Comments
 (0)