Re: [PATCH 06/14] mm/bootmem_info: remove handling for !CONFIG_SPARSEMEM_VMEMMAP

Lorenzo Stoakes (Oracle)
2026-03-17T17:49:53Z

On Tue, Mar 17, 2026 at 05:56:44PM +0100, David Hildenbrand (Arm) wrote:
> It is not immediately obvious that CONFIG_HAVE_BOOTMEM_INFO_NODE is
> only selected from CONFIG_MEMORY_HOTREMOVE, which itself depends on
> CONFIG_MEMORY_HOTPLUG that ... depends on CONFIG_SPARSEMEM_VMEMMAP.

Ugh god.

>
> Let's remove the !CONFIG_SPARSEMEM_VMEMMAP leftovers.

Maybe worth explicitly saying 'dead code' here just to underline how stupid this
was...

>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>

This might be dead code, but this is a dead on patch, so:

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

> ---
> mm/bootmem_info.c | 37 -------------------------------------
> 1 file changed, 37 deletions(-)
>
> diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c
> index b0e2a9fa641f..e61e08e24924 100644
> --- a/mm/bootmem_info.c
> +++ b/mm/bootmem_info.c
> @@ -40,42 +40,6 @@ void put_page_bootmem(struct page *page)
> }
> }
>
> -#ifndef CONFIG_SPARSEMEM_VMEMMAP
> -static void __init register_page_bootmem_info_section(unsigned long start_pfn)
> -{
> - unsigned long mapsize, section_nr, i;
> - struct mem_section *ms;
> - struct page *page, *memmap;
> - struct mem_section_usage *usage;
> -
> - section_nr = pfn_to_section_nr(start_pfn);
> - ms = __nr_to_section(section_nr);
> -
> - /* Get section's memmap address */
> - memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr);
> -
> - /*
> - * Get page for the memmap's phys address
> - * XXX: need more consideration for sparse_vmemmap...
> - */
> - page = virt_to_page(memmap);
> - mapsize = sizeof(struct page) * PAGES_PER_SECTION;
> - mapsize = PAGE_ALIGN(mapsize) >> PAGE_SHIFT;
> -
> - /* remember memmap's page */
> - for (i = 0; i < mapsize; i++, page++)
> - get_page_bootmem(section_nr, page, SECTION_INFO);
> -
> - usage = ms->usage;
> - page = virt_to_page(usage);
> -
> - mapsize = PAGE_ALIGN(mem_section_usage_size()) >> PAGE_SHIFT;
> -
> - for (i = 0; i < mapsize; i++, page++)
> - get_page_bootmem(section_nr, page, MIX_SECTION_INFO);
> -
> -}

So this was just dead code before? That's gross.

> -#else /* CONFIG_SPARSEMEM_VMEMMAP */
> static void __init register_page_bootmem_info_section(unsigned long start_pfn)
> {
> unsigned long mapsize, section_nr, i;
> @@ -100,7 +64,6 @@ static void __init register_page_bootmem_info_section(unsigned long start_pfn)
> for (i = 0; i < mapsize; i++, page++)
> get_page_bootmem(section_nr, page, MIX_SECTION_INFO);
> }
> -#endif /* !CONFIG_SPARSEMEM_VMEMMAP */
>
> void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
> {
> --
> 2.43.0
>