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

mm: keep separate anon and file statistics on page reclaim activity

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 <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Link: http://lkml.kernel.org/r/20200520232525.798933-3-hannes@cmpxchg.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Johannes Weiner and committed by
Linus Torvalds
497a6c1b 5df74196

+17 -8
+4
include/linux/vm_event_item.h
··· 35 35 PGSCAN_KSWAPD, 36 36 PGSCAN_DIRECT, 37 37 PGSCAN_DIRECT_THROTTLE, 38 + PGSCAN_ANON, 39 + PGSCAN_FILE, 40 + PGSTEAL_ANON, 41 + PGSTEAL_FILE, 38 42 #ifdef CONFIG_NUMA 39 43 PGSCAN_ZONE_RECLAIM_FAILED, 40 44 #endif
+9 -8
mm/vmscan.c
··· 1913 1913 unsigned int nr_reclaimed = 0; 1914 1914 unsigned long nr_taken; 1915 1915 struct reclaim_stat stat; 1916 - int file = is_file_lru(lru); 1916 + bool file = is_file_lru(lru); 1917 1917 enum vm_event_item item; 1918 1918 struct pglist_data *pgdat = lruvec_pgdat(lruvec); 1919 1919 struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; ··· 1941 1941 1942 1942 __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, nr_taken); 1943 1943 reclaim_stat->recent_scanned[file] += nr_taken; 1944 - 1945 1944 item = current_is_kswapd() ? PGSCAN_KSWAPD : PGSCAN_DIRECT; 1946 1945 if (!cgroup_reclaim(sc)) 1947 1946 __count_vm_events(item, nr_scanned); 1948 1947 __count_memcg_events(lruvec_memcg(lruvec), item, nr_scanned); 1948 + __count_vm_events(PGSCAN_ANON + file, nr_scanned); 1949 + 1949 1950 spin_unlock_irq(&pgdat->lru_lock); 1950 1951 1951 1952 if (nr_taken == 0) ··· 1957 1956 1958 1957 spin_lock_irq(&pgdat->lru_lock); 1959 1958 1959 + move_pages_to_lru(lruvec, &page_list); 1960 + 1961 + __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); 1962 + reclaim_stat->recent_rotated[0] += stat.nr_activate[0]; 1963 + reclaim_stat->recent_rotated[1] += stat.nr_activate[1]; 1960 1964 item = current_is_kswapd() ? PGSTEAL_KSWAPD : PGSTEAL_DIRECT; 1961 1965 if (!cgroup_reclaim(sc)) 1962 1966 __count_vm_events(item, nr_reclaimed); 1963 1967 __count_memcg_events(lruvec_memcg(lruvec), item, nr_reclaimed); 1964 - reclaim_stat->recent_rotated[0] += stat.nr_activate[0]; 1965 - reclaim_stat->recent_rotated[1] += stat.nr_activate[1]; 1966 - 1967 - move_pages_to_lru(lruvec, &page_list); 1968 - 1969 - __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); 1968 + __count_vm_events(PGSTEAL_ANON + file, nr_reclaimed); 1970 1969 1971 1970 spin_unlock_irq(&pgdat->lru_lock); 1972 1971
+4
mm/vmstat.c
··· 1203 1203 "pgscan_kswapd", 1204 1204 "pgscan_direct", 1205 1205 "pgscan_direct_throttle", 1206 + "pgscan_anon", 1207 + "pgscan_file", 1208 + "pgsteal_anon", 1209 + "pgsteal_file", 1206 1210 1207 1211 #ifdef CONFIG_NUMA 1208 1212 "zone_reclaim_failed",