Skip to content

Commit 6fe61cb

Browse files
vineethribmacmel
authored andcommitted
perf sched: Rename 'switches' column header to 'count' and add usage description, options for latency
Rename 'Switches' to 'Count' and document metrics shown for perf sched latency output. Also add options possible with perf sched latency. Initially, after seeing the output of 'perf sched latency', the term 'Switches' seemed like it's the number of context switches-in for a particular task, but upon going through the code, it was observed that it's actually keeping track of number of times a delay was calculated so that it is used in calculation of the average delay. Actually, the switches here is a subset of number of context switches-in because there are some cases where the count is not incremented in switch-in handler 'add_sched_in_event'. For example when a task is switched-in while it's state is not ready to run(!= THREAD_WAIT_CPU). commit d9340c1 ("perf sched: Display time in milliseconds, reorganize output") changed it from the original count to switches. So, renamed switches to count to make things a bit more clearer and added the metrics description of latency in the document. Reviewed-by: Aditya Gupta <[email protected]> Signed-off-by: Madadi Vineeth Reddy <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent e2eeef2 commit 6fe61cb

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

tools/perf/Documentation/perf-sched.txt

+36
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ There are several variants of 'perf sched':
2020
'perf sched latency' to report the per task scheduling latencies
2121
and other scheduling properties of the workload.
2222

23+
Example usage:
24+
perf sched record -- sleep 1
25+
perf sched latency
26+
27+
-------------------------------------------------------------------------------------------------------------------------------------------
28+
Task | Runtime ms | Count | Avg delay ms | Max delay ms | Max delay start | Max delay end |
29+
-------------------------------------------------------------------------------------------------------------------------------------------
30+
perf:(2) | 2.804 ms | 66 | avg: 0.524 ms | max: 1.069 ms | max start: 254752.314960 s | max end: 254752.316029 s
31+
NetworkManager:1343 | 0.372 ms | 13 | avg: 0.008 ms | max: 0.013 ms | max start: 254751.551153 s | max end: 254751.551166 s
32+
kworker/1:2-xfs:4649 | 0.012 ms | 1 | avg: 0.008 ms | max: 0.008 ms | max start: 254751.519807 s | max end: 254751.519815 s
33+
kworker/3:1-xfs:388 | 0.011 ms | 1 | avg: 0.006 ms | max: 0.006 ms | max start: 254751.519809 s | max end: 254751.519815 s
34+
sleep:147736 | 0.938 ms | 3 | avg: 0.006 ms | max: 0.007 ms | max start: 254751.313817 s | max end: 254751.313824 s
35+
36+
It shows Runtime(time that a task spent actually running on the CPU),
37+
Count(number of times a delay was calculated) and delay(time that a
38+
task was ready to run but was kept waiting).
39+
40+
Tasks with the same command name are merged and the merge count is
41+
given within (), However if -p option is used, pid is mentioned.
42+
2343
'perf sched script' to see a detailed trace of the workload that
2444
was recorded (aliased to 'perf script' for now).
2545

@@ -78,6 +98,22 @@ OPTIONS
7898
--force::
7999
Don't complain, do it.
80100

101+
OPTIONS for 'perf sched latency'
102+
-------------------------------
103+
104+
-C::
105+
--CPU <n>::
106+
CPU to profile on.
107+
108+
-p::
109+
--pids::
110+
latency stats per pid instead of per command name.
111+
112+
-s::
113+
--sort <key[,key2...]>::
114+
sort by key(s): runtime, switch, avg, max
115+
by default it's sorted by "avg ,max ,switch ,runtime".
116+
81117
OPTIONS for 'perf sched map'
82118
----------------------------
83119

tools/perf/builtin-sched.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,7 @@ static int perf_sched__lat(struct perf_sched *sched)
32133213
perf_sched__sort_lat(sched);
32143214

32153215
printf("\n -------------------------------------------------------------------------------------------------------------------------------------------\n");
3216-
printf(" Task | Runtime ms | Switches | Avg delay ms | Max delay ms | Max delay start | Max delay end |\n");
3216+
printf(" Task | Runtime ms | Count | Avg delay ms | Max delay ms | Max delay start | Max delay end |\n");
32173217
printf(" -------------------------------------------------------------------------------------------------------------------------------------------\n");
32183218

32193219
next = rb_first_cached(&sched->sorted_atom_root);

0 commit comments

Comments
 (0)