From 17915bb6dfead184802f7b88ee007723dcf4a549 Mon Sep 17 00:00:00 2001 From: Johannes Weiner Date: Wed, 3 Jun 2020 16:02:34 -0700 Subject: [PATCH 2361/2944] mm: keep separate anon and file statistics on page reclaim activity task #31256938 commit 497a6c1b09902b22ceccc0f25ba4dd623e1ddb7d upstream Having statistics on pages scanned and pages reclaimed for both anon and file pages makes it easier to evaluate changes to LRU balancing. While at it, clean up the stat-keeping mess for isolation, putback, reclaim stats etc. a bit: first the physical LRU operation (isolation and putback), followed by vmstats, reclaim_stats, and then vm events. Signed-off-by: Johannes Weiner Signed-off-by: Andrew Morton Cc: Joonsoo Kim Cc: Michal Hocko Cc: Minchan Kim Cc: Rik van Riel Link: http://lkml.kernel.org/r/20200520232525.798933-3-hannes@cmpxchg.org Signed-off-by: Linus Torvalds Signed-off-by: zhongjiang-ali Reviewed-by: Xunlei Pang --- include/linux/vm_event_item.h | 4 ++++ mm/vmscan.c | 13 +++++++------ mm/vmstat.c | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 47a3441..6143858 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -35,6 +35,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, PGSCAN_KSWAPD, PGSCAN_DIRECT, PGSCAN_DIRECT_THROTTLE, + PGSCAN_ANON, + PGSCAN_FILE, + PGSTEAL_ANON, + PGSTEAL_FILE, #ifdef CONFIG_NUMA PGSCAN_ZONE_RECLAIM_FAILED, #endif diff --git a/mm/vmscan.c b/mm/vmscan.c index e42c3dc..1858903 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1881,7 +1881,7 @@ static int current_may_throttle(void) unsigned long nr_taken; struct reclaim_stat stat = {}; isolate_mode_t isolate_mode = 0; - int file = is_file_lru(lru); + bool file = is_file_lru(lru); struct pglist_data *pgdat = lruvec_pgdat(lruvec); struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; bool stalled = false; @@ -1911,7 +1911,6 @@ static int current_may_throttle(void) __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, nr_taken); reclaim_stat->recent_scanned[file] += nr_taken; - if (current_is_kswapd()) { if (!cgroup_reclaim(sc)) __count_vm_events(PGSCAN_KSWAPD, nr_scanned); @@ -1923,6 +1922,8 @@ static int current_may_throttle(void) count_memcg_events(lruvec_memcg(lruvec), PGSCAN_DIRECT, nr_scanned); } + __count_vm_events(PGSCAN_ANON + file, nr_scanned); + spin_unlock_irq(&pgdat->lru_lock); if (nr_taken == 0) @@ -1933,6 +1934,9 @@ static int current_may_throttle(void) spin_lock_irq(&pgdat->lru_lock); + putback_inactive_pages(lruvec, &page_list); + + __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); if (current_is_kswapd()) { if (!cgroup_reclaim(sc)) __count_vm_events(PGSTEAL_KSWAPD, nr_reclaimed); @@ -1944,10 +1948,7 @@ static int current_may_throttle(void) count_memcg_events(lruvec_memcg(lruvec), PGSTEAL_DIRECT, nr_reclaimed); } - - putback_inactive_pages(lruvec, &page_list); - - __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); + __count_vm_events(PGSTEAL_ANON + file, nr_reclaimed); spin_unlock_irq(&pgdat->lru_lock); diff --git a/mm/vmstat.c b/mm/vmstat.c index 8fec4a1..cb13fac 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1212,6 +1212,10 @@ int fragmentation_index(struct zone *zone, unsigned int order) "pgscan_kswapd", "pgscan_direct", "pgscan_direct_throttle", + "pgscan_anon", + "pgscan_file", + "pgsteal_anon", + "pgsteal_file", #ifdef CONFIG_NUMA "zone_reclaim_failed", -- 1.8.3.1