diff options
author | David Ahern <dsahern@gmail.com> | 2016-11-29 15:39:48 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-12-07 10:00:32 -0500 |
commit | f45bf8d3939d8f32f06ec12e56d2b8651c5437b4 (patch) | |
tree | 95fe80b695ed7ae6cc265dd0f470df4782227607 /tools | |
parent | 8ac1eb7bab7c8d9d6f00b3e2a408611c45d9dff0 (diff) |
perf sched timehist: Improve error message when analyzing wrong file
Arnaldo reported an unhelpful error message when running perf sched
timehist on a file that did not contain sched tracepoints:
[root@jouet ~]# perf sched timehist
No trace sample to read. Did you call 'perf record -R'?
[root@jouet ~]# perf evlist -v
cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
Change the has_traces check to look for the sched_switch event. Analysis
for perf sched timehist requires at least this event.
Now when analyzing a file without sched tracepoints you get:
root@f21-vbox:/tmp$ perf sched timehist
No sched_switch events found. Have you run 'perf sched record'?
Signed-off-by: David Ahern <dsahern@gmail.com>
Reported-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1480451988-43673-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-sched.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 870d94cd20ba..84c39f177bef 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -2629,8 +2629,12 @@ static int perf_sched__timehist(struct perf_sched *sched) | |||
2629 | if (perf_session__set_tracepoints_handlers(session, handlers)) | 2629 | if (perf_session__set_tracepoints_handlers(session, handlers)) |
2630 | goto out; | 2630 | goto out; |
2631 | 2631 | ||
2632 | if (!perf_session__has_traces(session, "record -R")) | 2632 | /* sched_switch event at a minimum needs to exist */ |
2633 | if (!perf_evlist__find_tracepoint_by_name(session->evlist, | ||
2634 | "sched:sched_switch")) { | ||
2635 | pr_err("No sched_switch events found. Have you run 'perf sched record'?\n"); | ||
2633 | goto out; | 2636 | goto out; |
2637 | } | ||
2634 | 2638 | ||
2635 | if (sched->show_migrations && | 2639 | if (sched->show_migrations && |
2636 | perf_session__set_tracepoints_handlers(session, migrate_handlers)) | 2640 | perf_session__set_tracepoints_handlers(session, migrate_handlers)) |