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

Configure Feed

Select the types of activity you want to include in your feed.

memblock: make free_reserved_area() update memblock if ARCH_KEEP_MEMBLOCK=y

On architectures that keep memblock after boot, freeing of reserved memory
with free_reserved_area() is paired with an update of memblock arrays,
usually by a call to memblock_free().

Make free_reserved_area() directly update memblock.reserved when
ARCH_KEEP_MEMBLOCK is enabled.

Remove the now-redundant explicit memblock_free() call from
arm64::free_initmem() and the #ifdef CONFIG_ARCH_KEEP_MEMBLOCK block
from the generic free_initrd_mem().

Link: https://patch.msgid.link/20260323074836.3653702-8-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

+6 -10
-3
arch/arm64/mm/init.c
··· 385 385 WARN_ON(!IS_ALIGNED((unsigned long)lm_init_begin, PAGE_SIZE)); 386 386 WARN_ON(!IS_ALIGNED((unsigned long)lm_init_end, PAGE_SIZE)); 387 387 388 - /* Delete __init region from memblock.reserved. */ 389 - memblock_free(lm_init_begin, lm_init_end - lm_init_begin); 390 - 391 388 free_reserved_area(lm_init_begin, lm_init_end, 392 389 POISON_FREE_INITMEM, "unused kernel"); 393 390 /*
-7
init/initramfs.c
··· 652 652 653 653 void __weak __init free_initrd_mem(unsigned long start, unsigned long end) 654 654 { 655 - #ifdef CONFIG_ARCH_KEEP_MEMBLOCK 656 - unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE); 657 - unsigned long aligned_end = ALIGN(end, PAGE_SIZE); 658 - 659 - memblock_free((void *)aligned_start, aligned_end - aligned_start); 660 - #endif 661 - 662 655 free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, 663 656 "initrd"); 664 657 }
+6
mm/memblock.c
··· 943 943 end_pa = __pa(end - 1) + 1; 944 944 } 945 945 946 + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) { 947 + if (start_pa < end_pa) 948 + memblock_remove_range(&memblock.reserved, 949 + start_pa, end_pa - start_pa); 950 + } 951 + 946 952 pages = __free_reserved_area(start_pa, end_pa, poison); 947 953 if (pages && s) 948 954 pr_info("Freeing %s memory: %ldK\n", s, K(pages));