Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

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: Li Zhijian <lizhijian@fujitsu.com>
Acked-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Li Zhijian and committed by
Andrew Morton
23e9f013 0c92218f

+15 -10
+4
include/linux/mmzone.h
··· 206 206 #ifdef CONFIG_NUMA_BALANCING 207 207 PGPROMOTE_SUCCESS, /* promote successfully */ 208 208 PGPROMOTE_CANDIDATE, /* candidate pages to promote */ 209 + /* PGDEMOTE_*: pages demoted */ 210 + PGDEMOTE_KSWAPD, 211 + PGDEMOTE_DIRECT, 212 + PGDEMOTE_KHUGEPAGED, 209 213 #endif 210 214 NR_VM_NODE_STAT_ITEMS 211 215 };
-3
include/linux/vm_event_item.h
··· 41 41 PGSTEAL_KSWAPD, 42 42 PGSTEAL_DIRECT, 43 43 PGSTEAL_KHUGEPAGED, 44 - PGDEMOTE_KSWAPD, 45 - PGDEMOTE_DIRECT, 46 - PGDEMOTE_KHUGEPAGED, 47 44 PGSCAN_KSWAPD, 48 45 PGSCAN_DIRECT, 49 46 PGSCAN_KHUGEPAGED,
+8 -4
mm/vmscan.c
··· 409 409 410 410 static int reclaimer_offset(void) 411 411 { 412 + #ifdef CONFIG_NUMA_BALANCING 412 413 BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != 413 414 PGDEMOTE_DIRECT - PGDEMOTE_KSWAPD); 414 - BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != 415 - PGSCAN_DIRECT - PGSCAN_KSWAPD); 416 415 BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != 417 416 PGDEMOTE_KHUGEPAGED - PGDEMOTE_KSWAPD); 417 + #endif 418 + BUILD_BUG_ON(PGSTEAL_DIRECT - PGSTEAL_KSWAPD != 419 + PGSCAN_DIRECT - PGSCAN_KSWAPD); 418 420 BUILD_BUG_ON(PGSTEAL_KHUGEPAGED - PGSTEAL_KSWAPD != 419 421 PGSCAN_KHUGEPAGED - PGSCAN_KSWAPD); 420 422 ··· 978 976 migrate_pages(demote_folios, alloc_demote_folio, NULL, 979 977 (unsigned long)&mtc, MIGRATE_ASYNC, MR_DEMOTION, 980 978 &nr_succeeded); 981 - 982 - __count_vm_events(PGDEMOTE_KSWAPD + reclaimer_offset(), nr_succeeded); 979 + #ifdef CONFIG_NUMA_BALANCING 980 + mod_node_page_state(pgdat, PGDEMOTE_KSWAPD + reclaimer_offset(), 981 + nr_succeeded); 982 + #endif 983 983 984 984 return nr_succeeded; 985 985 }
+3 -3
mm/vmstat.c
··· 1248 1248 #ifdef CONFIG_NUMA_BALANCING 1249 1249 "pgpromote_success", 1250 1250 "pgpromote_candidate", 1251 + "pgdemote_kswapd", 1252 + "pgdemote_direct", 1253 + "pgdemote_khugepaged", 1251 1254 #endif 1252 1255 1253 1256 /* enum writeback_stat_item counters */ ··· 1282 1279 "pgsteal_kswapd", 1283 1280 "pgsteal_direct", 1284 1281 "pgsteal_khugepaged", 1285 - "pgdemote_kswapd", 1286 - "pgdemote_direct", 1287 - "pgdemote_khugepaged", 1288 1282 "pgscan_kswapd", 1289 1283 "pgscan_direct", 1290 1284 "pgscan_khugepaged",