diff mbox series

[v2,1/3] mm/mm_init.c: get the highest zone directly

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

Commit Message

Wei Yang June 5, 2024, 7:13 a.m. UTC
We have recorded nr_zones in pgdat, just get it directly.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
---
 mm/mm_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Mike Rapoport June 5, 2024, 7:55 a.m. UTC | #1
From: Mike Rapoport (IBM) <rppt@kernel.org>

On Wed, 05 Jun 2024 07:13:37 +0000, Wei Yang wrote:
> We have recorded nr_zones in pgdat, just get it directly.
> 
> 

Applied to for-next branch of memblock.git tree, thanks!

[1/3] mm/mm_init.c: get the highest zone directly
      commit: e62a627e845de79104e7fb6661eb69162aa91a21
[2/3] mm/mm_init.c: use deferred_init_mem_pfn_range_in_zone() to decide loop condition
      commit: 731b1168481978f56e81e1866758356387e4c23d
[3/3] mm/mm_init.c: not always search next deferred_init_pfn from very beginning
      commit: 8887ee905d0889d491e88b12f8134d31c8a21b11

tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
branch: for-next

--
Sincerely yours,
Mike.
diff mbox series

Patch

diff --git a/mm/mm_init.c b/mm/mm_init.c
index aa83105b3a1b..2bcf87eab0c6 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2136,7 +2136,7 @@  static int __init deferred_init_memmap(void *data)
 	unsigned long first_init_pfn, flags;
 	unsigned long start = jiffies;
 	struct zone *zone;
-	int zid, max_threads;
+	int max_threads;
 	u64 i;
 
 	/* Bind memory initialisation thread to a local node if possible */
@@ -2163,12 +2163,8 @@  static int __init deferred_init_memmap(void *data)
 	 */
 	pgdat_resize_unlock(pgdat, &flags);
 
-	/* Only the highest zone is deferred so find it */
-	for (zid = 0; zid < MAX_NR_ZONES; zid++) {
-		zone = pgdat->node_zones + zid;
-		if (first_init_pfn < zone_end_pfn(zone))
-			break;
-	}
+	/* 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,
@@ -2196,7 +2192,7 @@  static int __init deferred_init_memmap(void *data)
 	}
 zone_empty:
 	/* Sanity check that the next zone really is unpopulated */
-	WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone));
+	WARN_ON(pgdat->nr_zones < MAX_NR_ZONES && populated_zone(++zone));
 
 	pr_info("node %d deferred pages initialised in %ums\n",
 		pgdat->node_id, jiffies_to_msecs(jiffies - start));