]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/boot: Move setting of memblock parameters to e820__memblock_setup()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Fri, 14 Feb 2025 09:06:48 +0000 (11:06 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 21 Feb 2025 15:05:00 +0000 (16:05 +0100)
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
arch/x86/kernel/e820.c
arch/x86/kernel/setup.c

index 82b96ed9890aba6260e73c9eaf049e738087b1f7..8d8bd039d2ac1a0eb35932ec6514280f395db207 100644 (file)
@@ -1302,6 +1302,36 @@ void __init e820__memblock_setup(void)
        int i;
        u64 end;
 
+#ifdef CONFIG_MEMORY_HOTPLUG
+       /*
+        * Memory used by the kernel cannot be hot-removed because Linux
+        * cannot migrate the kernel pages. When memory hotplug is
+        * enabled, we should prevent memblock from allocating memory
+        * for the kernel.
+        *
+        * ACPI SRAT records all hotpluggable memory ranges. But before
+        * SRAT is parsed, we don't know about it.
+        *
+        * The kernel image is loaded into memory at very early time. We
+        * cannot prevent this anyway. So on NUMA system, we set any
+        * node the kernel resides in as un-hotpluggable.
+        *
+        * Since on modern servers, one node could have double-digit
+        * gigabytes memory, we can assume the memory around the kernel
+        * image is also un-hotpluggable. So before SRAT is parsed, just
+        * allocate memory near the kernel image to try the best to keep
+        * the kernel away from hotpluggable memory.
+        */
+       if (movable_node_is_enabled())
+               memblock_set_bottom_up(true);
+#endif
+
+       /*
+        * At this point only the first megabyte is mapped for sure, the
+        * rest of the memory cannot be used for memblock resizing
+        */
+       memblock_set_current_limit(ISA_END_ADDRESS);
+
        /*
         * The bootstrap memblock region count maximum is 128 entries
         * (INIT_MEMBLOCK_REGIONS), but EFI might pass us more E820 entries
index cebee310e2009efa7cbcb64f6f841995940166d7..4baadeab8a2eeae130098375d7fa1cb406b85962 100644 (file)
@@ -866,30 +866,6 @@ void __init setup_arch(char **cmdline_p)
        if (efi_enabled(EFI_BOOT))
                efi_memblock_x86_reserve_range();
 
-#ifdef CONFIG_MEMORY_HOTPLUG
-       /*
-        * Memory used by the kernel cannot be hot-removed because Linux
-        * cannot migrate the kernel pages. When memory hotplug is
-        * enabled, we should prevent memblock from allocating memory
-        * for the kernel.
-        *
-        * ACPI SRAT records all hotpluggable memory ranges. But before
-        * SRAT is parsed, we don't know about it.
-        *
-        * The kernel image is loaded into memory at very early time. We
-        * cannot prevent this anyway. So on NUMA system, we set any
-        * node the kernel resides in as un-hotpluggable.
-        *
-        * Since on modern servers, one node could have double-digit
-        * gigabytes memory, we can assume the memory around the kernel
-        * image is also un-hotpluggable. So before SRAT is parsed, just
-        * allocate memory near the kernel image to try the best to keep
-        * the kernel away from hotpluggable memory.
-        */
-       if (movable_node_is_enabled())
-               memblock_set_bottom_up(true);
-#endif
-
        x86_report_nx();
 
        apic_setup_apic_calls();
@@ -990,7 +966,6 @@ void __init setup_arch(char **cmdline_p)
 
        cleanup_highmap();
 
-       memblock_set_current_limit(ISA_END_ADDRESS);
        e820__memblock_setup();
 
        /*