Commit 544b8e14 authored by Wei Yang's avatar Wei Yang Committed by Mike Rapoport (IBM)

mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition

If deferred_init_mem_pfn_range_in_zone() return true, we know it finds
some range in (spfn, epfn). Then we can use it directly for the loop
condition.
Signed-off-by: default avatarWei Yang <richard.weiyang@gmail.com>
Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
Link: https://lore.kernel.org/all/20240605071339.15330-1-richard.weiyang@gmail.comSigned-off-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
parent ce8ebb95
...@@ -2170,20 +2170,15 @@ static int __init deferred_init_memmap(void *data) ...@@ -2170,20 +2170,15 @@ static int __init deferred_init_memmap(void *data)
/* Only the highest zone is deferred */ /* Only the highest zone is deferred */
zone = pgdat->node_zones + pgdat->nr_zones - 1; zone = pgdat->node_zones + pgdat->nr_zones - 1;
/* If the zone is empty somebody else may have cleared out the zone */
if (!deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
first_init_pfn))
goto zone_empty;
max_threads = deferred_page_init_max_threads(cpumask); max_threads = deferred_page_init_max_threads(cpumask);
while (spfn < epfn) { while (deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, first_init_pfn)) {
unsigned long epfn_align = ALIGN(epfn, PAGES_PER_SECTION); first_init_pfn = ALIGN(epfn, PAGES_PER_SECTION);
struct padata_mt_job job = { struct padata_mt_job job = {
.thread_fn = deferred_init_memmap_chunk, .thread_fn = deferred_init_memmap_chunk,
.fn_arg = zone, .fn_arg = zone,
.start = spfn, .start = spfn,
.size = epfn_align - spfn, .size = first_init_pfn - spfn,
.align = PAGES_PER_SECTION, .align = PAGES_PER_SECTION,
.min_chunk = PAGES_PER_SECTION, .min_chunk = PAGES_PER_SECTION,
.max_threads = max_threads, .max_threads = max_threads,
...@@ -2191,10 +2186,8 @@ static int __init deferred_init_memmap(void *data) ...@@ -2191,10 +2186,8 @@ static int __init deferred_init_memmap(void *data)
}; };
padata_do_multithreaded(&job); padata_do_multithreaded(&job);
deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
epfn_align);
} }
zone_empty:
/* Sanity check that the next zone really is unpopulated */ /* Sanity check that the next zone really is unpopulated */
WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone)); WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment