Skip to contentSkip to conversation

mm/page_alloc: cleanup flag vars in alloc_pages_bulk_noprof()

PATCH Applied Brendan Jackman 5 participants 5 messages Mar 31 – Apr 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/page_alloc: cleanup flag vars in alloc_pages_bulk_noprof()

These two variables are redundant, squash them to align alloc_pages_bulk_noprof() with the style used in alloc_frozen_pages_nolock_noprof().

---
 mm/page_alloc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
mm/page_alloc.c +1 -4
index 111b54df8a3cb..5e280ded6e7ac 100644
@@ -5051,7 +5051,6 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	struct per_cpu_pages *pcp;
 	struct list_head *pcp_list;
 	struct alloc_context ac;
-	gfp_t alloc_gfp;
 	unsigned int alloc_flags = ALLOC_WMARK_LOW;
 	int nr_populated = 0, nr_account = 0;
 
@@ -5092,10 +5091,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 
 	/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
 	gfp &= gfp_allowed_mask;
-	alloc_gfp = gfp;
-	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags))
+	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
 		goto out;
-	gfp = alloc_gfp;
 
 	/* Find an allowed local zone that meets the low watermark. */
 	z = ac.preferred_zoneref;

---
base-commit: 57e5b07deacb0a9bd7b8c9b933ff72e902d4f06b
change-id: 20260331-b4-prepare_alloc_pages-flags-5bb9a1e04e00

Best regards,

Signature · 1 line
Brendan Jackman <[email protected]>
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Brendan Jackman

These two variables are redundant, squash them to align alloc_pages_bulk_noprof() with the style used in alloc_frozen_pages_nolock_noprof().

Indeed. I'm not sure why this was needed even in the original patch (387ba26fb1cb) that introduced this function. It carefully preserves the original gfp even though its value either gets overwritten later (prepare_alloc_pages succeeds) or is unused (prepare_alloc_pages fails)...

Quoted 2 lines
Quoted 37 lines
---
 mm/page_alloc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
mm/page_alloc.c +1 -5
index 111b54df8a3cb..5e280ded6e7ac 100644
@@ -5051,7 +5051,6 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
        struct per_cpu_pages *pcp;
        struct list_head *pcp_list;
        struct alloc_context ac;
-       gfp_t alloc_gfp;
        unsigned int alloc_flags = ALLOC_WMARK_LOW;
        int nr_populated = 0, nr_account = 0;
 
@@ -5092,10 +5091,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 
        /* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
        gfp &= gfp_allowed_mask;
-       alloc_gfp = gfp;
-       if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags))
+       if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
                goto out;
-       gfp = alloc_gfp;
 
        /* Find an allowed local zone that meets the low watermark. */
        z = ac.preferred_zoneref;
 
---

base-commit: 57e5b07deacb0a9bd7b8c9b933ff72e902d4f06b
change-id: 20260331-b4-prepare_alloc_pages-flags-5bb9a1e04e00

Best regards,
--
Brendan Jackman <[email protected]>

Reviewed-by
#2 lore raw
Quoted 11 lines · Suren Baghdasaryan
Quoted 4 lines · Brendan Jackman

These two variables are redundant, squash them to align alloc_pages_bulk_noprof() with the style used in alloc_frozen_pages_nolock_noprof().

Indeed. I'm not sure why this was needed even in the original patch (387ba26fb1cb) that introduced this function. It carefully preserves the original gfp even though its value either gets overwritten later (prepare_alloc_pages succeeds) or is unused (prepare_alloc_pages fails)...

I did some digging and wasn't able to find any reason myself. It should be fine without it.

Quoted 4 lines
Quoted 2 lines
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Brendan Jackman
Quoted 5 lines · Brendan Jackman

These two variables are redundant, squash them to align alloc_pages_bulk_noprof() with the style used in alloc_frozen_pages_nolock_noprof().

Quoted 34 lines
---
 mm/page_alloc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
mm/page_alloc.c +1 -5
index 111b54df8a3cb..5e280ded6e7ac 100644
@@ -5051,7 +5051,6 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	struct per_cpu_pages *pcp;
 	struct list_head *pcp_list;
 	struct alloc_context ac;
-	gfp_t alloc_gfp;
 	unsigned int alloc_flags = ALLOC_WMARK_LOW;
 	int nr_populated = 0, nr_account = 0;
 
@@ -5092,10 +5091,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 
 	/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
 	gfp &= gfp_allowed_mask;
-	alloc_gfp = gfp;
-	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags))
+	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
 		goto out;
-	gfp = alloc_gfp;
 
 	/* Find an allowed local zone that meets the low watermark. */
 	z = ac.preferred_zoneref;
 
---

base-commit: 57e5b07deacb0a9bd7b8c9b933ff72e902d4f06b
change-id: 20260331-b4-prepare_alloc_pages-flags-5bb9a1e04e00

Best regards,

Reviewed-by on v1 1/1
#4 lore raw
In reply to Brendan Jackman
Quoted 24 lines · Brendan Jackman

These two variables are redundant, squash them to align alloc_pages_bulk_noprof() with the style used in alloc_frozen_pages_nolock_noprof().

---
 mm/page_alloc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
mm/page_alloc.c +0 -1
index 111b54df8a3cb..5e280ded6e7ac 100644
@@ -5051,7 +5051,6 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	struct per_cpu_pages *pcp;
 	struct list_head *pcp_list;
 	struct alloc_context ac;
-	gfp_t alloc_gfp;
 	unsigned int alloc_flags = ALLOC_WMARK_LOW;
 	int nr_populated = 0, nr_account = 0;
 
@@ -5092,10 +5091,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 

mm/page_alloc.c unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, · line 5098

Quoted 10 lines
mm/page_alloc.c +1 -3
 	/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
 	gfp &= gfp_allowed_mask;
-	alloc_gfp = gfp;
-	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags))
+	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
 		goto out;
-	gfp = alloc_gfp;
 
 	/* Find an allowed local zone that meets the low watermark. */
 	z = ac.preferred_zoneref;