The patch titled Subject: mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition has been added to the -mm mm-unstable branch. Its filename is mm-mm_initc-use-deferred_init_mem_pfn_range_in_zone-to-decide-loop-condition.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-mm_initc-use-deferred_init_mem_pfn_range_in_zone-to-decide-loop-condition.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Wei Yang <richard.weiyang@xxxxxxxxx> Subject: mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition Date: Fri, 31 May 2024 00:26:12 +0000 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. Link: https://lkml.kernel.org/r/20240531002613.5231-2-richard.weiyang@xxxxxxxxx Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> Cc: Mike Rapoport (IBM) <rppt@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mm_init.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) --- a/mm/mm_init.c~mm-mm_initc-use-deferred_init_mem_pfn_range_in_zone-to-decide-loop-condition +++ a/mm/mm_init.c @@ -2168,20 +2168,15 @@ static int __init deferred_init_memmap(v /* Only the highest zone is deferred */ 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); - while (spfn < epfn) { - unsigned long epfn_align = ALIGN(epfn, PAGES_PER_SECTION); + while (deferred_init_mem_pfn_range_in_zone(&i, zone, &spfn, &epfn, first_init_pfn)) { + first_init_pfn = ALIGN(epfn, PAGES_PER_SECTION); struct padata_mt_job job = { .thread_fn = deferred_init_memmap_chunk, .fn_arg = zone, .start = spfn, - .size = epfn_align - spfn, + .size = first_init_pfn - spfn, .align = PAGES_PER_SECTION, .min_chunk = PAGES_PER_SECTION, .max_threads = max_threads, @@ -2189,10 +2184,8 @@ static int __init deferred_init_memmap(v }; 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 */ WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone)); _ Patches currently in -mm which might be from richard.weiyang@xxxxxxxxx are mm-mm_initc-get-the-highest-zone-directly.patch mm-mm_initc-use-deferred_init_mem_pfn_range_in_zone-to-decide-loop-condition.patch mm-mm_initc-not-always-search-next-deferred_init_pfn-from-very-beginning.patch