mm/page_alloc: add same penalty is enough to get round-robin order
Subsystems (2)
PATCH v2 1/2 mm/page_alloc: add same penalty is enough to get round-robin order
To make node order in round-robin in the same distance group, we add a penalty to the first node we got in each round.
To get a round-robin order in the same distance group, we don't need to decrease the penalty since:
* find_next_best_node() always iterates node in the same order
* distance matters more then penalty in find_next_best_node()
* in nodes with the same distance, the first one would be picked up
So it is fine to increase same penalty when we get the first node in the same distance group.
---
v2: adjust constant penalty to 1
--- mm/page_alloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/page_alloc.c +2 -4
@@ -6283,13 +6283,12 @@ 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, load, nr_nodes =0 ; +int node, nr_nodes =0 ;nodemask_t used_mask =NODE_MASK_NONE ;int local_node, prev_node;/* NUMA-aware ordering of nodes */ local_node = pgdat->node_id; - load = nr_online_nodes; prev_node = local_node;memset (node_order,0 ,sizeof (node_order));
@@ -6301,11 +6300,10 @@ static void build_zonelists(pg_data_t *pgdat)*/ if (node_distance (local_node, node) !=node_distance (local_node, prev_node)) - node_load[node] += load; + node_load[node] +=1 ; node_order[nr_nodes++] = node; prev_node = node; - load--; }build_zonelists_in_node_order (pgdat, node_order, nr_nodes);
Signature · 1 line
2.33.1
PATCH v2 2/2 mm/page_alloc: not necessary to multiply MAX_NODE_LOAD
Since we just increase a constance of 1 to node penalty, it is not necessary to multiply MAX_NODE_LOAD for preference.
This patch also remove the definition.
[[email protected]: suggests]
--- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/page_alloc.c +1 -2
@@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes)static int node_load[MAX_NUMNODES ];/**
@@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val +=PENALTY_FOR_NODE_WITH_CPUS ;/* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD *MAX_NUMNODES ); + val *=MAX_NUMNODES ; val += node_load[n];if (val < min_val) {
Signature · 1 line
2.33.1
Re: [Patch v2 2/2] mm/page_alloc: not necessary to multiply MAX_NODE_LOAD
Quoted 28 lines · Wei Yang
Since we just increase a constance of 1 to node penalty, it is not necessary to multiply
MAX_NODE_LOADfor preference.This patch also remove the definition.
[[email protected]: suggests]
Signed-off-by Wei Yang <[email protected]>CC Vlastimil Babka <[email protected]>CC David Hildenbrand <[email protected]>CC Oscar Salvador <[email protected]>--- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/page_alloc.c +0
-1@@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes)static int node_load[MAX_NUMNODES ];/**
mm/page_alloc.c int find_next_best_node(int node, nodemask_t *used_node_mask) · line 6222
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val +=PENALTY_FOR_NODE_WITH_CPUS ;/* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD *MAX_NUMNODES ); + val *=MAX_NUMNODES ; val += node_load[n];if (val < min_val) {
I feel like this should be squashed into the previous patch. It has the same effect of making this code independent of nr_online_nodes. And I had to scratch my head a couple of times in patch #1 why the change in patch #1 is fine with thus remaining in place.
Having that said, I consider this code highly unnecessary over-complicated at first sight. Removing some of the magic most certainly is very welcome.
This semantics of the global variable node_load[] remains mostly mysterious for me.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Patch v2 2/2] mm/page_alloc: not necessary to multiply MAX_NODE_LOAD
Quoted 44 lines · David Hildenbrand
Quoted 28 lines · Wei Yang
Since we just increase a constance of 1 to node penalty, it is not necessary to multiply
MAX_NODE_LOADfor preference.This patch also remove the definition.
[[email protected]: suggests]
Signed-off-by Wei Yang <[email protected]>CC Vlastimil Babka <[email protected]>CC David Hildenbrand <[email protected]>CC Oscar Salvador <[email protected]>--- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/page_alloc.c +0
-1@@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes)static int node_load[MAX_NUMNODES ];/** mm/page_alloc.c int find_next_best_node(int node, nodemask_t *used_node_mask) · line 6222
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val +=PENALTY_FOR_NODE_WITH_CPUS ;/* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD *MAX_NUMNODES ); + val *=MAX_NUMNODES ; val += node_load[n];if (val < min_val) {I feel like this should be squashed into the previous patch. It has the same effect of making this code independent of
nr_online_nodes. And I had to scratch my head a couple of times in patch #1 why the change in patch #1 is fine with thus remaining in place.
Quoted 7 lines
Having that said, I consider this code highly unnecessary over-complicated at first sight. Removing some of the magic most certainly is very welcome.
This semantics of the global variable node_load[] remains mostly mysterious for me.
So the suggestion is a v3 with #1 and #2 squashed?
Quoted 4 lines
Signature · 3 lines
Thanks, David / dhildenb
Signature · 2 lines
Wei Yang Help you, Help me
Re: [Patch v2 2/2] mm/page_alloc: not necessary to multiply MAX_NODE_LOAD
Quoted 45 lines · Wei Yang
Quoted 44 lines · David Hildenbrand
Quoted 28 lines · Wei Yang
Since we just increase a constance of 1 to node penalty, it is not necessary to multiply
MAX_NODE_LOADfor preference.This patch also remove the definition.
[[email protected]: suggests]
Signed-off-by Wei Yang <[email protected]>CC Vlastimil Babka <[email protected]>CC David Hildenbrand <[email protected]>CC Oscar Salvador <[email protected]>--- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/page_alloc.c +0
-1@@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes)static int node_load[MAX_NUMNODES ];/** mm/page_alloc.c int find_next_best_node(int node, nodemask_t *used_node_mask) · line 6222
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val +=PENALTY_FOR_NODE_WITH_CPUS ;/* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD *MAX_NUMNODES ); + val *=MAX_NUMNODES ; val += node_load[n];if (val < min_val) {I feel like this should be squashed into the previous patch. It has the same effect of making this code independent of
nr_online_nodes. And I had to scratch my head a couple of times in patch #1 why the change in patch #1 is fine with thus remaining in place.
Quoted 6 lines
Quoted 6 lines
Having that said, I consider this code highly unnecessary over-complicated at first sight. Removing some of the magic most certainly is very welcome.
This semantics of the global variable node_load[] remains mostly mysterious for me.
Looks like after this patch(es), it would be "how many times was this node picked as the first fallback out of nodes with the same distance"?
Quoted 3 lines
Quoted 1 line
So the suggestion is a v3 with #1 and #2 squashed?
Yes, and I agree with the suggestion.
Quoted 5 lines
Quoted 4 lines
Signature · 3 lines
Thanks, David / dhildenb
Re: [Patch v2 2/2] mm/page_alloc: not necessary to multiply MAX_NODE_LOAD
Quoted 53 lines · Vlastimil Babka
Quoted 45 lines · Wei Yang
Quoted 44 lines · David Hildenbrand
Quoted 28 lines · Wei Yang
Since we just increase a constance of 1 to node penalty, it is not necessary to multiply
MAX_NODE_LOADfor preference.This patch also remove the definition.
[[email protected]: suggests]
Signed-off-by Wei Yang <[email protected]>CC Vlastimil Babka <[email protected]>CC David Hildenbrand <[email protected]>CC Oscar Salvador <[email protected]>--- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/page_alloc.c +0
-1@@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes)static int node_load[MAX_NUMNODES ];/** mm/page_alloc.c int find_next_best_node(int node, nodemask_t *used_node_mask) · line 6222
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val +=PENALTY_FOR_NODE_WITH_CPUS ;/* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD *MAX_NUMNODES ); + val *=MAX_NUMNODES ; val += node_load[n];if (val < min_val) {I feel like this should be squashed into the previous patch. It has the same effect of making this code independent of
nr_online_nodes. And I had to scratch my head a couple of times in patch #1 why the change in patch #1 is fine with thus remaining in place.Quoted 6 lines
Quoted 6 lines
Having that said, I consider this code highly unnecessary over-complicated at first sight. Removing some of the magic most certainly is very welcome.
This semantics of the global variable node_load[] remains mostly mysterious for me.
Quoted 8 lines
Looks like after this patch(es), it would be "how many times was this node picked as the first fallback out of nodes with the same distance"?
Quoted 3 lines
Quoted 1 line
So the suggestion is a v3 with #1 and #2 squashed?
Yes, and I agree with the suggestion.
No problem.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Signature · 4 lines
-- Thanks, David / dhildenb
Signature · 2 lines
Wei Yang Help you, Help me
Re: [Patch v2 2/2] mm/page_alloc: not necessary to multiply MAX_NODE_LOAD
In reply to Vlastimil BabkaQuoted 50 lines · Vlastimil Babka
Quoted 49 lines · Wei Yang
Quoted 48 lines · David Hildenbrand
Quoted 28 lines · Wei Yang
Since we just increase a constance of 1 to node penalty, it is not necessary to multiply
MAX_NODE_LOADfor preference.This patch also remove the definition.
[[email protected]: suggests]
Signed-off-by Wei Yang <[email protected]>CC Vlastimil Babka <[email protected]>CC David Hildenbrand <[email protected]>CC Oscar Salvador <[email protected]>--- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/page_alloc.c +0
-1@@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes)static int node_load[MAX_NUMNODES ];/** mm/page_alloc.c int find_next_best_node(int node, nodemask_t *used_node_mask) · line 6222
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val +=PENALTY_FOR_NODE_WITH_CPUS ;/* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD *MAX_NUMNODES ); + val *=MAX_NUMNODES ; val += node_load[n];if (val < min_val) {I feel like this should be squashed into the previous patch. It has the same effect of making this code independent of
nr_online_nodes. And I had to scratch my head a couple of times in patch #1 why the change in patch #1 is fine with thus remaining in place.Having that said, I consider this code highly unnecessary over-complicated at first sight. Removing some of the magic most certainly is very welcome.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
This semantics of the global variable node_load[] remains mostly mysterious for me.
Looks like after this patch(es), it would be "how many times was this node picked as the first fallback out of nodes with the same distance"?
Yeah, that makes sense. I'd appreciate if we'd just stop using a global variable here and pass it as a parameter. But that's obviously an independent cleanup.
Signature · 3 lines
Thanks, David / dhildenb