[PATCH 0/2] introduce new perf-script page-reclaim

From: Yafang Shao
Date: Wed Sep 18 2019 - 10:39:04 EST


A new perf script page-reclaim is introduced in this patchset.
This new script is used to report the page reclaim details. The possible
usage of this script is as bellow,
- identify latency spike caused by direct reclaim
- whehter the latency spike is relevant with pageout
- why is page reclaim requested, i.e. whether it is because of memory
fragmentation
- page reclaim efficiency
etc
In the future we may also enhance it to analyze the memcg reclaim.

Bellow is how to use this script,
# Record, one of the following
$ perf record -e 'vmscan:mm_vmscan_*' ./workload
$ perf script record page-reclaim

# Report
$ perf script report page-reclaim

# Report per process latency
$ perf script report page-reclaim -- -p

# Report per process latency details. At what time and how long it
# stalls at each time.
$ perf script report page-reclaim -- -v

An example of the script's report,
$ perf script report page-reclaim
Direct reclaims: 4924
Direct latency (ms) total max avg min
177823.211 6378.977 36.114 0.051
Direct file reclaimed 22920
Direct file scanned 28306
Direct file sync write I/O 0
Direct file async write I/O 0
Direct anon reclaimed 212567
Direct anon scanned 1446854
Direct anon sync write I/O 0
Direct anon async write I/O 278325
Direct order 0 1 3
4870 23 31
Wake kswapd requests 716
Wake order 0 1
715 1

Kswapd reclaims: 9
Kswapd latency (ms) total max avg min
86353.046 42128.816 9594.783 120.736
Kswapd file reclaimed 366461
Kswapd file scanned 369554
Kswapd file sync write I/O 0
Kswapd file async write I/O 0
Kswapd anon reclaimed 362594
Kswapd anon scanned 693938
Kswapd anon sync write I/O 0
Kswapd anon async write I/O 330663
Kswapd order 0 1 3
3 1 5
Kswapd re-wakes 705

Per process latency (ms):
pid[comm] total max avg min
timestamp latency(ns)
1[systemd] 276.764 248.933 21.29 0.293
3406860552338: 16819800
3406877381650: 5532855
3407458799399: 929517
3407459796042: 916682
3407460763220: 418989
3407461250236: 332355
3407461637534: 401731
3407462092234: 449219
3407462605855: 292857
3407462952343: 372700
3407463364947: 414880
3407463829547: 949162
3407464813883: 248933444
163[kswapd0] 86353.046 42128.816 9594.783 120.736
3357637025977: 1026962745
3358915619888: 41268642175
3400239664127: 42128816204
3443784780373: 679641989
3444847948969: 120735792
3445001978784: 342713657
3445835850664: 316851589
3446865035476: 247457873
3449355401352: 221223878
...

This script must be in sync with bellow vmscan tracepoints,
mm_vmscan_direct_reclaim_begin
mm_vmscan_direct_reclaim_end
mm_vmscan_kswapd_wake
mm_vmscan_kswapd_sleep
mm_vmscan_wakeup_kswapd
mm_vmscan_lru_shrink_inactive
mm_vmscan_writepage

Currently there's no easy way to make perf scripts in sync with
tracepoints. One possible way is to run perf's tests regularly, another way
is once we changes the definitions of tracepoints we must keep in mind that
the perf scripts which are using these tracepoints must be changed as well.
So I add some comment for the new introduced page-reclaim script as a
reminder.

Yafang Shao (2):
perf script python: integrate page reclaim analyze script
tracing, vmscan: add comments for perf script page-reclaim

include/trace/events/vmscan.h | 15 +-
tools/perf/scripts/python/bin/page-reclaim-record | 2 +
tools/perf/scripts/python/bin/page-reclaim-report | 4 +
tools/perf/scripts/python/page-reclaim.py | 378 ++++++++++++++++++++++
4 files changed, 398 insertions(+), 1 deletion(-)
create mode 100644 tools/perf/scripts/python/bin/page-reclaim-record
create mode 100644 tools/perf/scripts/python/bin/page-reclaim-report
create mode 100644 tools/perf/scripts/python/page-reclaim.py

--
1.8.3.1