Skip to contentSkip to conversation

mm/sparse: nr_pages won't be 0

PATCH Applied Wei Yang 2 participants 6 messages Jun 19, 2024 – Jun 23, 2024

Subsystems (4)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/4 mm/sparse: nr_pages won't be 0

Function subsection_map_init() is only used in free_area_init() in the loop of for_each_mem_pfn_range(). And we are sure in each iteration of for_each_mem_pfn_range(), start_pfn < end_pfn.

So nr_pages is not possible to be 0 and we can remove the check.

CC Mike Rapoport (IBM) <[email protected]>
---
 mm/sparse.c | 3 ---
 1 file changed, 3 deletions(-)
mm/sparse.c +0 -3
index de40b2c73406..f56701873ce8 100644
@@ -195,9 +195,6 @@ void __init subsection_map_init(unsigned long pfn, unsigned long nr_pages)
 	int end_sec = pfn_to_section_nr(pfn + nr_pages - 1);
 	unsigned long nr, start_sec = pfn_to_section_nr(pfn);
 
-	if (!nr_pages)
-		return;
-
 	for (nr = start_sec; nr <= end_sec; nr++) {
 		struct mem_section *ms;
 		unsigned long pfns;
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/4 mm/mm_init.c: move build check on MAX_ZONELISTS out of ifdef

Current check on MAX_ZONELISTS is wrapped in CONFIG_DEBUG_MEMORY_INIT, which may not be triggered all the time.

Let's move it out to a more general place.

CC Mike Rapoport (IBM) <[email protected]>
---
 mm/mm_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mm_init.c +1 -1
index 31ebb3cd53ac..4991cb5c5436 100644
@@ -53,7 +53,6 @@ void __init mminit_verify_zonelist(void)
 		struct zonelist *zonelist;
 		int i, listid, zoneid;
 
-		BUILD_BUG_ON(MAX_ZONELISTS > 2);
 		for (i = 0; i < MAX_ZONELISTS * MAX_NR_ZONES; i++) {
 
 			/* Identify the zone and nodelist */
@@ -2668,6 +2667,7 @@ static void __init mem_init_print_info(void)
 void __init mm_core_init(void)
 {
 	/* Initializations relying on SMP setup */
+	BUILD_BUG_ON(MAX_ZONELISTS > 2);
 	build_all_zonelists(NULL);
 	page_alloc_init_cpuhp();
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 2/4
#2 lore raw

Re: [PATCH 2/4] mm/mm_init.c: move build check on MAX_ZONELISTS out of ifdef

Quoted 7 lines · Wei Yang

Current check on MAX_ZONELISTS is wrapped in CONFIG_DEBUG_MEMORY_INIT, which may not be triggered all the time.

Let's move it out to a more general place.

CC Mike Rapoport (IBM) <[email protected]>
Quoted 27 lines
---
 mm/mm_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mm_init.c +1 -1
index 31ebb3cd53ac..4991cb5c5436 100644
@@ -53,7 +53,6 @@ void __init mminit_verify_zonelist(void)
 		struct zonelist *zonelist;
 		int i, listid, zoneid;
 
-		BUILD_BUG_ON(MAX_ZONELISTS > 2);
 		for (i = 0; i < MAX_ZONELISTS * MAX_NR_ZONES; i++) {
 
 			/* Identify the zone and nodelist */
@@ -2668,6 +2667,7 @@ static void __init mem_init_print_info(void)
 void __init mm_core_init(void)
 {
 	/* Initializations relying on SMP setup */
+	BUILD_BUG_ON(MAX_ZONELISTS > 2);
 	build_all_zonelists(NULL);
 	page_alloc_init_cpuhp();
 
Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours,
Mike.
author
#3 lore raw

PATCH 3/4 mm/page_alloc: fix a typo in comment about GFP flag

In reply to Wei Yang

The GFP flags used to choose the zonelist is __GFP_THISNODE.

Let's change it to what exactly it should be.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index f3ba1ede142d..594176449890 100644
@@ -5209,7 +5209,7 @@ static void build_zonelists_in_node_order(pg_data_t *pgdat, int *node_order,
 }
 
 /*
- * Build gfp_thisnode zonelists
+ * Build __GFP_THISNODE zonelists
  */
 static void build_thisnode_zonelists(pg_data_t *pgdat)
 {
Signature · 1 line
2.34.1
maintainer Acked-by on v1 3/4
#4 lore raw

Re: [PATCH 3/4] mm/page_alloc: fix a typo in comment about GFP flag

Quoted 5 lines · Wei Yang

The GFP flags used to choose the zonelist is __GFP_THISNODE.

Let's change it to what exactly it should be.

Quoted 20 lines
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index f3ba1ede142d..594176449890 100644
@@ -5209,7 +5209,7 @@ static void build_zonelists_in_node_order(pg_data_t *pgdat, int *node_order,
 }
 
 /*
- * Build gfp_thisnode zonelists
+ * Build __GFP_THISNODE zonelists
  */
 static void build_thisnode_zonelists(pg_data_t *pgdat)
 {
Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours,
Mike.
author
#5 lore raw

PATCH 4/4 mm/page_alloc: reword the comment of buddy_merge_likely()

In reply to Wei Yang

For page with order O, we are checking its order (O + 1)'s buddy. If it is free, we would like to put it to the tail and expect it would be merged to a page with order (O + 2).

Reword the comment to reflect it.

---
 mm/page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/page_alloc.c +3 -3
index 594176449890..d1df7929f003 100644
@@ -706,12 +706,12 @@ static inline struct page *get_page_from_free_area(struct free_area *area,
 }
 
 /*
- * If this is not the largest possible page, check if the buddy
- * of the next-highest order is free. If it is, it's possible
+ * If this is less than the 2nd largest possible page, check if the buddy
+ * of the next-higher order is free. If it is, it's possible
  * that pages are being freed that will coalesce soon. In case,
  * that is happening, add the free page to the tail of the list
  * so it's less likely to be used soon and more likely to be merged
- * as a higher order page
+ * as a 2-level higher order page
  */
 static inline bool
 buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,
Signature · 1 line
2.34.1