Commit b1689282 authored by Li Zhijian's avatar Li Zhijian Committed by Peng Zhang
Browse files

mm/vmstat: move pgdemote_* to per-node stats

mainline inclusion
from mainline-v6.8-rc1
commit 23e9f0138963ceef2a252d887534923a0502b2da
category: other
bugzilla: https://gitee.com/openeuler/kernel/issues/I8YBMI

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=23e9f0138963ceef2a252d887534923a0502b2da

--------------------------------

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

Link: https://lkml.kernel.org/r/20231103031450.1456523-1-lizhijian@fujitsu.com


Signed-off-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
Acked-by: default avatar"Huang, Ying" <ying.huang@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent ac589cc5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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
};
+0 −3
Original line number Diff line number Diff line
@@ -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,
+8 −4
Original line number Diff line number Diff line
@@ -1114,12 +1114,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);

@@ -1681,8 +1683,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;
}
+3 −3
Original line number Diff line number Diff line
@@ -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",