From: David Ahern <dsahern@gmail.com>
To: acme@ghostprotocols.net, linux-kernel@vger.kernel.org
Cc: David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Mike Galbraith <efault@gmx.de>, Jiri Olsa <jolsa@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Stephane Eranian <eranian@google.com>,
Pekka Enberg <penberg@kernel.org>
Subject: [PATCH 7/8] perf sched timehist: Add support for context-switch event
Date: Mon, 18 Nov 2013 13:32:50 -0700 [thread overview]
Message-ID: <1384806771-2945-8-git-send-email-dsahern@gmail.com> (raw)
In-Reply-To: <1384806771-2945-1-git-send-email-dsahern@gmail.com>
Context switch events are 64 bytes; sched_switch events are 136 bytes. Both
indicate scheduling changes, so allow user to leverage the smaller event. If
both events exist in a data file, then context-switch event is ignored.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Pekka Enberg <penberg@kernel.org>
---
tools/perf/builtin-sched.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index ffe11067083c..79a94655d3ed 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -180,6 +180,7 @@ struct perf_sched {
unsigned int max_stack;
bool show_cpu_visual;
bool show_wakeups;
+ bool have_traces;
/* process and task id's of interest */
struct target target;
struct intlist *pid, *tid;
@@ -2070,6 +2071,15 @@ out:
return rc;
}
+static int timehist_cs_event(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_evsel *evsel,
+ struct perf_sample *sample,
+ struct machine *machine __maybe_unused)
+{
+ return timehist_sched_change_event(tool, event, evsel, sample, machine);
+}
+
static int timehist_sched_switch_event(struct perf_tool *tool,
union perf_event *event,
struct perf_evsel *evsel,
@@ -2293,10 +2303,25 @@ static int parse_target_str(struct perf_sched *sched)
static int timehist_check_attr(struct perf_sched *sched,
struct perf_evlist *evlist)
{
- struct perf_evsel *evsel;
+ struct perf_evsel *evsel, *cs_evsel = NULL;
struct evsel_runtime *er;
+ const char *evname;
+ bool have_cs_event = false, have_sched_event = false;
list_for_each_entry(evsel, &evlist->entries, node) {
+ if (evsel->attr.type == PERF_TYPE_TRACEPOINT)
+ sched->have_traces = true;
+
+ evname = perf_evsel__name(evsel);
+ if (strcmp(evname, "cs") == 0 ||
+ strcmp(evname, "context-switch") == 0) {
+ cs_evsel = evsel;
+ have_cs_event = true;
+ } else if (strcmp(evname, "sched:sched_switch") == 0) {
+ have_sched_event = true;
+ }
+
+
er = perf_evsel__get_runtime(evsel);
if (er == NULL) {
pr_err("Failed to allocate memory for evsel runtime data\n");
@@ -2311,6 +2336,13 @@ static int timehist_check_attr(struct perf_sched *sched,
}
}
+ if (have_cs_event && have_sched_event) {
+ pr_debug("Both schedule change events exist. Ignoring context-switch event\n");
+ } else if (have_cs_event) {
+ pr_debug("Using context-switch events.\n");
+ cs_evsel->handler = timehist_cs_event;
+ }
+
return 0;
}
@@ -2367,10 +2399,8 @@ static int perf_sched__timehist(struct perf_sched *sched)
setup_pager();
/* setup per-evsel handlers */
- if (perf_session__set_tracepoints_handlers(session, handlers))
- goto out;
-
- if (!perf_session__has_traces(session, "record -R"))
+ if (sched->have_traces &&
+ perf_session__set_tracepoints_handlers(session, handlers))
goto out;
/* pre-allocate struct for per-CPU idle stats */
--
1.8.3.4 (Apple Git-47)
next prev parent reply other threads:[~2013-11-18 20:34 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-18 20:32 [PATCH 0/8] perf: sched timehist command David Ahern
2013-11-18 20:32 ` [PATCH 1/8] perf tool: Skip ignored symbols while printing callchain David Ahern
2013-11-30 12:52 ` [tip:perf/core] perf evsel: " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 2/8] perf symbols: Move idle syms check from top to generic function David Ahern
2013-11-28 8:36 ` Namhyung Kim
2013-11-30 15:58 ` David Ahern
2013-11-30 12:52 ` [tip:perf/core] " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 3/8] perf symbol: Save vmlinux or kallsyms path loaded David Ahern
2013-11-22 18:44 ` Arnaldo Carvalho de Melo
2013-11-22 19:13 ` David Ahern
2013-11-22 19:40 ` Arnaldo Carvalho de Melo
2013-11-22 20:09 ` David Ahern
2013-11-18 20:32 ` [PATCH 4/8] perf thread: Move comm_list check into function David Ahern
2013-11-30 12:52 ` [tip:perf/core] " tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 5/8] perf tool: export setup_list David Ahern
2013-11-28 8:45 ` Namhyung Kim
2013-11-30 12:52 ` [tip:perf/core] perf tools: Export setup_list tip-bot for David Ahern
2013-11-18 20:32 ` [PATCH 6/8] perf sched: Introduce timehist command David Ahern
2013-11-28 9:50 ` Namhyung Kim
2013-11-28 16:01 ` David Ahern
2013-11-28 15:38 ` Namhyung Kim
2013-11-28 16:01 ` David Ahern
2013-11-29 0:48 ` Namhyung Kim
2013-11-29 1:58 ` David Ahern
2013-12-04 4:15 ` David Ahern
2013-11-18 20:32 ` David Ahern [this message]
2013-11-18 20:32 ` [PATCH 8/8] perf sched : Add documentation for timehist options David Ahern
2013-11-28 15:42 ` Namhyung Kim
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=1384806771-2945-8-git-send-email-dsahern@gmail.com \
--to=dsahern@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=penberg@kernel.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).