From: Wei Yang <richard.weiyang@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Wei Yang <richard.weiyang@gmail.com>,
Krupa Ramakrishnan <krupa.ramakrishnan@amd.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Michal Hocko <mhocko@suse.com>
Subject: [PATCH 2/2] mm/page_alloc: add penalty to local_node
Date: Sun, 23 Jan 2022 01:35:37 +0000 [thread overview]
Message-ID: <20220123013537.20491-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220123013537.20491-1-richard.weiyang@gmail.com>
'Commit 54d032ced983 ("mm/page_alloc: use accumulated load when building
node fallback list")' fix a bug on zonelist order. This let me think
about what would happen if we have a node system with the following
distance matrix.
Node 0 1 2 3 4 5 6 7
----------------------------
0 10 12 12 12 32 32 32 32
1 12 10 12 12 32 32 32 32
2 12 12 10 12 32 32 32 32
3 12 12 12 10 32 32 32 32
4 32 32 32 32 10 12 12 12
5 32 32 32 32 12 10 12 12
6 32 32 32 32 12 12 10 12
7 32 32 32 32 12 12 12 10
Unfortunately for this case, the node fallback list gets built like this:
Node Fallback list
---------------------
0: 0 1 2 3 4 5 6 7
1: 1 0 2 3 5 6 7 4
2: 2 3 0 1 6 7 4 5
3: 3 2 0 1 7 4 5 6
4: 4 5 6 7 0 1 2 3
5: 5 4 6 7 1 2 3 0
6: 6 7 4 5 2 3 0 1
7: 7 6 4 5 3 0 1 2
We found the order in diagonal block is not expected. The reason is we
don't penalty local node.
After penalty local node, the node fallback list gets built like this:
Node Fallback list
---------------------
0: 0 1 2 3 4 5 6 7
1: 1 2 3 0 5 6 7 4
2: 2 3 0 1 6 7 4 5
3: 3 0 1 2 7 4 5 6
4: 4 5 6 7 0 1 2 3
5: 5 6 7 4 1 2 3 0
6: 6 7 4 5 2 3 0 1
7: 7 4 5 6 3 0 1 2
Now the fallback list is in round-robin order.
I am not very familiar with the node distance pattern, while I tried the
following distance matrix. Both of them works with this change.
Node 0 1 2 3
----------------
0 10 10 10 10
1 10 10 10 10
2 10 10 10 10
3 10 10 10 10
Node 0 1 2 3 4 5 6 7
----------------------------
0 10 10 10 10 32 32 32 32
1 10 10 10 10 32 32 32 32
2 10 10 10 10 32 32 32 32
3 10 10 10 10 32 32 32 32
4 32 32 32 32 10 10 10 10
5 32 32 32 32 10 10 10 10
6 32 32 32 32 10 10 10 10
7 32 32 32 32 10 10 10 10
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Krupa Ramakrishnan <krupa.ramakrishnan@amd.com>
CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
CC: Michal Hocko <mhocko@suse.com>
---
mm/page_alloc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f27afd517652..0cc25429a17e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6260,8 +6260,9 @@ static void build_zonelists(pg_data_t *pgdat)
* So adding penalty to the first node in same
* distance group to make it round-robin.
*/
- if (node_distance(local_node, node) !=
- node_distance(local_node, prev_node))
+ if ((node_distance(local_node, node) !=
+ node_distance(local_node, prev_node)) ||
+ node == local_node)
node_load[node] += nr_online_nodes;
node_order[nr_nodes++] = node;
--
2.33.1
next prev parent reply other threads:[~2022-01-23 1:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-23 1:35 [PATCH 1/2] mm/page_alloc: add same penalty is enough to get round-robin order Wei Yang
2022-01-23 1:35 ` Wei Yang [this message]
2022-03-21 21:17 ` Andrew Morton
2022-03-26 15:48 ` Wei Yang
2022-04-05 17:11 ` Vlastimil Babka
2022-04-06 23:47 ` Wei Yang
2022-04-07 9:53 ` Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220123013537.20491-2-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=krupa.ramakrishnan@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox