aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2018-01-07 11:03:53 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-01-10 10:00:39 -0500
commit3d7c27b6dbca4c90e7d921b45c2240e7c3cb92a2 (patch)
treeecb6ee74ee84e5fa1e720f1994f6fc223014c345 /tools/perf/builtin-script.c
parent28a0b39877f5ed64ae9fadf95dddb90999309dee (diff)
perf script: Add support to display lost events
Adding option to display lost events: $ perf script --show-lost-events ... mplayer 13810 [002] 468011.402396: 100 cycles:ppp: ff.. mplayer 13810 [002] 468011.402396: PERF_RECORD_LOST lost 3880 mplayer 13810 [002] 468011.402397: 100 cycles:ppp: ff.. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180107160356.28203-10-jolsa@kernel.org [ Use PRIu64 when printing u64 values, fixing the build in some arches ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index bb603495cf4a..c1cce474c0f1 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1489,6 +1489,7 @@ struct perf_script {
1489 bool show_mmap_events; 1489 bool show_mmap_events;
1490 bool show_switch_events; 1490 bool show_switch_events;
1491 bool show_namespace_events; 1491 bool show_namespace_events;
1492 bool show_lost_events;
1492 bool allocated; 1493 bool allocated;
1493 bool per_event_dump; 1494 bool per_event_dump;
1494 struct cpu_map *cpus; 1495 struct cpu_map *cpus;
@@ -2080,6 +2081,29 @@ static int process_switch_event(struct perf_tool *tool,
2080 return 0; 2081 return 0;
2081} 2082}
2082 2083
2084static int
2085process_lost_event(struct perf_tool *tool,
2086 union perf_event *event,
2087 struct perf_sample *sample,
2088 struct machine *machine)
2089{
2090 struct perf_script *script = container_of(tool, struct perf_script, tool);
2091 struct perf_session *session = script->session;
2092 struct perf_evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id);
2093 struct thread *thread;
2094
2095 thread = machine__findnew_thread(machine, sample->pid,
2096 sample->tid);
2097 if (thread == NULL)
2098 return -1;
2099
2100 perf_sample__fprintf_start(sample, thread, evsel,
2101 PERF_RECORD_LOST, stdout);
2102 perf_event__fprintf(event, stdout);
2103 thread__put(thread);
2104 return 0;
2105}
2106
2083static void sig_handler(int sig __maybe_unused) 2107static void sig_handler(int sig __maybe_unused)
2084{ 2108{
2085 session_done = 1; 2109 session_done = 1;
@@ -2174,6 +2198,8 @@ static int __cmd_script(struct perf_script *script)
2174 script->tool.context_switch = process_switch_event; 2198 script->tool.context_switch = process_switch_event;
2175 if (script->show_namespace_events) 2199 if (script->show_namespace_events)
2176 script->tool.namespaces = process_namespaces_event; 2200 script->tool.namespaces = process_namespaces_event;
2201 if (script->show_lost_events)
2202 script->tool.lost = process_lost_event;
2177 2203
2178 if (perf_script__setup_per_event_dump(script)) { 2204 if (perf_script__setup_per_event_dump(script)) {
2179 pr_err("Couldn't create the per event dump files\n"); 2205 pr_err("Couldn't create the per event dump files\n");
@@ -3110,6 +3136,8 @@ int cmd_script(int argc, const char **argv)
3110 "Show context switch events (if recorded)"), 3136 "Show context switch events (if recorded)"),
3111 OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events, 3137 OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
3112 "Show namespace events (if recorded)"), 3138 "Show namespace events (if recorded)"),
3139 OPT_BOOLEAN('\0', "show-lost-events", &script.show_lost_events,
3140 "Show lost events (if recorded)"),
3113 OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump, 3141 OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump,
3114 "Dump trace output to files named by the monitored events"), 3142 "Dump trace output to files named by the monitored events"),
3115 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), 3143 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),