Skip to contentSkip to conversation

mm, page_alloc: drop pointless static qualifier in build_zonelists()

PATCH In review Kaitao Cheng 4 participants 4 messages Sep 27, 2019 – Oct 8, 2019

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

PATCH 1/1 mm, page_alloc: drop pointless static qualifier in build_zonelists()

There is no need to make the 'node_order' variable static since new value always be assigned before use it.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index 3334a769eb91..c473c304d09f 100644
@@ -5597,7 +5597,7 @@ static void build_thisnode_zonelists(pg_data_t *pgdat)
 
 static void build_zonelists(pg_data_t *pgdat)
 {
-	static int node_order[MAX_NUMNODES];
+	int node_order[MAX_NUMNODES];
 	int node, load, nr_nodes = 0;
 	nodemask_t used_mask;
 	int local_node, prev_node;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 15 lines · Kaitao Cheng

There is no need to make the 'node_order' variable static since new value always be assigned before use it.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +0 -0
index 3334a769eb91..c473c304d09f 100644

mm/page_alloc.c static void build_thisnode_zonelists(pg_data_t *pgdat) · line 5600

Quoted 5 lines
mm/page_alloc.c +1 -1
@@ -5597,7 +5597,7 @@ static void build_thisnode_zonelists(pg_data_t *pgdat)
 
 static void build_zonelists(pg_data_t *pgdat)
 {
-       static int node_order[MAX_NUMNODES];
+       int node_order[MAX_NUMNODES];

This isn't pointless. This prevents 4KB stack allocation which might overflow.

#2 lore raw
In reply to Kaitao Cheng
Quoted 2 lines · Kaitao Cheng

There is no need to make the 'node_order' variable static since new value always be assigned before use it.

In the past MAX_NUMMNODES could become quite large like 512 or 1k. Large array allocations on the stack are problematic.

Maybe that is no longer the case?

#3 lore raw
Quoted 9 lines · Cristopher Lameter
Quoted 2 lines · Kaitao Cheng

There is no need to make the 'node_order' variable static since new value always be assigned before use it.

In the past MAX_NUMMNODES could become quite large like 512 or 1k. Large array allocations on the stack are problematic.

Maybe that is no longer the case?

CONFIG_NODES_SHIFT=10 is nothing really unusual in distribution kernels. Likely wasteful for most HW available but a proper way to address it in this particular case is to use a different data structure than drop the static modifier which seems to be more of an misunderstanding than an intention.

Signature · 2 lines
Michal Hocko
SUSE Labs