perf script/python: add new compaction-times script
PATCH 1/1 perf script/python: add new compaction-times script
This patch creates a new script (compaction-times) to report time spent in mm compaction. Report times in nanoseconds (default) or microseconds (-u). Option -p will break down times by process id, -pv will further decompose by each compaction entry/exit. Entries may be further filtered by pid, pid-range or comm (regex).
The script is useful when analysing workloads that compact memory. The most common example will be THP allocations on systems with a lot of uptime that has fragmented memory. This is an example of using the script to analyse a thpscale from mmtests which deliberately fragments memory and allocates THP in 4 separate threads
# Recording step, one of the following;
$ perf record -e 'compaction:mm_compaction_*' ./workload $ perf script record compaction-times
# Reporting: basic
$ perf script report compaction-times total: 15825912302ns (1416084 migrated 160674 failed)
# Reporting: Per task stall times
$ perf script report compaction-times -- -p total: 15825912302ns (1416084 migrated 160674 failed) 5024[thpscale]: 2588338168ns (476189 migrated 32 failed) 5025[thpscale]: 2469205861ns (460767 migrated 7 failed) 5026[thpscale]: 8246032631ns (659 migrated 160621 failed) 5023[thpscale]: 2522335642ns (478469 migrated 14 failed)
# Reporting: Per-compaction attempt broken down by task
$ perf script report compaction-times -- -pv total: 15825912302ns (1416084 migrated 160674 failed) 5024[thpscale]: 2588338168ns (476189 migrated 32 failed) 5024[thpscale].1: 3549721ns (352 migrated 0 failed) 5024[thpscale].2: 173091ns (32 migrated 0 failed) 5024[thpscale].3: 695548ns (160 migrated 0 failed) 5024[thpscale].4: 138561ns (32 migrated 0 failed) 5024[thpscale].5: 1123068ns (224 migrated 0 failed) 5024[thpscale].6: 163610ns (32 migrated 0 failed) ..... output continues ...
--- .../scripts/python/bin/compaction-times-record | 2 + .../scripts/python/bin/compaction-times-report | 4 + tools/perf/scripts/python/compaction-times.py | 219 +++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 tools/perf/scripts/python/bin/compaction-times-record create mode 100644 tools/perf/scripts/python/bin/compaction-times-report create mode 100644 tools/perf/scripts/python/compaction-times.py
tools/perf/scripts/python/bin/compaction-times-record new file +2 -0
@@ -0,0 +1,2 @@ +#!/bin/bash +perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages $@
tools/perf/scripts/python/bin/compaction-times-report new file +4 -0
@@ -0,0 +1,4 @@ +#!/bin/bash +#description: display time taken by mm compaction +#args: [-p|-pv] [-u] [pid|pid-range|comm-regex] +perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@
tools/perf/scripts/python/compaction-times.py new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
2.4.6
Quoted 41 lines · Tony Jones
This patch creates a new script (compaction-times) to report time spent in mm compaction. Report times in nanoseconds (default) or microseconds (-u). Option -p will break down times by process id, -pv will further decompose by each compaction entry/exit. Entries may be further filtered by pid, pid-range or comm (regex).
The script is useful when analysing workloads that compact memory. The most common example will be THP allocations on systems with a lot of uptime that has fragmented memory. This is an example of using the script to analyse a thpscale from mmtests which deliberately fragments memory and allocates THP in 4 separate threads
# Recording step, one of the following; $ perf record -e 'compaction:mm_compaction_*' ./workload $ perf script record compaction-times # Reporting: basic $ perf script report compaction-times total: 15825912302ns (1416084 migrated 160674 failed) # Reporting: Per task stall times $ perf script report compaction-times -- -p total: 15825912302ns (1416084 migrated 160674 failed) 5024[thpscale]: 2588338168ns (476189 migrated 32 failed) 5025[thpscale]: 2469205861ns (460767 migrated 7 failed) 5026[thpscale]: 8246032631ns (659 migrated 160621 failed) 5023[thpscale]: 2522335642ns (478469 migrated 14 failed) # Reporting: Per-compaction attempt broken down by task $ perf script report compaction-times -- -pv total: 15825912302ns (1416084 migrated 160674 failed) 5024[thpscale]: 2588338168ns (476189 migrated 32 failed) 5024[thpscale].1: 3549721ns (352 migrated 0 failed) 5024[thpscale].2: 173091ns (32 migrated 0 failed) 5024[thpscale].3: 695548ns (160 migrated 0 failed) 5024[thpscale].4: 138561ns (32 migrated 0 failed) 5024[thpscale].5: 1123068ns (224 migrated 0 failed) 5024[thpscale].6: 163610ns (32 migrated 0 failed) ..... output continues ...
Quoted 1 line
Signed-off-by Tony Jones <[email protected]>
It would be nice, if the script also reported number of pages scanned and isolated by the compaction migration and free scanners. This would provide the same metrics as vmstat, but possible to break down per process, which is useful.
You would need to process two extra tracepoints:mm_compaction_isolate_migratepagesmm_compaction_isolate_freepages
Note that vmstat lumps the pages isolated in either of those into a shared counter COMPACTISOLATED, but for determining efficiency of each of the scanners, it would be better if the script reported them separately.
Thanks,
Vlastimil
PATCH v2 1/1 perf script/python: add new compaction-times script
This patch creates a new script (compaction-times) to report time spent in mm compaction. It is possible to report times in nanoseconds (default) or microseconds (-u). The option -p will break down results by process id, -pv will further decompose by each compaction entry/exit. For each compaction entry/exit what is reported is controlled by the options -t (report only timing), -m (report migration stats), -ms (report migration scanner stats) and -fs (report free scanner stats). The default is to report all. Entries may be further filtered by pid, pid-range or comm (regex).
The script is useful when analysing workloads that compact memory. The most common example will be THP allocations on systems with a lot of uptime that has fragmented memory. This is an example of using the script to analyse a thpscale from mmtests which deliberately fragments memory and allocates THP in 4 separate threads
# Recording step, one of the following;
$ perf record -e 'compaction:mm_compaction_*' ./workload
$ perf script record compaction-times
# Reporting: basic
total: 2444505743ns migration: moved=357738 failed=39275
free_scanner: scanned=2705578 isolated=387875
migration_scanner: scanned=414426 isolated=397013
# Reporting: Per task stall times
$ perf script report compaction-times -- -t -p
total: 2444505743ns
6384[thpscale]: 740800017ns
6385[thpscale]: 274119512ns
6386[thpscale]: 832961337ns
6383[thpscale]: 596624877ns
# Reporting: Per-compaction attempts for task 6385
$ perf script report compaction-times -- -m -pv 6385
total: 274119512ns migration: moved=14893 failed=24285
6385[thpscale]: 274119512ns migration: moved=14893 failed=24285
6385[thpscale].1: 3033277ns migration: moved=511 failed=1
6385[thpscale].2: 9592094ns migration: moved=1524 failed=12
6385[thpscale].3: 2495587ns migration: moved=512 failed=0
6385[thpscale].4: 2561766ns migration: moved=512 failed=0
6385[thpscale].5: 2523521ns migration: moved=512 failed=0
..... output continues ...Changes since v1:
- report stats for isolate_migratepages and isolate_freepages (Vlastimil Babka)
- refactor code to achieve above
- add help text
- output to stdout/stderr explicitly
--- .../scripts/python/bin/compaction-times-record | 2 + .../scripts/python/bin/compaction-times-report | 4 + tools/perf/scripts/python/compaction-times.py | 312 +++++++++++++++++++++ 3 files changed, 318 insertions(+) create mode 100644 tools/perf/scripts/python/bin/compaction-times-record create mode 100644 tools/perf/scripts/python/bin/compaction-times-report create mode 100644 tools/perf/scripts/python/compaction-times.py
tools/perf/scripts/python/bin/compaction-times-record new file +2 -0
@@ -0,0 +1,2 @@ +#!/bin/bash +perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages -e compaction:mm_compaction_isolate_migratepages -e compaction:mm_compaction_isolate_freepages $@
tools/perf/scripts/python/bin/compaction-times-report new file +4 -0
@@ -0,0 +1,4 @@ +#!/bin/bash +#description: display time taken by mm compaction +#args: [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex] +perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@
tools/perf/scripts/python/compaction-times.py new file +312 -0
312 lines not on this page · raw message
Signature · 1 line
2.4.6
Quoted 51 lines · Tony Jones
This patch creates a new script (compaction-times) to report time spent in mm compaction. It is possible to report times in nanoseconds (default) or microseconds (-u). The option -p will break down results by process id, -pv will further decompose by each compaction entry/exit. For each compaction entry/exit what is reported is controlled by the options -t (report only timing), -m (report migration stats), -ms (report migration scanner stats) and -fs (report free scanner stats). The default is to report all. Entries may be further filtered by pid, pid-range or comm (regex).
The script is useful when analysing workloads that compact memory. The most common example will be THP allocations on systems with a lot of uptime that has fragmented memory. This is an example of using the script to analyse a thpscale from mmtests which deliberately fragments memory and allocates THP in 4 separate threads
# Recording step, one of the following; $ perf record -e 'compaction:mm_compaction_*' ./workload $ perf script record compaction-times # Reporting: basic total: 2444505743ns migration: moved=357738 failed=39275 free_scanner: scanned=2705578 isolated=387875 migration_scanner: scanned=414426 isolated=397013 # Reporting: Per task stall times $ perf script report compaction-times -- -t -p total: 2444505743ns 6384[thpscale]: 740800017ns 6385[thpscale]: 274119512ns 6386[thpscale]: 832961337ns 6383[thpscale]: 596624877ns # Reporting: Per-compaction attempts for task 6385 $ perf script report compaction-times -- -m -pv 6385 total: 274119512ns migration: moved=14893 failed=24285 6385[thpscale]: 274119512ns migration: moved=14893 failed=24285 6385[thpscale].1: 3033277ns migration: moved=511 failed=1 6385[thpscale].2: 9592094ns migration: moved=1524 failed=12 6385[thpscale].3: 2495587ns migration: moved=512 failed=0 6385[thpscale].4: 2561766ns migration: moved=512 failed=0 6385[thpscale].5: 2523521ns migration: moved=512 failed=0 ..... output continues ...Changes since v1:
- report stats forisolate_migratepagesandisolate_freepages(Vlastimil Babka)
- refactor code to achieve above
- add help text
- output to stdout/stderr explicitly
Quoted 3 lines
Signed-off-by Tony Jones <[email protected]>Cc Mel Gorman <[email protected]>Cc Vlastimil Babka <[email protected]>
Works for me, thanks. I'll leave it to perf experts to judge if the options and output formatting matches what's common for perf scripts.
Arnaldo Carvalho de Melo
maintainerEm Thu, Aug 20, 2015 at 11:33:24AM +0200, Vlastimil Babka escreveu:
Quoted 52 lines · Tony Jones
Quoted 51 lines
This patch creates a new script (compaction-times) to report time spent in mm compaction. It is possible to report times in nanoseconds (default) or microseconds (-u). The option -p will break down results by process id, -pv will further decompose by each compaction entry/exit. For each compaction entry/exit what is reported is controlled by the options -t (report only timing), -m (report migration stats), -ms (report migration scanner stats) and -fs (report free scanner stats). The default is to report all. Entries may be further filtered by pid, pid-range or comm (regex).
The script is useful when analysing workloads that compact memory. The most common example will be THP allocations on systems with a lot of uptime that has fragmented memory. This is an example of using the script to analyse a thpscale from mmtests which deliberately fragments memory and allocates THP in 4 separate threads
# Recording step, one of the following; $ perf record -e 'compaction:mm_compaction_*' ./workload $ perf script record compaction-times # Reporting: basic total: 2444505743ns migration: moved=357738 failed=39275 free_scanner: scanned=2705578 isolated=387875 migration_scanner: scanned=414426 isolated=397013 # Reporting: Per task stall times $ perf script report compaction-times -- -t -p total: 2444505743ns 6384[thpscale]: 740800017ns 6385[thpscale]: 274119512ns 6386[thpscale]: 832961337ns 6383[thpscale]: 596624877ns # Reporting: Per-compaction attempts for task 6385 $ perf script report compaction-times -- -m -pv 6385 total: 274119512ns migration: moved=14893 failed=24285 6385[thpscale]: 274119512ns migration: moved=14893 failed=24285 6385[thpscale].1: 3033277ns migration: moved=511 failed=1 6385[thpscale].2: 9592094ns migration: moved=1524 failed=12 6385[thpscale].3: 2495587ns migration: moved=512 failed=0 6385[thpscale].4: 2561766ns migration: moved=512 failed=0 6385[thpscale].5: 2523521ns migration: moved=512 failed=0 ..... output continues ...Changes since v1:
- report stats forisolate_migratepagesandisolate_freepages(Vlastimil Babka)
- refactor code to achieve above
- add help text
- output to stdout/stderr explicitly
Quoted 8 lines
Quoted 3 lines
Signed-off-by Tony Jones <[email protected]>Cc Mel Gorman <[email protected]>Cc Vlastimil Babka <[email protected]>Acked-by Vlastimil Babka <[email protected]>Works for me, thanks. I'll leave it to perf experts to judge if the options and output formatting matches what's common for perf scripts.
Well, we don't have any firm set standard for outputting from scripts, so if you did it inspired by existing scripts outputs, probably that is good enough, having someone testing it is a plus, and in these cases, if the "works for me" means you actually tested it, can we replace the "Acked-by" with a "Tested-by"?
Ingo, others, comments on formatting?
- Arnaldo
Quoted 5 lines · Arnaldo Carvalho de Melo
Well, we don't have any firm set standard for outputting from scripts, so if you did it inspired by existing scripts outputs, probably that is good enough, having someone testing it is a plus, and in these cases, if the "works for me" means you actually tested it, can we replace the "Acked-by" with a "Tested-by"?
The output seemed consistent with the existing scripts in that, as you point out, there really isn't much consistency. Taking a second look, the only thing I can see is that scripts such as futex-contention and failed-syscalls-by-pid output "comm *[pid]" whereas I'm outputting "pid[comm]". That's certainly easy to change.
Yes, I believe Vlastimil tested v1 and v2 but I'll let him speak to this and to whether his approval goes beyond testing (re: acked-by).
thanks
tony
Quoted 11 lines · Arnaldo Carvalho de Melo
Em Thu, Aug 20, 2015 at 11:33:24AM +0200, Vlastimil Babka escreveu:
Quoted 4 lines · Tony Jones
Works for me, thanks. I'll leave it to perf experts to judge if the options and output formatting matches what's common for perf scripts.
Well, we don't have any firm set standard for outputting from scripts, so if you did it inspired by existing scripts outputs, probably that is good enough, having someone testing it is a plus, and in these cases, if the "works for me" means you actually tested it, can we replace the "Acked-by" with a "Tested-by"?
Yeah you can change to Tested-by. Thanks.
Quoted 4 lines
Ingo, others, comments on formatting?
- Arnaldo
tip-bot for Tony Jones
merge bot[tip:perf/core] perf scripts python: Add new compaction-times script
In reply to Tony Jonesperf scripts python: Add new compaction-times script
Commit-ID: 84e5d89a777cca26cc513264752b439874702dd6 Gitweb: http://git.kernel.org/tip/84e5d89a777cca26cc513264752b439874702dd6 Author: Tony Jones <[email protected]> AuthorDate: Mon, 17 Aug 2015 12:48:52 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 28 Aug 2015 14:53:40 -0300
perf scripts python: Add new compaction-times script
This patch creates a new script (compaction-times) to report time spent in mm compaction. It is possible to report times in nanoseconds (default) or microseconds (-u).
The option -p will break down results by process id, -pv will further decompose by each compaction entry/exit.
For each compaction entry/exit what is reported is controlled by the options:
-t report only timing -m report migration stats -ms report migration scanner stats -fs report free scanner stats
The default is to report all.
Entries may be further filtered by pid, pid-range or comm (regex).
The script is useful when analysing workloads that compact memory. The most common example will be THP allocations on systems with a lot of uptime that has fragmented memory.
This is an example of using the script to analyse a thpscale from mmtests which deliberately fragments memory and allocates THP in 4 separate threads
# Recording step, one of the following;
$ perf record -e 'compaction:mm_compaction_*' ./workload # or: $ perf script record compaction-times
# Reporting: basic
total: 2444505743ns migration: moved=357738 failed=39275
free_scanner: scanned=2705578 isolated=387875
migration_scanner: scanned=414426 isolated=397013
# Reporting: Per task stall times
$ perf script report compaction-times -- -t -p total: 2444505743ns 6384[thpscale]: 740800017ns 6385[thpscale]: 274119512ns 6386[thpscale]: 832961337ns 6383[thpscale]: 596624877ns
# Reporting: Per-compaction attempts for task 6385
$ perf script report compaction-times -- -m -pv 6385 total: 274119512ns migration: moved=14893 failed=24285 6385[thpscale]: 274119512ns migration: moved=14893 failed=24285 6385[thpscale].1: 3033277ns migration: moved=511 failed=1 6385[thpscale].2: 9592094ns migration: moved=1524 failed=12 6385[thpscale].3: 2495587ns migration: moved=512 failed=0 6385[thpscale].4: 2561766ns migration: moved=512 failed=0 6385[thpscale].5: 2523521ns migration: moved=512 failed=0 ..... output continues ...
Changes since v1:
- report stats for isolate_migratepages and isolate_freepages (Vlastimil Babka)
- refactor code to achieve above
- add help text
- output to stdout/stderr explicitly
--- .../scripts/python/bin/compaction-times-record | 2 + .../scripts/python/bin/compaction-times-report | 4 + tools/perf/scripts/python/compaction-times.py | 311 +++++++++++++++++++++ 3 files changed, 317 insertions(+)
tools/perf/scripts/python/bin/compaction-times-record new file +2 -0
@@ -0,0 +1,2 @@ +#!/bin/bash +perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages -e compaction:mm_compaction_isolate_migratepages -e compaction:mm_compaction_isolate_freepages $@
tools/perf/scripts/python/bin/compaction-times-report new file +4 -0
@@ -0,0 +1,4 @@ +#!/bin/bash +#description: display time taken by mm compaction +#args: [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex] +perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@
tools/perf/scripts/python/compaction-times.py new file +311 -0
311 lines not on this page · raw message