Skip to content

Commit 2d6bff3

Browse files
rpptIngo Molnar
authored andcommitted
x86/boot: Move setting of memblock parameters to e820__memblock_setup()
Changing memblock parameters, namely bottom_up and allocation upper limit does not have any effect before memblock initialization in e820__memblock_setup(). Move the calls to memblock_set_bottom_up() and memblock_set_current_limit() to e820__memblock_setup() to group all the memblock initial setup and make setup_arch() more readable. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20250214090651.3331663-2-rppt@kernel.org
1 parent 0ad2507 commit 2d6bff3

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

arch/x86/kernel/e820.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,36 @@ void __init e820__memblock_setup(void)
13021302
int i;
13031303
u64 end;
13041304

1305+
#ifdef CONFIG_MEMORY_HOTPLUG
1306+
/*
1307+
* Memory used by the kernel cannot be hot-removed because Linux
1308+
* cannot migrate the kernel pages. When memory hotplug is
1309+
* enabled, we should prevent memblock from allocating memory
1310+
* for the kernel.
1311+
*
1312+
* ACPI SRAT records all hotpluggable memory ranges. But before
1313+
* SRAT is parsed, we don't know about it.
1314+
*
1315+
* The kernel image is loaded into memory at very early time. We
1316+
* cannot prevent this anyway. So on NUMA system, we set any
1317+
* node the kernel resides in as un-hotpluggable.
1318+
*
1319+
* Since on modern servers, one node could have double-digit
1320+
* gigabytes memory, we can assume the memory around the kernel
1321+
* image is also un-hotpluggable. So before SRAT is parsed, just
1322+
* allocate memory near the kernel image to try the best to keep
1323+
* the kernel away from hotpluggable memory.
1324+
*/
1325+
if (movable_node_is_enabled())
1326+
memblock_set_bottom_up(true);
1327+
#endif
1328+
1329+
/*
1330+
* At this point only the first megabyte is mapped for sure, the
1331+
* rest of the memory cannot be used for memblock resizing
1332+
*/
1333+
memblock_set_current_limit(ISA_END_ADDRESS);
1334+
13051335
/*
13061336
* The bootstrap memblock region count maximum is 128 entries
13071337
* (INIT_MEMBLOCK_REGIONS), but EFI might pass us more E820 entries

arch/x86/kernel/setup.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -866,30 +866,6 @@ void __init setup_arch(char **cmdline_p)
866866
if (efi_enabled(EFI_BOOT))
867867
efi_memblock_x86_reserve_range();
868868

869-
#ifdef CONFIG_MEMORY_HOTPLUG
870-
/*
871-
* Memory used by the kernel cannot be hot-removed because Linux
872-
* cannot migrate the kernel pages. When memory hotplug is
873-
* enabled, we should prevent memblock from allocating memory
874-
* for the kernel.
875-
*
876-
* ACPI SRAT records all hotpluggable memory ranges. But before
877-
* SRAT is parsed, we don't know about it.
878-
*
879-
* The kernel image is loaded into memory at very early time. We
880-
* cannot prevent this anyway. So on NUMA system, we set any
881-
* node the kernel resides in as un-hotpluggable.
882-
*
883-
* Since on modern servers, one node could have double-digit
884-
* gigabytes memory, we can assume the memory around the kernel
885-
* image is also un-hotpluggable. So before SRAT is parsed, just
886-
* allocate memory near the kernel image to try the best to keep
887-
* the kernel away from hotpluggable memory.
888-
*/
889-
if (movable_node_is_enabled())
890-
memblock_set_bottom_up(true);
891-
#endif
892-
893869
x86_report_nx();
894870

895871
apic_setup_apic_calls();
@@ -990,7 +966,6 @@ void __init setup_arch(char **cmdline_p)
990966

991967
cleanup_highmap();
992968

993-
memblock_set_current_limit(ISA_END_ADDRESS);
994969
e820__memblock_setup();
995970

996971
/*

0 commit comments

Comments
 (0)