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

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

authored by

Mike Rapoport (Microsoft) and committed by
Ingo Molnar
2d6bff31 0ad2507d

+30 -25
+30
arch/x86/kernel/e820.c
··· 1302 1302 int i; 1303 1303 u64 end; 1304 1304 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 + 1305 1335 /* 1306 1336 * The bootstrap memblock region count maximum is 128 entries 1307 1337 * (INIT_MEMBLOCK_REGIONS), but EFI might pass us more E820 entries
-25
arch/x86/kernel/setup.c
··· 866 866 if (efi_enabled(EFI_BOOT)) 867 867 efi_memblock_x86_reserve_range(); 868 868 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 - 893 869 x86_report_nx(); 894 870 895 871 apic_setup_apic_calls(); ··· 966 990 967 991 cleanup_highmap(); 968 992 969 - memblock_set_current_limit(ISA_END_ADDRESS); 970 993 e820__memblock_setup(); 971 994 972 995 /*