Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1191440
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 18/18] perf script: Add option --show-switch-events |
| Date | 2015-07-24 04:10 +0200 |
| Message-ID | <pPAAW-8ws-13@gated-at.bofh.it> (permalink) |
| References | <pPArf-85G-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Adrian Hunter <adrian.hunter@intel.com>
Add option --show-switch-events to show switch events in a similar
fashion to --show-task-events and --show-mmap-events.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1437471846-26995-6-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-script.txt | 4 ++++
tools/perf/builtin-script.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index c82df572fac2..e2fec5fc21e7 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -222,6 +222,10 @@ OPTIONS
--show-mmap-events
Display mmap related events (e.g. MMAP, MMAP2).
+--show-switch-events
+ Display context switch events i.e. events of type PERF_RECORD_SWITCH or
+ PERF_RECORD_SWITCH_CPU_WIDE.
+
--header
Show perf.data header.
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8a8e2ead6382..bd31380122f9 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -623,6 +623,7 @@ struct perf_script {
struct perf_session *session;
bool show_task_events;
bool show_mmap_events;
+ bool show_switch_events;
};
static int process_attr(struct perf_tool *tool, union perf_event *event,
@@ -813,6 +814,32 @@ static int process_mmap2_event(struct perf_tool *tool,
return 0;
}
+static int process_switch_event(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct machine *machine)
+{
+ struct thread *thread;
+ struct perf_script *script = container_of(tool, struct perf_script, tool);
+ struct perf_session *session = script->session;
+ struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
+
+ if (perf_event__process_switch(tool, event, sample, machine) < 0)
+ return -1;
+
+ thread = machine__findnew_thread(machine, sample->pid,
+ sample->tid);
+ if (thread == NULL) {
+ pr_debug("problem processing SWITCH event, skipping it.\n");
+ return -1;
+ }
+
+ print_sample_start(sample, thread, evsel);
+ perf_event__fprintf(event, stdout);
+ thread__put(thread);
+ return 0;
+}
+
static void sig_handler(int sig __maybe_unused)
{
session_done = 1;
@@ -834,6 +861,8 @@ static int __cmd_script(struct perf_script *script)
script->tool.mmap = process_mmap_event;
script->tool.mmap2 = process_mmap2_event;
}
+ if (script->show_switch_events)
+ script->tool.context_switch = process_switch_event;
ret = perf_session__process_events(script->session);
@@ -1618,6 +1647,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
"Show the fork/comm/exit events"),
OPT_BOOLEAN('\0', "show-mmap-events", &script.show_mmap_events,
"Show the mmap events"),
+ OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
+ "Show context switch events (if recorded)"),
OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
"Instruction Tracing options",
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:00 +0200
[PATCH 01/18] perf test: Check for refcnt in thread_map test Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:00 +0200
[PATCH 06/18] perf symbols: Add front end cache for DSO symbol lookup Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 12/18] perf tools: Stop reading the kallsyms data from perf.data Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Jiri Olsa <jolsa@redhat.com> - 2015-08-03 19:50 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 21:10 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 21:30 +0200
Re: [PATCH 11/18] perf script: Switch from perf.data's kallsyms to perf's symbol resolver Jiri Olsa <jolsa@redhat.com> - 2015-08-03 22:20 +0200
[PATCH 03/18] perf evlist: Use bool instead of target argument in propagate_maps() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 18/18] perf script: Add option --show-switch-events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 16/18] perf record: Add option --switch-events to select PERF_RECORD_SWITCH events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 07/18] perf symbols: Introduce map__is_(kernel,kmodule)() Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 08/18] tools lib traceevent: Allow setting an alternative symbol resolver Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 13/18] perf tools: Stop copying kallsyms into the perf.data file header Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 15/18] perf tools: Add new PERF_RECORD_SWITCH event Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 17/18] perf script: Don't assume evsel position of tracking events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 09/18] perf symbols: Provide libtraceevent callback to resolve kernel symbols Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 14/18] perf: Add PERF_RECORD_SWITCH to indicate context switches Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
[PATCH 05/18] perf header: Use argv style storage for cmdline feature data Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-07-24 04:10 +0200
csiph-web