diff mbox series

[2/3] mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition

Message ID 20240531002613.5231-2-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series [1/3] mm/mm_init.c: get the highest zone directly | expand

Commit Message

Wei Yang May 31, 2024, 12:26 a.m. UTC
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 <richard.weiyang@gmail.com>
---
 mm/mm_init.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Mike Rapoport June 3, 2024, 6:23 a.m. UTC | #1
On Fri, May 31, 2024 at 12:26:12AM +0000, Wei Yang wrote:
> 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 <richard.weiyang@gmail.com>

Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
>  mm/mm_init.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 2bcf87eab0c6..d05a4c38310f 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -2166,20 +2166,15 @@ static int __init deferred_init_memmap(void *data)
>  	/* 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,
> @@ -2187,10 +2182,8 @@ static int __init deferred_init_memmap(void *data)
>  		};
>  
>  		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));
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 2bcf87eab0c6..d05a4c38310f 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2166,20 +2166,15 @@  static int __init deferred_init_memmap(void *data)
 	/* 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,
@@ -2187,10 +2182,8 @@  static int __init deferred_init_memmap(void *data)
 		};
 
 		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));