Skip to contentSkip to conversation

perf sched timehist: Improve error message when analyzing wrong file

PATCH In review David Ahern 4 participants 5 messages Nov 29, 2016 – Dec 7, 2016 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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'?
---
 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +5 -1
index 870d94cd20ba..84c39f177bef 100644
@@ -2629,8 +2629,12 @@ static int perf_sched__timehist(struct perf_sched *sched)
 	if (perf_session__set_tracepoints_handlers(session, handlers))
 		goto out;
 
-	if (!perf_session__has_traces(session, "record -R"))
+	/* sched_switch event at a minimum needs to exist */
+	if (!perf_evlist__find_tracepoint_by_name(session->evlist,
+						  "sched:sched_switch")) {
+		pr_err("No sched_switch events found. Have you run 'perf sched record'?\n");
 		goto out;
+	}
 
 	if (sched->show_migrations &&
 	    perf_session__set_tracepoints_handlers(session, migrate_handlers))
Signature · 1 line
2.7.4 (Apple Git-66)
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 15 lines · David Ahern

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.

Quoted 6 lines

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'?

Thanks,
Namhyung

Quoted 28 lines
---
 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +5 -1
index 870d94cd20ba..84c39f177bef 100644
@@ -2629,8 +2629,12 @@ static int perf_sched__timehist(struct perf_sched
 *sched)
 	if (perf_session__set_tracepoints_handlers(session, handlers))
 		goto out;
 
-	if (!perf_session__has_traces(session, "record -R"))
+	/* sched_switch event at a minimum needs to exist */
+	if (!perf_evlist__find_tracepoint_by_name(session->evlist,
+						  "sched:sched_switch")) {
+		pr_err("No sched_switch events found. Have you run 'perf sched
 record'?\n");
 		goto out;
+	}
 
tools/perf/builtin-sched.c +0 -1
 	if (sched->show_migrations &&
 	    perf_session__set_tracepoints_handlers(session, migrate_handlers))
--

2.7.4 (Apple Git-66)

Signature · 2 lines
Thanks,
Namhyung Kim
#2 lore raw
Quoted 21 lines · Namhyung Kim
Quoted 20 lines · David Ahern

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'?
Quoted 7 lines
Quoted 1 line

Thanks,
Namhyung

Arnaldo: I think this one has been overlooked

#3 lore raw

Em Mon, Dec 05, 2016 at 03:41:54PM -0800, David Ahern escreveu:

Quoted 9 lines · Namhyung Kim
Quoted 8 lines · David Ahern
Quoted 6 lines

Arnaldo reported an unhelpful error message when running perf sched timehist on a file that did not contain sched tracepoints:

    root@f21-vbox:/tmp$ perf sched timehist
    No sched_switch events found. Have you run 'perf sched record'?
Quoted 7 lines
Quoted 5 lines

Thanks,
Namhyung

Arnaldo: I think this one has been overlooked

Ooops, Reported-and-Forgot-by: Arnaldo, ok, tested, applied, thanks!

- Arnaldo

#4 lore raw
In reply to David Ahern
perf sched timehist: Improve error message when analyzing wrong file
Commit-ID:  f45bf8d3939d8f32f06ec12e56d2b8651c5437b4
Gitweb:     http://git.kernel.org/tip/f45bf8d3939d8f32f06ec12e56d2b8651c5437b4
Author:     David Ahern <[email protected]>
AuthorDate: Tue, 29 Nov 2016 13:39:48 -0700
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 7 Dec 2016 12:00:32 -0300

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'?
---
 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +5 -1
index 870d94c..84c39f1 100644
@@ -2629,8 +2629,12 @@ static int perf_sched__timehist(struct perf_sched *sched)
 	if (perf_session__set_tracepoints_handlers(session, handlers))
 		goto out;
 
-	if (!perf_session__has_traces(session, "record -R"))
+	/* sched_switch event at a minimum needs to exist */
+	if (!perf_evlist__find_tracepoint_by_name(session->evlist,
+						  "sched:sched_switch")) {
+		pr_err("No sched_switch events found. Have you run 'perf sched record'?\n");
 		goto out;
+	}
 
 	if (sched->show_migrations &&
 	    perf_session__set_tracepoints_handlers(session, migrate_handlers))