mm/sparse: rename and cleanup sparse_init_nid()

Let's rename it to "sparse_metadata_init_nid", avoid the "pnum"
terminology and drop the function comment.  Further, rename the "map"
variable to "mem_map" for consistency with other functions.

Link: https://lore.kernel.org/20260921-b4-sparsemem_cleanups-v2-4-54d81d65e125@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Kairui Song <kasong@tencent.com>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Barry Song <baohua@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
David Hildenbrand (Arm) 2026-09-21 21:58:56 +02:00 committed by Andrew Morton
parent d8ab71169c
commit 31b3829703

View File

@ -221,36 +221,33 @@ void __weak __meminit vmemmap_populate_print_last(void)
{
}
/*
* Initialize sparse on a specific node. The node spans [pnum_begin, pnum_end)
* And number of present sections in this node is map_count.
*/
static void __init sparse_init_nid(int nid, unsigned long pnum_begin,
unsigned long pnum_end,
unsigned long map_count)
static void __init sparse_metadata_init_nid(int nid,
unsigned long start_section_nr, unsigned long end_section_nr,
unsigned long nr_sections)
{
unsigned long pnum;
struct mem_section_usage *usage;
unsigned long section_nr;
usage = memblock_alloc_node(map_count * mem_section_usage_size(),
usage = memblock_alloc_node(nr_sections * mem_section_usage_size(),
SMP_CACHE_BYTES, nid);
if (!usage)
panic("Failed to allocate usemap for node %d\n", nid);
for_each_present_section_nr(pnum_begin, pnum) {
unsigned long pfn = section_nr_to_pfn(pnum);
struct page *map;
for_each_present_section_nr(start_section_nr, section_nr) {
const unsigned long pfn = section_nr_to_pfn(section_nr);
struct page *mem_map;
if (pnum >= pnum_end)
if (section_nr >= end_section_nr)
break;
map = __populate_section_memmap(pfn, PAGES_PER_SECTION,
nid, NULL, NULL);
if (!map)
panic("Failed to allocate memmap for section %lu\n", pnum);
mem_map = __populate_section_memmap(pfn, PAGES_PER_SECTION, nid,
NULL, NULL);
if (!mem_map)
panic("Failed to allocate memmap for section %lu\n",
section_nr);
memmap_boot_pages_add(section_nr_vmemmap_pages(pfn, PAGES_PER_SECTION));
sparse_init_one_section(__nr_to_section(pnum), pnum, map, usage,
SECTION_IS_EARLY);
sparse_init_one_section(__nr_to_section(section_nr), section_nr,
mem_map, usage, SECTION_IS_EARLY);
usage = (void *)usage + mem_section_usage_size();
}
}
@ -268,12 +265,14 @@ static void __init sparse_metadata_init(void)
nr_sections++;
continue;
}
sparse_init_nid(nid_begin, start_section_nr, section_nr, nr_sections);
sparse_metadata_init_nid(nid_begin, start_section_nr,
section_nr, nr_sections);
nid_begin = nid;
start_section_nr = section_nr;
nr_sections = 1;
}
sparse_init_nid(nid_begin, start_section_nr, section_nr, nr_sections);
sparse_metadata_init_nid(nid_begin, start_section_nr, section_nr,
nr_sections);
}
/*