From patchwork Tue Feb 6 02:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13546518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED2D3C48260 for ; Tue, 6 Feb 2024 02:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CBE26B0071; Mon, 5 Feb 2024 21:02:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47B966B0072; Mon, 5 Feb 2024 21:02:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CE536B0074; Mon, 5 Feb 2024 21:02:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1D41A6B0071 for ; Mon, 5 Feb 2024 21:02:11 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F27F740B5C for ; Tue, 6 Feb 2024 02:02:10 +0000 (UTC) X-FDA: 81759728820.25.0A437B6 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) by imf24.hostedemail.com (Postfix) with ESMTP id 7A3C218001A for ; Tue, 6 Feb 2024 02:02:08 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=JNZYclEl; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf24.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.61.252 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707184928; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=3PzvG93gqLmcxPeIMhDifmXSPPiYpe2WX8hxAnw/c8Q=; b=WJyDVaunmdfpmKPsheFuj4e6rYZVPp38TD5gjSVE/0kLkUXEaclzqRvpr6nSUmGmYSB8x3 VCqdUfY/TfL6fPkXWWv4FJd/L7F4amgyVMpBw49YApMIv3TT9yJOQWvuiP4O/aasZnCSs/ 8CHnEh+6yPgKkR7AlINUjTQCxpBItE0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=JNZYclEl; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf24.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.61.252 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707184929; a=rsa-sha256; cv=none; b=S3R/q4/tqFaHDpYP+0qdytlm2A+R8PzTp6aEk+RbTbt7cMIOe5ISXNgNB+BDzT0+I+p+qT EQF4P9E8Ht2sU7J5NJxhO7KPO0YKpwbVps7xAc0lWv1UTdniO66UEq7NXuCOsZYgdxczf3 rm8bVv5AZgknVBC+lMXVBERNfO3AVB8= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1707184928; x=1738720928; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=A6c6C805cvInprc5DfIwyhw/cznXAQ4Ac7UCK9u+NGQ=; b=JNZYclEleL53MEdmZRUzeYCcqGmVhKfXVv96xmz8ceCw5p3QCUpHrfRX Gg86s0oeyJftTgoHuqX/se5tHv2vC9urBP+ARxoeY8fsb/pa2wZMN6jTT Ir4Xj24t19Av+aqsN1pe8TrpI2lTZditVz8SurhrznJote2+1/HWTsptS WelIWmm8GSNObFKXbWlRE2FdSqtArehmfm2MPusKtKsuRtK2Rmx+gT1sd iBXJUmydsQG5swqmakS6jpt8G0EP28417BE3zR06HjR/3wf9oB4CC3LMv 7JACLb1WHlb4g14/NNncd+ATbCHACVnTQUQnAaGQkAfGH4FMEbfHCi+f+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="127273601" X-IronPort-AV: E=Sophos;i="6.05,245,1701097200"; d="scan'208";a="127273601" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 11:02:06 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id E488C7987F for ; Tue, 6 Feb 2024 11:02:03 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id D93CBD6206 for ; Tue, 6 Feb 2024 11:02:02 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 719BB2009641E for ; Tue, 6 Feb 2024 11:02:02 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 9CAD01A009A; Tue, 6 Feb 2024 10:02:01 +0800 (CST) From: Li Zhijian To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, Li Zhijian , "Huang, Ying" , "Aneesh Kumar K . V" Subject: [PATCH v2] mm/demotion: print demotion targets Date: Tue, 6 Feb 2024 10:01:51 +0800 Message-Id: <20240206020151.605516-1-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28170.003 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28170.003 X-TMASE-Result: 10--7.256200-10.000000 X-TMASE-MatchedRID: 84oovQVhL8FELNYIFEAu6zmKlJefBFwzvhf/zJ92tsM6Zx3YUNQTGzAW 5be84JTB+7QmOJudfuM0MAPuOAsAkxvtxLq45qm9Ojf3A4DTYuEfimmlcABuN+g3wNKii1r5gKe r2q0Zy9XA2G3OXMO97Otno5Fr47QU0ekSi+00U24ReM8i8p3vgEyQ5fRSh26513Gq5v1TibNVcX P3eMLfFyuV2J6ODXDa78NWCssKwqTSTldzGIIsPnaNJ/iTxXCafS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtJC9jS54qtzWMv0MkyTdeRcnUaQwUzbCHhhYN1k2z0iGM878aKTOCmQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7A3C218001A X-Stat-Signature: bcu96hd93fewrtmfn1c4shw37bbo6ujr X-HE-Tag: 1707184928-499540 X-HE-Meta: U2FsdGVkX19l+WJ3NOHBzys9K0tXiUk9fA9pusGg8LbT4JPktaljElANFfTra2nIDJ3X+qOWeS+/Vc79mopK+B5qIy8eiotMBAQvuZ3uHhQSi+BNSP+z+pW3D6rFcr9oPsvwpUppsGTPVp7cnknP7MNuJQg+MrGDt4yNmpf6zKQAoXmuvYVDeqssifQgBGJLUWk1n8t7ryA8Aejqx2147XRtpS5uW4C3nMm/iujfdkmlWEwy9GEMgoeAo7BaTe3YqEUgIqsM/Yw9bgB7C7A5uqaxwlWjUZFhTPtKLmSLXJ08kcaVD71DgIx6OfWSn/Zfv7yrocFfpGoyVIZFKVHP7Y0mr4rdAZKd3R0NBwBhthSyDd3TvlCIik8IiIvmv0BG+q2UN1U3jdjG7dR/NH8uZd7pjlHYqNMAhnwupqMI9V16mvcpz30FgSZApl6jN6KUCn79NPUg0h2gEOZjom0S0baP/jOXDg48c6hop8v2OtWrVvI5du7rOMEoiriTRKEHWwUIh8KlGstr6T6ZYZ0vAuX9vEUNH13fyhIeDiJxIUrqdF7MF8Kgwn5QZv66xdK9+v5Eq53c4bGXbV9J2aNJDMwSU65xo4k3NszbYhYeowT2QCMU/pLg0ARxCVBsFU/6Oy4TLj6m3SFONvDmEx9vy1Ti5UDhzBJLflXCaG/GilDXPuSugEE1ObVyM6+1Pt/nEbRawk6GIeBJTZkjOc2OxbIXhJjYijm1oz69HMgJbiv5V+uGeCaTyRYMh+Mnt88EVFmXL1/+SE8XT/8+WWOm51xtXe6OPZhmKP15fgrKVj0YSkNGvZayY8WrP/5ow+9l2rZ01s7ErjYZpuwhBm4VXUcWF1LLEAlo9RhCaXLZxbmRfyQGsKn3fLN8X37QWVLSxgHGTzXudjo6aG5qTyBBalp6SFRJeyKq6nvB2+983ifzdfZogxp2thVM6jhFiUNZ0x7VjJhp9u/NEHi6W1/ 5rQnWji2 BKxhQnMaSd4d/SCtKWJkMdH0cBKJ+Wy4zJ0RxLlapFqDCVQCcpU5NOtdVN0vMXCuqCw/LVPJoStxnv66wBDlp7bknURZ1xLrWE/+VIBnSUTJxuzwN1GXCcUmuAXMKdHdYQdSb726pZClqbXPAZd1BqOVlHOfRfpnT43pCDkuMAOC61yTyLPtDRP/pwcXGkfXkXZbKb/q3BW2p820Cnotb++LU5yeMkBPigP4H1agFCCuKpTdyys9l6gkRXnn4NghjNLOKS2xpSl8sBXlVRS9UEhMRu6kPKxfd0MOVqJDnGrb8CSMYPFP8GUlgL4t4c/4DE0okjuqc1mvT44pTm5AUOyd4gbE/Or2v0qMY X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, when a demotion occurs, it will prioritize selecting a node from the preferred targets as the destination node for the demotion. If the preferred node does not meet the requirements, it will try from all the lower memory tier nodes until it finds a suitable demotion destination node or ultimately fails. However, the demotion target information isn't exposed to the users, especially the preferred target information, which relies on more factors. This makes users hard to understand the exact demotion behavior. Rather than having a new sys interface to expose this information, printing directly to kernel messages, just like the current page allocation fallback order does. A dmesg example with this patch is as follows: [ 0.704860] Demotion targets for Node 0: null [ 0.705456] Demotion targets for Node 1: null // node 2 is onlined [ 32.259775] Demotion targets for Node 0: perferred: 2, fallback: 2 [ 32.261290] Demotion targets for Node 1: perferred: 2, fallback: 2 [ 32.262726] Demotion targets for Node 2: null // node 3 is onlined [ 42.448809] Demotion targets for Node 0: perferred: 2, fallback: 2-3 [ 42.450704] Demotion targets for Node 1: perferred: 2, fallback: 2-3 [ 42.452556] Demotion targets for Node 2: perferred: 3, fallback: 3 [ 42.454136] Demotion targets for Node 3: null // node 4 is onlined [ 52.676833] Demotion targets for Node 0: perferred: 2, fallback: 2-4 [ 52.678735] Demotion targets for Node 1: perferred: 2, fallback: 2-4 [ 52.680493] Demotion targets for Node 2: perferred: 4, fallback: 3-4 [ 52.682154] Demotion targets for Node 3: null [ 52.683405] Demotion targets for Node 4: null // node 5 is onlined [ 62.931902] Demotion targets for Node 0: perferred: 2, fallback: 2-5 [ 62.938266] Demotion targets for Node 1: perferred: 5, fallback: 2-5 [ 62.943515] Demotion targets for Node 2: perferred: 4, fallback: 3-4 [ 62.947471] Demotion targets for Node 3: null [ 62.949908] Demotion targets for Node 4: null [ 62.952137] Demotion targets for Node 5: perferred: 3, fallback: 3-4 CC: "Huang, Ying" CC: Aneesh Kumar K.V Signed-off-by: Li Zhijian Reviewed-by: "Huang, Ying" --- V2: Regarding this requirement, we have previously discussed [1]. The initial proposal involved introducing a new sys interface. However, due to concerns about potential changes and compatibility issues with the interface in the future, a consensus was not reached with the community. Therefore, this time, we are directly printing out the information. [1] https://lore.kernel.org/all/d1d5add8-8f4a-4578-8bf0-2cbe79b09989@fujitsu.com/ --- mm/memory-tiers.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index 5462d9e3c84c..4d3506a290b7 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -359,6 +359,26 @@ static void disable_all_demotion_targets(void) synchronize_rcu(); } +static void dump_demotion_targets(void) +{ + int node; + + for_each_node_state(node, N_MEMORY) { + struct memory_tier *memtier = __node_get_memory_tier(node); + nodemask_t preferred = node_demotion[node].preferred; + + if (!memtier) + continue; + + if (nodes_empty(preferred)) + pr_info("Demotion targets for Node %d: null\n", node); + else + pr_info("Demotion targets for Node %d: preferred: %*pbl, fallback: %*pbl\n", + node, nodemask_pr_args(&preferred), + nodemask_pr_args(&memtier->lower_tier_mask)); + } +} + /* * Find an automatic demotion target for all memory * nodes. Failing here is OK. It might just indicate @@ -443,7 +463,7 @@ static void establish_demotion_targets(void) * Now build the lower_tier mask for each node collecting node mask from * all memory tier below it. This allows us to fallback demotion page * allocation to a set of nodes that is closer the above selected - * perferred node. + * preferred node. */ lower_tier = node_states[N_MEMORY]; list_for_each_entry(memtier, &memory_tiers, list) { @@ -456,6 +476,8 @@ static void establish_demotion_targets(void) nodes_andnot(lower_tier, lower_tier, tier_nodes); memtier->lower_tier_mask = lower_tier; } + + dump_demotion_targets(); } #else