From patchwork Fri Nov 3 03:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13444288 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 E966BC4332F for ; Fri, 3 Nov 2023 03:15:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CBA68D00B5; Thu, 2 Nov 2023 23:15:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 754C58D000F; Thu, 2 Nov 2023 23:15:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CF018D00B5; Thu, 2 Nov 2023 23:15:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4A8218D000F for ; Thu, 2 Nov 2023 23:15:10 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1E97080366 for ; Fri, 3 Nov 2023 03:15:10 +0000 (UTC) X-FDA: 81415176780.12.2A87F57 Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) by imf08.hostedemail.com (Postfix) with ESMTP id C42E216000F for ; Fri, 3 Nov 2023 03:15:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.47 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698981308; a=rsa-sha256; cv=none; b=iBW+ZmIv/84AmPHznuLyRjYXAPxLq7WXZPRrVrpk/EdkRHStO/8oU8kUrigfzdFL3pfh4W MdpceFN/k85G9lvFBQqn9yV0+/88Agjj9Vc7nckvW7lZzmtWgb3XFwV8pwzjjqnTGS6KF6 KbntvQ5l+MNSIgB9MFaDVWT3P+ykSU8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.47 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698981308; 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; bh=v7WIbRGzYlTYWJ0DDpDU6+kGB4kRtio2UMaEiWCWxHw=; b=yxESN6hpNKaasUTvF/KMQtPjezzY9FaAUxkJ6wXIW8cHnSFo+hIKzHpkSsMmPZzhTdrs6w haM+9y4eKTBjfg0wDQ0H0hTKh+1iQq3K6AFOlpbUelufD91SUV3ipK3VMWLv87wIRxxRg9 0uYg4TtUD9Grh8rGIPKCjXG+ee0Dp7E= X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="138267539" X-IronPort-AV: E=Sophos;i="6.03,273,1694703600"; d="scan'208";a="138267539" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 12:15:05 +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 4E027D7AD5 for ; Fri, 3 Nov 2023 12:15:03 +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 7E8CED88CF for ; Fri, 3 Nov 2023 12:15: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 0B92B200649DE for ; Fri, 3 Nov 2023 12:15:02 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 16C431A0071; Fri, 3 Nov 2023 11:15:00 +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 , kernel test robot Subject: [PATCH v2] mm/vmstat: Move pgdemote_* to per-node stats Date: Fri, 3 Nov 2023 11:14:50 +0800 Message-Id: <20231103031450.1456523-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-27974.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27974.004 X-TMASE-Result: 10--10.827300-10.000000 X-TMASE-MatchedRID: xt1fvVgCaAxeJRw5hj8/hKEtILqFekmXN/BTU5ZfZRLL/AT90ZKK1/+E Jgno/UyCSpLsaBDNZu/6/M7RNQTVFxRHYhNSCATTa87CDXaKRVIYQYFQ2+HwYGO0yVK/5LmcJrq OKTQyDL6gvsHUO6oCqMz43V5/DvDfKd6blBoO65y5x7uAXGEprcE5XPQnBzGXq8KsbROd9VQRbq eAiDR9yQ2RSLvCi3WqSV0yV+LvIB/5TMpCPkA1z54CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyH4gK q42LRYknP7hJyr6BRTsPSCeQ5fhxHByY+xbtD7YpBPVKrePf6R+3BndfXUhXQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C42E216000F X-Stat-Signature: sewdowci6ma19b8pgqcx5kedi1y9eehx X-HE-Tag: 1698981307-982959 X-HE-Meta: U2FsdGVkX18R+EJx2BxlWTmOvIXlGeu07LAA63/YGrSfJo3UGr8LyXMMMHp7MdeNR/7MTG+PJeMPZK/p3PpyODNc/YFaCijqqcf/84i0F7BiuE04Rg/fF3U8J8yGMmN3zCMyLjrjPX6ieQ3HK+Pgfvq2EOjJfG/hN3hT+atgoRld0Y23XCoGbCWlkSrWLwgePj4dQtBkoXlY9hzqeSKPYGQMcxo0a/G0fAK7vYBFMz0AfPR2CMkuqSrGK4tPzNIPqesqFoGJZkgNSJYLacP/I4F2HMcB6v9b6jq7Iaxp2ydciD6Af6qmgqRjdyosdHnDrs11u0lWC48JGRV5lm3T9sS0zyut20XDqUHiGs6/OcXmuW0088LjB/03rgDmBHkptDL4heSDRydMLZvJFyL857Svw30SUd5jlUmdoh0Mf8S1IjNZ4RFTTrHZaXsK8eprsZlp9qCGgAiB3q1lto22iyt32oIN7eLUHlADoQdI03nKsUfV3f9oXj7YkEbw3q2jaeGeIxT+z9prUI3S0VUH1SX3qf0B+KTIE5F5XGHxUQeOiMSGTyRk8YrG4Mhnjmx/j33qPoeEwZtJXk5RRqBiYBG8dOOkX96IEGY7elf6/P8Ut4EE9UAghOF2ZcjUPIzD0H6kaR+pm1fznXjrGz5FzN1LpGubAdetqzx+lcAc+TC9BYY8DR7HSoA5VtiUqNRQud/FBQ9QGnZJEtG/gxJ+XtfaDXwQbKRVayhjMS/9/IGHGJ+S/qKTxcwR2Dz3BxCHcUH5pmag+V/Uf/RKPe+1x91SjNW9tjKi5ZHHc3PP82i7YlpIX93ozF6kLahBz9V/wJXzW086j14m9RSF5hpkaKVDvU0o32TvpZz3MKdcrOjUowyYfISC3+Z0D1Rwaq9q8bSGdv9zucNhdNo2Xv1Wjqzt74XAxN0HO9QF7swqLeO7ped27q6c1JEdIEjNuCkkdNrs/3I8+z0j8nZpbl8 OOcoruHJ PAmkBzb9dnBOBtMty6lh5w8r00iaWV0yLhn3nY/tAUXTgecJ/Jr0nnos66dsY5ShQ1Lehnii8n7Jre7tnJEOvV3KrEkUaoo3Hy6hfPRSWDefMHQB/HatLUG0YOT7qhZ1OxIKDJx54qkw6LSXv/nrm2xsPC1NaNtfIZhtj8GNfsTzlAxUadg0n7jN2YxOtUeqJ2/z+iZ773KvSMrXiXCiJOfJd0qk39GdGpUw9n/cL8QLPRd+U7wuDF+zLCbfyNleAQL9uhUEguDtYJLwhVZuk+UjKbE2dA9/0c9wT 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: Demotion will migrate pages across nodes. Previously, only the global demotion statistics were accounted for. Changed them to per-node statistics, making it easier to observe where demotion occurs on each node. This will help to identify which nodes are under pressure. This patch also make pgdemote_* behind CONFIG_NUMA_BALANCING, since demotion is not available for !CONFIG_NUMA_BALANCING With this patch, here is a sample where node0 node1 are DRAM, node3 is PMEM: Global stats: $ grep demote /proc/vmstat pgdemote_kswapd 254288 pgdemote_direct 113497 pgdemote_khugepaged 0 Per-node stats: $ grep demote /sys/devices/system/node/node0/vmstat # demotion source pgdemote_kswapd 68454 pgdemote_direct 83431 pgdemote_khugepaged 0 $ grep demote /sys/devices/system/node/node1/vmstat # demotion source pgdemote_kswapd 185834 pgdemote_direct 30066 pgdemote_khugepaged 0 $ grep demote /sys/devices/system/node/node3/vmstat # demotion target pgdemote_kswapd 0 pgdemote_direct 0 pgdemote_khugepaged 0 Reported-by: kernel test robot # compling errors Closes: https://lore.kernel.org/oe-kbuild-all/202311030137.Vu2ki6zm-lkp@intel.com/ Acked-by: "Huang, Ying" Signed-off-by: Li Zhijian --- V2: split it as a separate patch from previous patch set. account them to the source node instead destination and add Acked-by # Huang, Ying --- include/linux/mmzone.h | 4 ++++ include/linux/vm_event_item.h | 3 --- mm/vmscan.c | 12 ++++++++---- mm/vmstat.c | 6 +++--- 4 files changed, 15 insertions(+), 10 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..cc70dcefc60a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1110,12 +1110,14 @@ void drop_slab(void) static int reclaimer_offset(void) { +#ifdef CONFIG_NUMA_BALANCING BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != PGDEMOTE_DIRECT - PGDEMOTE_KSWAPD); - BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != - PGSCAN_DIRECT - PGSCAN_KSWAPD); BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != PGDEMOTE_KHUGEPAGED - PGDEMOTE_KSWAPD); +#endif + BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != + PGSCAN_DIRECT - PGSCAN_KSWAPD); BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != PGSCAN_KHUGEPAGED - PGSCAN_KSWAPD); @@ -1677,8 +1679,10 @@ static unsigned int demote_folio_list(struct list_head *demote_folios, migrate_pages(demote_folios, alloc_demote_folio, NULL, (unsigned long)&mtc, MIGRATE_ASYNC, MR_DEMOTION, &nr_succeeded); - - __count_vm_events(PGDEMOTE_KSWAPD + reclaimer_offset(), nr_succeeded); +#ifdef CONFIG_NUMA_BALANCING + mod_node_page_state(pgdat, PGDEMOTE_KSWAPD + reclaimer_offset(), + nr_succeeded); +#endif 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",