Skip to content

Commit 544b8e1

Browse files
RichardWeiYangrppt
authored andcommitted
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: Wei Yang <[email protected]> Reviewed-by: Mike Rapoport (IBM) <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Mike Rapoport (IBM) <[email protected]>
1 parent ce8ebb9 commit 544b8e1

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

mm/mm_init.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,31 +2170,24 @@ static int __init deferred_init_memmap(void *data)
21702170
/* Only the highest zone is deferred */
21712171
zone = pgdat->node_zones + pgdat->nr_zones - 1;
21722172

2173-
/* If the zone is empty somebody else may have cleared out the zone */
2174-
if (!deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
2175-
first_init_pfn))
2176-
goto zone_empty;
2177-
21782173
max_threads = deferred_page_init_max_threads(cpumask);
21792174

2180-
while (spfn < epfn) {
2181-
unsigned long epfn_align = ALIGN(epfn, PAGES_PER_SECTION);
2175+
while (deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, first_init_pfn)) {
2176+
first_init_pfn = ALIGN(epfn, PAGES_PER_SECTION);
21822177
struct padata_mt_job job = {
21832178
.thread_fn = deferred_init_memmap_chunk,
21842179
.fn_arg = zone,
21852180
.start = spfn,
2186-
.size = epfn_align - spfn,
2181+
.size = first_init_pfn - spfn,
21872182
.align = PAGES_PER_SECTION,
21882183
.min_chunk = PAGES_PER_SECTION,
21892184
.max_threads = max_threads,
21902185
.numa_aware = false,
21912186
};
21922187

21932188
padata_do_multithreaded(&job);
2194-
deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn,
2195-
epfn_align);
21962189
}
2197-
zone_empty:
2190+
21982191
/* Sanity check that the next zone really is unpopulated */
21992192
WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone));
22002193

0 commit comments

Comments
 (0)