If CONFIG_ARCH_KEEP_MEMBLOCK is enabled, the memory information in
memblock will be retained. We release the __init memory here, and
we should also delete the corresponding region in memblock.reserved,
which allows debugfs/memblock/reserved to display correct memory
information.
Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.com>
Link: https://lore.kernel.org/r/20240902023940.43227-1-rongqianfeng@vivo.com
Signed-off-by: Will Deacon <will@kernel.org>
void free_initmem(void)
{
+ unsigned long aligned_begin = ALIGN_DOWN((u64)__init_begin, PAGE_SIZE);
+ unsigned long aligned_end = ALIGN((u64)__init_end, PAGE_SIZE);
+
+ /* Delete __init region from memblock.reserved. */
+ memblock_free((void *)aligned_begin, aligned_end - aligned_begin);
+
free_reserved_area(lm_alias(__init_begin),
lm_alias(__init_end),
POISON_FREE_INITMEM, "unused kernel");