From patchwork Thu Nov 2 02:56:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13443343 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 51D30C41535 for ; Thu, 2 Nov 2023 02:57:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2A488E0011; Wed, 1 Nov 2023 22:57:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB3A58E0009; Wed, 1 Nov 2023 22:57:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92EF08E0011; Wed, 1 Nov 2023 22:57:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7BD868E0009 for ; Wed, 1 Nov 2023 22:57:11 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5916A160E39 for ; Thu, 2 Nov 2023 02:57:11 +0000 (UTC) X-FDA: 81411502662.12.1FFE180 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) by imf01.hostedemail.com (Postfix) with ESMTP id 6F4D440007 for ; Thu, 2 Nov 2023 02:57:07 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.225 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698893829; a=rsa-sha256; cv=none; b=qmU+A2XIS9eCr6Rd0O2jOPTTBSPm6edROKXN/Nx5ycKdQne4jBYrZ4AsIVBlwM83EA3aMx HSMme8frWaxcZ1fS2aCDbAfV53q750DF8i9wGmcjM1rjBynaHtqJgm78ZBljskyPsLf2vO z4quJZIoNbDuJW2vENGd6BBwawTiKgE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.225 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=1698893829; 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:in-reply-to:references:references; bh=pBkM1/qLyUTUROmO1aPza7TK7CczzizhpwO6PW/dp5c=; b=xXQJGER+iLSrb6UpgwYcKKYh1EdWa+Ge0hfyAgB+6B/Y1w0L15ZRMglxOcfkgs8TxBeuPN 8rPMGDcrrOgtwU896wxXcPWfPdjT2d8jXRHKrssRWjn14SKOpnfP4kMorz7L3ip1lPFVUt Wi8rwu0zOaCOi2vgcO9zQZXSNwxkT7E= X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="126046533" X-IronPort-AV: E=Sophos;i="6.03,270,1694703600"; d="scan'208";a="126046533" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 11:56:57 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 49D47DF06F for ; Thu, 2 Nov 2023 11:56:55 +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 6FDCBD94A2 for ; Thu, 2 Nov 2023 11:56:54 +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 0357820050181 for ; Thu, 2 Nov 2023 11:56:54 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 7F4361A0072; Thu, 2 Nov 2023 10:56:53 +0800 (CST) From: Li Zhijian To: Andrew Morton , Greg Kroah-Hartman , rafael@kernel.org, linux-mm@kvack.org Cc: ying.huang@intel.com, y-goto@fujitsu.com, linux-kernel@vger.kernel.org, Li Zhijian Subject: [PATCH RFC 1/4] drivers/base/node: Add demotion_nodes sys infterface Date: Thu, 2 Nov 2023 10:56:45 +0800 Message-Id: <20231102025648.1285477-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20231102025648.1285477-1-lizhijian@fujitsu.com> References: <20231102025648.1285477-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27972.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27972.004 X-TMASE-Result: 10--14.336100-10.000000 X-TMASE-MatchedRID: SzbEz7SZt2vZZREXUuleLioiRKlBVkYIfb+ZO7kHlEgpzVB/joYk/NBK hYxPftuoV6Ny+iZr9hdg3t1DWHRjJ3jXR2Tx0VSFpSXVpBS+ilYCtGYG0znilDoUdFbHYUawvwU evDt+uW5/XjpbSJS7awAWmAcUEPw5C8OYzF1BQS4ZgmFGHqyx6xgff28UuvITx8BJ7uScK21J2n edCULoK/ivPJqimipv4QeSIpZv9OkfE8yM4pjsDwtuKBGekqUpI/NGWt0UYPAARPH/Z7Dn2zo9f 1+qs3ML8eQMN6SWv/KHJHsBzrGMm1Se7XPfCxbq X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6F4D440007 X-Stat-Signature: dfwadkpccs5ae9f5qi6gien1o6568zz9 X-Rspam-User: X-HE-Tag: 1698893827-293778 X-HE-Meta: U2FsdGVkX18qoeUrKlzmCKRWReIEOeSYRYZxuB/SebpwTxYTNP2Bq5R5u3X+BWdP4a5IKlSzoZzivK++ooJ7BtR41HrhPCwtT2bAxwEFhi8HyY1uf854Voc1V1Xw3E2EuR1L9cOkbtjs5sxpo0904bcbL4DjmoB4NGo4Hz/2zUSb1nDcNGECRxFB/6zmmSFb2tjgf44LOB4+KvEynI4bv48yg8ptxqP14OGe9RJbrbizsYrT9yQXXsj1UDj4x5kYNKVkV/ZY32Pqwi4a4+AajhbPiAhofndJ88BbCUVYHEVc0JJv4uUkaQpgQQ/oN0p7tNGiletL4KASHvx07OsYEHn5R2jytWrG19G1kfaZd9S/W3dTDfFo4eE7KalZzePqmqbW0AOsu/LMC1B6waoZ0vdeGTtGoyUG2Fj35Nb6PK5RCnMtsTDkIwPiWtKcRNGClZzMtODwchHWJkKXSuYi6Qks7mCz4AQSHiuS9wGF2A7KpTV9nboanRSP7Hvza2ltXTtzTCODw6O6y9Fa2pfPB0mJq1ayqcJqex46Hk68cL/gIPz4UPQshR7wcdq0N0f7xtixIhkxFanEUxBWnGGgg+QH2RQ0jIUjRZw3SpgKFRxs1xjbUPnh58N37mWX/9a1YN6YumgzViBNmLZmmTcnAgpf4TwE4rU88nd5u5+DPDZOfWOESooahn+Q4okRUTAVo7XJ1K7yt2JE+TTyWGdBbu6qr/unkopfKIQHTePltLlxuVUjbxgdZbif6y0XSqt8LGY0GRAvFgHVkohKDPnImMBen2lIEJFdShjO37oR7oHaaztS5/Fk99bJxT3l3tgKiah4LHcIZpy9GcobCogda8PyTQrS1PXGc0wYn0Kd06FH0kfqfzIRhCMxTjWEbsHyX2oikijCuPOJ6gKwlac33iITdjqKsT9gQ7WWJCx5fHqUrLGMoiDsTS4wUOn8zDwJ0djm59wtRFcI+tlBjLH jc/jA2uK XJ/POwlaUJLyWqK3MLy4/aDomnbRX4d3G8onTMAv7T+OfmC1ZRC++EuNkVlcrgXNDzT4TllHpcpYn+SWW5pWsW0yCPXV+SxwtGbOy02jtS5aqKlNEtcnxPXHmF2n+XyScD7k/lZqQydUTFAnVZJsDMqKRCAZQTYsIrOXqYSFSiFod/GF+09KA7qtCx9f3HGmV0s8hE1HNRjBKNCbRGecMSTXFHKaJJTxobb8eXaVmmD+sltfCwi8pn+mBEA== 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: It shows the demotion target nodes of a node. Export this information to user directly. Below is an example where node0 node1 are DRAM, node3 is a PMEM node. - Before PMEM is online, no demotion_nodes for node0 and node1. $ cat /sys/devices/system/node/node0/demotion_nodes - After node3 is online as kmem $ daxctl reconfigure-device --mode=system-ram --no-online dax0.0 && daxctl online-memory dax0.0 [ { "chardev":"dax0.0", "size":1054867456, "target_node":3, "align":2097152, "mode":"system-ram", "online_memblocks":0, "total_memblocks":7 } ] $ cat /sys/devices/system/node/node0/demotion_nodes 3 $ cat /sys/devices/system/node/node1/demotion_nodes 3 $ cat /sys/devices/system/node/node3/demotion_nodes Signed-off-by: Li Zhijian --- drivers/base/node.c | 13 +++++++++++++ include/linux/memory-tiers.h | 6 ++++++ mm/memory-tiers.c | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/drivers/base/node.c b/drivers/base/node.c index 493d533f8375..27e8502548a7 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -569,11 +570,23 @@ static ssize_t node_read_distance(struct device *dev, } static DEVICE_ATTR(distance, 0444, node_read_distance, NULL); +static ssize_t demotion_nodes_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int ret; + nodemask_t nmask = next_demotion_nodes(dev->id); + + ret = sysfs_emit(buf, "%*pbl\n", nodemask_pr_args(&nmask)); + return ret; +} +static DEVICE_ATTR_RO(demotion_nodes); + static struct attribute *node_dev_attrs[] = { &dev_attr_meminfo.attr, &dev_attr_numastat.attr, &dev_attr_distance.attr, &dev_attr_vmstat.attr, + &dev_attr_demotion_nodes.attr, NULL }; diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h index 437441cdf78f..8eb04923f965 100644 --- a/include/linux/memory-tiers.h +++ b/include/linux/memory-tiers.h @@ -38,6 +38,7 @@ void init_node_memory_type(int node, struct memory_dev_type *default_type); void clear_node_memory_type(int node, struct memory_dev_type *memtype); #ifdef CONFIG_MIGRATION int next_demotion_node(int node); +nodemask_t next_demotion_nodes(int node); void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets); bool node_is_toptier(int node); #else @@ -46,6 +47,11 @@ static inline int next_demotion_node(int node) return NUMA_NO_NODE; } +static inline next_demotion_nodes next_demotion_nodes(int node) +{ + return NODE_MASK_NONE; +} + static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets) { *targets = NODE_MASK_NONE; diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index 37a4f59d9585..90047f37d98a 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -282,6 +282,14 @@ void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets) rcu_read_unlock(); } +nodemask_t next_demotion_nodes(int node) +{ + if (!node_demotion) + return NODE_MASK_NONE; + + return node_demotion[node].preferred; +} + /** * next_demotion_node() - Get the next node in the demotion path * @node: The starting node to lookup the next node