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: Li Zhijian 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 From patchwork Thu Nov 2 02:56:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13443345 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 5D902C4332F for ; Thu, 2 Nov 2023 02:57:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 006ED8E0014; Wed, 1 Nov 2023 22:57:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED2AD8E0009; Wed, 1 Nov 2023 22:57:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4C178E0014; Wed, 1 Nov 2023 22:57:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C5CB28E0009 for ; Wed, 1 Nov 2023 22:57:34 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9B052120DD8 for ; Thu, 2 Nov 2023 02:57:34 +0000 (UTC) X-FDA: 81411503628.10.2EF635D Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by imf28.hostedemail.com (Postfix) with ESMTP id 48E83C0021 for ; Thu, 2 Nov 2023 02:57:31 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf28.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.137 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=1698893851; 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=fyXx7gHaeU0peW35MzmJZM4uRNKPnG2WG4mOi77pRtg=; b=7PeyKo9voDItng3L+n473+HOlgFtMiBFs+YoOXzMeDLwJH9Gf3WyAmLCfpmtUANB4Dr2Kr KB1mS6OSuDkwNzEBURWq4kJx7QDiKS8tNxoxfv+8D2JZjTt9uwxSaR4EvuX87O2YNFZpFr 2Ae5QM4Ls9h5rZWOvk8PyzLz0XvngDU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf28.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.137 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698893851; a=rsa-sha256; cv=none; b=iX4Qdg1dKPT1iNr6vA5nzH72mGWFJsOdbL+eeMx20ODAbMbIHW7+f14z6A3VeAek7hy0cw vQZr9RutyThDNuXbwBWTiMFrQ8EvzOVuxfK97UfX7xlPtLrZ7QfldtiIn9UaZd7cwWGYdh jxa+pvP7+dQC44caMRstaU68R0lUb8M= X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="117752854" X-IronPort-AV: E=Sophos;i="6.03,270,1694703600"; d="scan'208";a="117752854" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa11.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-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 9DBF0CA247 for ; Thu, 2 Nov 2023 11:56:55 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id C1667D94A2 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-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 60DF2E5E60 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 D80EF1A0071; 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 2/4] mm/vmstat: Move pgdemote_* to per-node stats Date: Thu, 2 Nov 2023 10:56:46 +0800 Message-Id: <20231102025648.1285477-3-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--0.846700-10.000000 X-TMASE-MatchedRID: 5rkJ48FE5MzOAp9H1IibggihQ5NZCXsS/OuUJVcMZhs6FHRWx2FGsL8F Hrw7frluf146W0iUu2vXgVbKoEEGVoYXQ9brtx4rngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPIcSq bxBgG0w5WoX0SFtPDB2Ve53KQDkILphM7H89s7DKCcrz/r6s9wQi97CyytPpdWBbwXBagd4Bbqn 8KVqy/D6rems9Kg9kizvTBn3+4zZZbjBuldNvkMkoq97WSHdFjfupJaud1uZCfRs6uIbkFVw== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspam-User: X-Stat-Signature: jpc6zr84f499q54wqb3x6gni4nkcc59i X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 48E83C0021 X-HE-Tag: 1698893851-916178 X-HE-Meta: U2FsdGVkX1/X0p2MxP/q0/b4SFSs80moszraqRokXNrHPDqTn0ogLF+OKEb3N61SoaE6ps0Fdz12px2xmEXOVSLNjv1NOTnqZj1jFhs/m10sJZviQOugVqf3gp9xtQjcwIXoleM2COWkrxIt+UmHN7aar2+K0nTgDpkItunpNkxr5QC+lu2ZxLFRRhzSJpt4bJBFm6AZcgvC5Gh5aMa1nre41Dbdo/OwsnoNKi0cPbfM8iv77MWAdK9v48oVaspHnlW5fLqVienHdJ5T2kQCTcFwo2qKk4YHk6N8mwghkxIUZHlXnNgK4zX2u8+Mx/pyqzW3AU3+b3eUgeVXcOMLgspaglg+zyiQcvCOo/AspiZVzSqPN2JNvQAiPQizHOzgvjaZeV6KiXTa09RkjRFS7ZiOa+IoNyVC1VSrZw7jzoqlxPVhLG4UsxE/3fRDD5mPZayLhqAmsy6HrG9jkvjBlSBEO9H3jfmucmtvd5l61ziJWiNtfOkglgRC4QPc3a2abs1cktbeVYEP+AhhM8f1YZd9XsPG8s0IrsjKxV1MprqCh1lukMN7y9a3mGNe7BDYcEEVYoSRw9xmm2OQOzhyLpO7NaRPSB3BmYY/7wLRpuwtUCZTRStsSES4N5RmWnL6wDCKx+Wrkm1TnUfxxchaFt8yHcGmk+fFcT+LWLwrD6O2QPDEiZUBrfhb1qDmJa2I7lIXR8X0DsrsHpVM3Niaioe75WPypNL4LMLvLuNA5GGSA13ACThK+PSph89YbSF5E309YHnETf1ZDTNY6mXd7Svx2EdWqy6bBKylA3nF58Kruy0lIYd3Ah9WlkFNOTOsDzsP+AwKWioM/K7nZP9sbGrnIOP2d3W/jhN5D7Y03GMq+fmX5NOKbihi02BxxkDYh9nxMtquT2aCB/NwrHCV8TCJYv7kXGvkIrlg6Ev7XBAL4W6QdrcZAgBqwAs635Do1AmBUPq8cSLLP8Xho5A MwJMNoSh Q+/GsbzE9puwnUnhmq5RjDISVapAdQ1QArQJAyd7A8eECrndt6Q9lrh8TV36m+6VPJJ4+sHxs3F9grNfvBeJ+8MTMANujgNyryMYfMt2H5aSxmVeqYNbVTKhTSjPpHkxaN6tG0EufT5fu99M71eXdIrNCAZYvoGm7wb5DgBIUQ9pRmYriGPDY4lvLTlJQYKX4jOON/6Bb0PpQ0+C5rUMqSbmixA== 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: This is a prepare to improve the demotion profiling in the later patches. Per-node demotion stats help users to quickly identify which node is in hige stree, and take some special operations if needed. Signed-off-by: Li Zhijian Acked-by: "Huang, Ying" --- include/linux/mmzone.h | 4 ++++ include/linux/vm_event_item.h | 3 --- mm/vmscan.c | 3 ++- mm/vmstat.c | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 4106fbc5b4b3..ad0309eea850 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -206,6 +206,10 @@ enum node_stat_item { #ifdef CONFIG_NUMA_BALANCING PGPROMOTE_SUCCESS, /* promote successfully */ PGPROMOTE_CANDIDATE, /* candidate pages to promote */ + /* PGDEMOTE_*: pages demoted */ + PGDEMOTE_KSWAPD, + PGDEMOTE_DIRECT, + PGDEMOTE_KHUGEPAGED, #endif NR_VM_NODE_STAT_ITEMS }; diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 8abfa1240040..d1b847502f09 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -41,9 +41,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, PGSTEAL_KSWAPD, PGSTEAL_DIRECT, PGSTEAL_KHUGEPAGED, - PGDEMOTE_KSWAPD, - PGDEMOTE_DIRECT, - PGDEMOTE_KHUGEPAGED, PGSCAN_KSWAPD, PGSCAN_DIRECT, PGSCAN_KHUGEPAGED, diff --git a/mm/vmscan.c b/mm/vmscan.c index 6f13394b112e..2f1fb4ec3235 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1678,7 +1678,8 @@ static unsigned int demote_folio_list(struct list_head *demote_folios, (unsigned long)&mtc, MIGRATE_ASYNC, MR_DEMOTION, &nr_succeeded); - __count_vm_events(PGDEMOTE_KSWAPD + reclaimer_offset(), nr_succeeded); + mod_node_page_state(NODE_DATA(target_nid), + PGDEMOTE_KSWAPD + reclaimer_offset(), nr_succeeded); return nr_succeeded; } diff --git a/mm/vmstat.c b/mm/vmstat.c index 00e81e99c6ee..f141c48c39e4 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1244,6 +1244,9 @@ const char * const vmstat_text[] = { #ifdef CONFIG_NUMA_BALANCING "pgpromote_success", "pgpromote_candidate", + "pgdemote_kswapd", + "pgdemote_direct", + "pgdemote_khugepaged", #endif /* enum writeback_stat_item counters */ @@ -1275,9 +1278,6 @@ const char * const vmstat_text[] = { "pgsteal_kswapd", "pgsteal_direct", "pgsteal_khugepaged", - "pgdemote_kswapd", - "pgdemote_direct", - "pgdemote_khugepaged", "pgscan_kswapd", "pgscan_direct", "pgscan_khugepaged", From patchwork Thu Nov 2 02:56:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13443344 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 6662EC4332F for ; Thu, 2 Nov 2023 02:57:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED3B58E0013; Wed, 1 Nov 2023 22:57:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5C8F8E0009; Wed, 1 Nov 2023 22:57:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD6EF8E0013; Wed, 1 Nov 2023 22:57:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BDC078E0009 for ; Wed, 1 Nov 2023 22:57:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9E6AF160E35 for ; Thu, 2 Nov 2023 02:57:19 +0000 (UTC) X-FDA: 81411502998.30.760EA29 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) by imf09.hostedemail.com (Postfix) with ESMTP id 4E7BD140017 for ; Thu, 2 Nov 2023 02:57:17 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf09.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.61.253 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=1698893837; 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=J9rftE7hC3AGyugrT+zGRfxywtEI4OKPAOoaaDlpups=; b=bdI9yPEKjobF0o5EgDyAp+3mRLHt35t443OtR8tzPvIkQP5wraA8SQKr9vDpGNSbfii+sr GwOCLuf+hHMhpj5VDnNcQlHtFRErTstpFLGaBjiE3I9y1zzFrADXPBiIdd/G8B8+NnGKjV Kb86is2M7pI81fgAWL921s22su89CFs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf09.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.61.253 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698893837; a=rsa-sha256; cv=none; b=mtGL9tEJwkxWfCpAab9OT3sBh4rs0p4zhwS793VanTygocuXF6E0rfDIW8TzrycMaCrx/i +ufj80vxans0yMTcXtketFIKt3N7z4q5I0nrKQOgqIfHABk3HdT266WuRx+bAWiUxSexcc 2iR+0/S0nrbRx/6EPChWL8/kO56PUDI= X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="126346049" X-IronPort-AV: E=Sophos;i="6.03,270,1694703600"; d="scan'208";a="126346049" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 11:56:58 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 0A13CD7AD5 for ; Thu, 2 Nov 2023 11:56:56 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 35BB7D4F41 for ; Thu, 2 Nov 2023 11:56:55 +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 B6C71200649E5 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 3D48C1A0072; Thu, 2 Nov 2023 10:56:54 +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 3/4] mm/vmstat: rename pgdemote_* to pgdemote_dst_* and add pgdemote_src_* Date: Thu, 2 Nov 2023 10:56:47 +0800 Message-Id: <20231102025648.1285477-4-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--0.044700-10.000000 X-TMASE-MatchedRID: s7S5NEjjqbJeDnPFO4EAX6EtILqFekmXGfZImb3fqAQG8XHns3ektTav Mpat2LKScNc4kvlfJCumDMVCgYQw4WeGWtJU0LwEuce7gFxhKa3BOVz0Jwcxl6vCrG0TnfVUEW6 ngIg0fckNkUi7wot1qoBStp5jwgJ5HxPMjOKY7A8LbigRnpKlKZx+7GyJjhAURc10OyDCZOyvXC vTsSnc8vUNzlSa+LRUIgjmxj8SpgVHij2FA3ms0pcYgvsapcWoAmnHtTPu1k0l4uLbbTGSgQrwF gFFpdiXmw0Qaktp+ussz+cQMs/Tnp75MOLIf/j3DF+QsB+Q01JoBmTSwRxjXg== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspam-User: X-Stat-Signature: tabsuhafdar7nccdbnoz7gjwfxk36uff X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4E7BD140017 X-HE-Tag: 1698893837-754509 X-HE-Meta: U2FsdGVkX18zw10EGwSs9CXSunYg9/vHSiozfbGdnA4pjUG6Z5Syi8DHr6mgjKvhzjKhuGmpc9G9eLK06aZ+YTa4i1+piB0C9+baB4rNitrdyIvwbGA8iN/qVFyGVQLya8LFZAXzMaye7PCAEpFvGqxkLg/lGDtNRDXxxsyoA5PibBgp9+eC1E88tQoTTmFGrhlOpITz1++NaSRl56hmGFZGMqvMum07A0kXUvUGh5gbS+pDG2ku0NxzPdvijYHQkHc3zTU4mrtWlSaocxcnOzJgTlZc2tTk0Wq1VlIp9mZ58qER7A21Yn2r4gXJJIJsif2qKM5Gxwhhyp+72rAMcNaaO9nd2xeD1R4PmkgB9PxEbxy0njNno3R6sbXFt0oQSFX3pbB7O1iZzZ2CaqLGKxQ/P89jhKtKu2ZojqwC30Ra7iJpkvIma5dMhQznpNMUMzFXdkStc9Dl9d1D43c80MSecM8kTZcPp82XfFPMkRkAr6MzrroQX48oanVJ8eT2wKxnpt27KwKIvxnRlotTyVJhs32mDk2pUuBwoKruzk5pOns7Xq8qhGw9PzMnLk+3YO/0G1TIvlCW5yFCWQX1TL8byHb2hXX3h2+WXaV5VmdQWHmKiqyCG6X7C5p+XtFinw6UF6iSpMXjihplh4m/ZaAnu3X5XqTFVMNtw/D/9R0K9/VGANPJgD+iwnBbSJTnvOabeNx0PZWawQC+HfThjiHw+km0mA6nM6TvgbgZcDXo6SbcCVCrNHAqERe8cDENLhuzVhy7FclLSFrd0NIBMjOjit6aYEduWJ0pqSym2nnLGTBY4r5KlOsB65HXqrH/7f4dh1h3rQiPSpt2l91CaCybLnz1BBneBTpzLhrcWQx5EnJV9Xz6WvEicYf2zkO/nlJusNerhynP8t8w69A3cmnbGhTZnHfGelSfrQ2v9k2MwtYRnVtUy0jc1HkMFVUBQ4JVouBwlm0qRixmmgn Ubi50Gjp 5NfUC8jOEEylq/85reRTAiQ/Bbg4qPe2Pq2N1LI6LMWiEQhhNXGgx3WMEEGRxTLPlyXoBV6Io47HglV29VpLm52d9FjNWY9adrCQJ8V7NiZcyb9BfCslFcKURPFCMfWAquB8BtSfGwq9Q9AXRB34jT8ct2S9MZYxx+QCCw/mD7nTVUzCzQQ43hxIIv+hNvijynjOtJfZKvFWDZAc= 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: pgdemote_src_*: pages demoted from this node. pgdemote_dst_*: pages demoted to this node. So that we are able to know their demotion per-node stats by checking this. In the environment, node0 and node1 are DRAM, node3 is PMEM. Global stats: $ grep -E 'demote' /proc/vmstat pgdemote_src_kswapd 130155 pgdemote_src_direct 113497 pgdemote_src_khugepaged 0 pgdemote_dst_kswapd 130155 pgdemote_dst_direct 113497 pgdemote_dst_khugepaged 0 Per-node stats: $ grep demote /sys/devices/system/node/node0/vmstat pgdemote_src_kswapd 68454 pgdemote_src_direct 83431 pgdemote_src_khugepaged 0 pgdemote_dst_kswapd 0 pgdemote_dst_direct 0 pgdemote_dst_khugepaged 0 $ grep demote /sys/devices/system/node/node1/vmstat pgdemote_src_kswapd 185834 pgdemote_src_direct 30066 pgdemote_src_khugepaged 0 pgdemote_dst_kswapd 0 pgdemote_dst_direct 0 pgdemote_dst_khugepaged 0 $ grep demote /sys/devices/system/node/node3/vmstat pgdemote_src_kswapd 0 pgdemote_src_direct 0 pgdemote_src_khugepaged 0 pgdemote_dst_kswapd 254288 pgdemote_dst_direct 113497 pgdemote_dst_khugepaged 0 From above stats, we know node3 is the demotion destination which one the node0 and node1 will demote to. Signed-off-by: Li Zhijian --- RFC: their names are open to discussion, maybe pgdemote_from/to_* Another defect of this patch is that, SUM(pgdemote_src_*) is always same as SUM(pgdemote_dst_*) in the global stats, shall we hide one of them. --- include/linux/mmzone.h | 9 ++++++--- mm/vmscan.c | 13 ++++++++++--- mm/vmstat.c | 9 ++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index ad0309eea850..a6140d894bec 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -207,9 +207,12 @@ enum node_stat_item { PGPROMOTE_SUCCESS, /* promote successfully */ PGPROMOTE_CANDIDATE, /* candidate pages to promote */ /* PGDEMOTE_*: pages demoted */ - PGDEMOTE_KSWAPD, - PGDEMOTE_DIRECT, - PGDEMOTE_KHUGEPAGED, + PGDEMOTE_SRC_KSWAPD, + PGDEMOTE_SRC_DIRECT, + PGDEMOTE_SRC_KHUGEPAGED, + PGDEMOTE_DST_KSWAPD, + PGDEMOTE_DST_DIRECT, + PGDEMOTE_DST_KHUGEPAGED, #endif NR_VM_NODE_STAT_ITEMS }; diff --git a/mm/vmscan.c b/mm/vmscan.c index 2f1fb4ec3235..55d2287d7150 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1111,13 +1111,18 @@ void drop_slab(void) static int reclaimer_offset(void) { BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != - PGDEMOTE_DIRECT - PGDEMOTE_KSWAPD); + PGDEMOTE_SRC_DIRECT - PGDEMOTE_SRC_KSWAPD); BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != PGSCAN_DIRECT - PGSCAN_KSWAPD); BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != - PGDEMOTE_KHUGEPAGED - PGDEMOTE_KSWAPD); + PGDEMOTE_SRC_KHUGEPAGED - PGDEMOTE_SRC_KSWAPD); BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != PGSCAN_KHUGEPAGED - PGSCAN_KSWAPD); + BUILD_BUG_ON(PGDEMOTE_SRC_DIRECT - PGDEMOTE_SRC_KSWAPD != + PGDEMOTE_DST_DIRECT - PGDEMOTE_DST_KSWAPD); + BUILD_BUG_ON(PGDEMOTE_SRC_KHUGEPAGED - PGDEMOTE_SRC_KSWAPD != + PGDEMOTE_DST_KHUGEPAGED - PGDEMOTE_DST_KSWAPD); + if (current_is_kswapd()) return 0; @@ -1678,8 +1683,10 @@ static unsigned int demote_folio_list(struct list_head *demote_folios, (unsigned long)&mtc, MIGRATE_ASYNC, MR_DEMOTION, &nr_succeeded); + mod_node_page_state(pgdat, + PGDEMOTE_SRC_KSWAPD + reclaimer_offset(), nr_succeeded); mod_node_page_state(NODE_DATA(target_nid), - PGDEMOTE_KSWAPD + reclaimer_offset(), nr_succeeded); + PGDEMOTE_DST_KSWAPD + reclaimer_offset(), nr_succeeded); return nr_succeeded; } diff --git a/mm/vmstat.c b/mm/vmstat.c index f141c48c39e4..63f106a5e008 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1244,9 +1244,12 @@ const char * const vmstat_text[] = { #ifdef CONFIG_NUMA_BALANCING "pgpromote_success", "pgpromote_candidate", - "pgdemote_kswapd", - "pgdemote_direct", - "pgdemote_khugepaged", + "pgdemote_src_kswapd", + "pgdemote_src_direct", + "pgdemote_src_khugepaged", + "pgdemote_dst_kswapd", + "pgdemote_dst_direct", + "pgdemote_dst_khugepaged", #endif /* enum writeback_stat_item counters */ From patchwork Thu Nov 2 02:56:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13443346 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 D147CC4167D for ; Thu, 2 Nov 2023 02:57:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BD948E0015; Wed, 1 Nov 2023 22:57:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 647168E0009; Wed, 1 Nov 2023 22:57:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C1778E0015; Wed, 1 Nov 2023 22:57:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3D3028E0009 for ; Wed, 1 Nov 2023 22:57:37 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 19AFD120DE2 for ; Thu, 2 Nov 2023 02:57:37 +0000 (UTC) X-FDA: 81411503754.22.3833BC3 Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by imf28.hostedemail.com (Postfix) with ESMTP id B9939C001A for ; Thu, 2 Nov 2023 02:57:34 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf28.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.137 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=1698893855; 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=+2lMwW7x0CNbqVvfeKF1nYASQsLMHIaL2xereHi1onc=; b=1mjTfgenjIN7x6XbuW+h3o3JS8mZRiG2Eg8Z/QmsgtcMuw6sd/f9Hpl8dSl/6486KqjU/V G5OidtJU0EyxHdZV8vSdcCMnKOqP6WHVrxiZgdoKAh7BOIqxRMboWm0YjN3689jYBQUcgV BnonwV+BvWtawYRZj0vkclEmFVGWTDM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf28.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.137 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698893855; a=rsa-sha256; cv=none; b=G8h8eydgsX0xawulsMP9U6hmgNFL4ArpL2u30LT36FX6bKgGmB9/UdzKsoY1fw/iR1Z4s/ MYmWk6EiexjjzJutII2IJRmfhSWePGxIDJjQgaOnyn5pEueU+u+va3bgMS0/R3lSUN9IG/ tBJG/3CG6NrD3SLNzQ+KQtrx5mKi6To= X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="117752860" X-IronPort-AV: E=Sophos;i="6.03,270,1694703600"; d="scan'208";a="117752860" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 11:57:00 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 5D66AD5026 for ; Thu, 2 Nov 2023 11:56:56 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 8A5CFD3F38 for ; Thu, 2 Nov 2023 11:56:55 +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 19724200649DE for ; Thu, 2 Nov 2023 11:56:55 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 966A41A0071; Thu, 2 Nov 2023 10:56:54 +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 4/4] drivers/base/node: add demote_src and demote_dst to numastat Date: Thu, 2 Nov 2023 10:56:48 +0800 Message-Id: <20231102025648.1285477-5-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--2.607700-10.000000 X-TMASE-MatchedRID: RtHHqK+8YWMx3g1BjbXsyArcxrzwsv5u5bMmdOYs/G/rix/QSCPuKr8F Hrw7frluf146W0iUu2tDc4lSgrowpdTgNUieJDkRSs47mbT7SARSuvtBzlaEqE+la3/T6ykP3YW HdXsKykrMyBGHVXFUDoAy6p60ZV62fJ5/bZ6npdjGVuWouVipcljVOVbGM+bZD1Vdt6kw28OKCz o1BkkvYAIiqmLQ6JLHOV0z0B/FQt8PnX3Fui/kjKo9VQLNxdGdSpvPBwsoXEYd/XNGPTZXaRFlt GxCTkwFQHVA+r1vGdZmQDEDCMiuswfP8fSSIvISoYC0cwOOST0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspam-User: X-Stat-Signature: xx8xu6aauoje5uda8hq89zcpi5rpxxta X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B9939C001A X-HE-Tag: 1698893854-631595 X-HE-Meta: U2FsdGVkX19NXQeyJKmEWrrHHwOnPy75/S1HWaxgaHja6NrdU+Cq3u4ihQXlXD42gq6vUWkqJaWfxKcQa1Mq8bUGLJSySzohsDFl7AT3jVKnQPastd8XX5oUxU9etKTHlZITgcLYuRFIyh+VPwtoXVrQpn6tcpZjgQQwkTMg45tH0EMK62xdCgVwF5wfFKqUkw/uP+2hxJh0oekDGrwXfZwO7PkLvXphTmdlWHjLP5NkytK6kt+CfReqtsBkSl6yHMfeVx2jkZ0CIzUm/P7skiTZbRoCSipVRGBoDiMno9F/Ybv+kcYNXZKh07uXhAGJ/opXjUxE4uqyGWDPnEGNYgZhrAassS6eyr+UTiA+zcAjZ5Ahnw64YDXELn/KjPDcuH7rdjEwHPZZkiH9bgmjzi8Yk0YLPWKW13BlE+mwGkgS/7XGPWRldc649TvHln3AlT2Joy79iFFzWdtYF7uFjN5dtYJgICGPPs0CFD1AuVXVBXW/LlvJ+GhHwTexgeY3Kxsj5e4Krz+4j5Zp8NQiqjgLGxoE/MVA/ywjyyQ0DuQLxUj1+vQfrrYYWL0fK+SnkXtUR7Wjd70gy/WTHohCRqvtHD1trNonnXd7WZ/tS3t7RuildU3aSXD32ve8COMu/hldK522CSVxJp1L4Y2qgAI8JtDxRpoHjmdMazlJnomkC9SL7Ob5hZsF+bvK6LZdMu5APef/WmrR8awQDGLwE3EN58/vmDqqjbjWkRahNVRZ7HWysPP48bKlkKPXQ7hhOaFfFcJuukq7yFStc7N7ndIRTJOWwaKUguqhlPb6gKbfFSm6hviA/JEThawuzvczsXPWZZrSME+7/YMSqQ7SRf0R02plJXLgszgU2VcYPWyh8+VK/bRWf0lJ6/UEQ9zvFk82P+E/SRKVi2wD6B0aDB6CLTBb0r5W3BqwJFSGd+pYStqlcU9W9QUQviwzsg1dG0QnmUAgsD6fRHpDmt2 3YLSdXgx jnSOFY+6FBHzHFnFGE450NesZOqr+blm/OlNkqJIj1x7NoAdzLvddX4gN59/nXJ00j54KMQUcmmx9ZriCIbbiNQRjTy4jHw/w5dqNAN93kBLhnFUPMjcAbDOpfgcICl2t40mdKldqh0OrItg7rY4EQeXNCqKMkbMEy+KBKrX47Iw6rOq9nzmMfvb+/QNloyeZdSq9agbCAWI0ipE= 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: node0 and node1 is DRAM node, node3 is a PMEM node. $ cat /sys/devices/system/node/node1/numastat numa_hit 646590 numa_miss 3963 numa_foreign 30651 interleave_hit 416 local_node 645252 other_node 5301 demote_src 200478 demote_dst 0 Of cousre, the userspace numastat will be extened to support these 2 new fields in the future like: $ numastat node0 node1 node3 numa_hit 741793 702460 364154 numa_miss 1759 8104 28893 numa_foreign 8105 30651 0 interleave_hit 653 416 0 local_node 741762 701115 0 other_node 1790 9449 393047 demote_src 163612 203828 0 demote_dst 0 0 367440 Signed-off-by: Li Zhijian --- drivers/base/node.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 27e8502548a7..d3fc70599b6a 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -496,20 +496,32 @@ static DEVICE_ATTR(meminfo, 0444, node_read_meminfo, NULL); static ssize_t node_read_numastat(struct device *dev, struct device_attribute *attr, char *buf) { + struct pglist_data *pgdat = NODE_DATA(dev->id); + unsigned long demote_src, demote_dst; + fold_vm_numa_events(); + demote_src = node_page_state_pages(pgdat, PGDEMOTE_SRC_KSWAPD) + + node_page_state_pages(pgdat, PGDEMOTE_SRC_DIRECT) + + node_page_state_pages(pgdat, PGDEMOTE_SRC_KHUGEPAGED); + demote_dst = node_page_state_pages(pgdat, PGDEMOTE_DST_KSWAPD) + + node_page_state_pages(pgdat, PGDEMOTE_DST_DIRECT) + + node_page_state_pages(pgdat, PGDEMOTE_DST_KHUGEPAGED); return sysfs_emit(buf, "numa_hit %lu\n" "numa_miss %lu\n" "numa_foreign %lu\n" "interleave_hit %lu\n" "local_node %lu\n" - "other_node %lu\n", + "other_node %lu\n" + "demote_src %lu\n" + "demote_dst %lu\n", sum_zone_numa_event_state(dev->id, NUMA_HIT), sum_zone_numa_event_state(dev->id, NUMA_MISS), sum_zone_numa_event_state(dev->id, NUMA_FOREIGN), sum_zone_numa_event_state(dev->id, NUMA_INTERLEAVE_HIT), sum_zone_numa_event_state(dev->id, NUMA_LOCAL), - sum_zone_numa_event_state(dev->id, NUMA_OTHER)); + sum_zone_numa_event_state(dev->id, NUMA_OTHER), + demote_src, demote_dst); } static DEVICE_ATTR(numastat, 0444, node_read_numastat, NULL);