linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 05/10] perf sched timehist: Improve error message when analyzing wrong file
Date: Wed,  7 Dec 2016 13:53:30 -0300	[thread overview]
Message-ID: <20161207165335.22835-6-acme@kernel.org> (raw)
In-Reply-To: <20161207165335.22835-1-acme@kernel.org>

From: David Ahern <dsahern@gmail.com>

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>
---
 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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)
 	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))
-- 
2.9.3

  parent reply	other threads:[~2016-12-07 16:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-07 16:53 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 01/10] perf build: Check LLVM version in feature check Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 02/10] perf tools: Move PERF-VERSION-FILE target into rules area Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 03/10] perf tools: Force fixdep compilation at the start of the build Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 04/10] perf tools: Move perf build related variables under non fixdep leg Arnaldo Carvalho de Melo
2016-12-07 16:53 ` Arnaldo Carvalho de Melo [this message]
2016-12-07 16:53 ` [PATCH 06/10] perf sched: Cleanup option processing Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 07/10] perf callchain: Introduce callchain_cursor__copy() Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 08/10] perf sched timehist: Handle zero sample->tid properly Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 09/10] perf sched timehist: Cleanup idle_max_cpu handling Arnaldo Carvalho de Melo
2016-12-07 16:53 ` [PATCH 10/10] perf tools: Explicitly document that --children is enabled by default Arnaldo Carvalho de Melo
2016-12-07 18:17 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161207165335.22835-6-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).