mirror of
https://github.com/torvalds/linux.git
synced 2026-11-10 17:11:02 +01:00
mm/sparse: move initialization of section metadata to sparse_metadata_init()
Let's move the code responsible for initializing sparse metadata (usemap, memmap) into a helper. Cleanup the variable while at it (e.g., "map_count"). Drop the rather obvious code comments. No functional change intended. Link: https://lore.kernel.org/20260921-b4-sparsemem_cleanups-v2-3-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:
parent
89e2b6e3d3
commit
d8ab71169c
43
mm/sparse.c
43
mm/sparse.c
|
|
@ -255,38 +255,39 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin,
|
|||
}
|
||||
}
|
||||
|
||||
static void __init sparse_metadata_init(void)
|
||||
{
|
||||
unsigned long start_section_nr = first_present_section_nr();
|
||||
int nid_begin = sparse_early_nid(__nr_to_section(start_section_nr));
|
||||
unsigned long section_nr, nr_sections = 1;
|
||||
|
||||
for_each_present_section_nr(start_section_nr + 1, section_nr) {
|
||||
const int nid = sparse_early_nid(__nr_to_section(section_nr));
|
||||
|
||||
if (nid == nid_begin) {
|
||||
nr_sections++;
|
||||
continue;
|
||||
}
|
||||
sparse_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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate the accumulated non-linear sections, allocate a mem_map
|
||||
* for each and record the physical to section mapping.
|
||||
*/
|
||||
void __init sparse_init(void)
|
||||
{
|
||||
unsigned long pnum_end, pnum_begin, map_count = 1;
|
||||
int nid_begin;
|
||||
|
||||
if (compound_info_has_mask()) {
|
||||
VM_WARN_ON_ONCE(!IS_ALIGNED((unsigned long) pfn_to_page(0),
|
||||
MAX_FOLIO_VMEMMAP_ALIGN));
|
||||
}
|
||||
|
||||
pnum_begin = first_present_section_nr();
|
||||
nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
|
||||
|
||||
for_each_present_section_nr(pnum_begin + 1, pnum_end) {
|
||||
int nid = sparse_early_nid(__nr_to_section(pnum_end));
|
||||
|
||||
if (nid == nid_begin) {
|
||||
map_count++;
|
||||
continue;
|
||||
}
|
||||
/* Init node with sections in range [pnum_begin, pnum_end) */
|
||||
sparse_init_nid(nid_begin, pnum_begin, pnum_end, map_count);
|
||||
nid_begin = nid;
|
||||
pnum_begin = pnum_end;
|
||||
map_count = 1;
|
||||
}
|
||||
/* cover the last node */
|
||||
sparse_init_nid(nid_begin, pnum_begin, pnum_end, map_count);
|
||||
sparse_metadata_init();
|
||||
sparse_init_subsection_map();
|
||||
vmemmap_populate_print_last();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user