提交 3d7c27b6 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

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: NJiri 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: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 28a0b398
...@@ -300,6 +300,9 @@ OPTIONS ...@@ -300,6 +300,9 @@ OPTIONS
Display context switch events i.e. events of type PERF_RECORD_SWITCH or Display context switch events i.e. events of type PERF_RECORD_SWITCH or
PERF_RECORD_SWITCH_CPU_WIDE. PERF_RECORD_SWITCH_CPU_WIDE.
--show-lost-events
Display lost events i.e. events of type PERF_RECORD_LOST.
--demangle:: --demangle::
Demangle symbol names to human readable form. It's enabled by default, Demangle symbol names to human readable form. It's enabled by default,
disable with --no-demangle. disable with --no-demangle.
......
...@@ -1489,6 +1489,7 @@ struct perf_script { ...@@ -1489,6 +1489,7 @@ struct perf_script {
bool show_mmap_events; bool show_mmap_events;
bool show_switch_events; bool show_switch_events;
bool show_namespace_events; bool show_namespace_events;
bool show_lost_events;
bool allocated; bool allocated;
bool per_event_dump; bool per_event_dump;
struct cpu_map *cpus; struct cpu_map *cpus;
...@@ -2080,6 +2081,29 @@ static int process_switch_event(struct perf_tool *tool, ...@@ -2080,6 +2081,29 @@ static int process_switch_event(struct perf_tool *tool,
return 0; return 0;
} }
static int
process_lost_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct machine *machine)
{
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);
struct thread *thread;
thread = machine__findnew_thread(machine, sample->pid,
sample->tid);
if (thread == NULL)
return -1;
perf_sample__fprintf_start(sample, thread, evsel,
PERF_RECORD_LOST, stdout);
perf_event__fprintf(event, stdout);
thread__put(thread);
return 0;
}
static void sig_handler(int sig __maybe_unused) static void sig_handler(int sig __maybe_unused)
{ {
session_done = 1; session_done = 1;
...@@ -2174,6 +2198,8 @@ static int __cmd_script(struct perf_script *script) ...@@ -2174,6 +2198,8 @@ static int __cmd_script(struct perf_script *script)
script->tool.context_switch = process_switch_event; script->tool.context_switch = process_switch_event;
if (script->show_namespace_events) if (script->show_namespace_events)
script->tool.namespaces = process_namespaces_event; script->tool.namespaces = process_namespaces_event;
if (script->show_lost_events)
script->tool.lost = process_lost_event;
if (perf_script__setup_per_event_dump(script)) { if (perf_script__setup_per_event_dump(script)) {
pr_err("Couldn't create the per event dump files\n"); pr_err("Couldn't create the per event dump files\n");
...@@ -3110,6 +3136,8 @@ int cmd_script(int argc, const char **argv) ...@@ -3110,6 +3136,8 @@ int cmd_script(int argc, const char **argv)
"Show context switch events (if recorded)"), "Show context switch events (if recorded)"),
OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events, OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
"Show namespace events (if recorded)"), "Show namespace events (if recorded)"),
OPT_BOOLEAN('\0', "show-lost-events", &script.show_lost_events,
"Show lost events (if recorded)"),
OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump, OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump,
"Dump trace output to files named by the monitored events"), "Dump trace output to files named by the monitored events"),
OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
......
...@@ -1435,6 +1435,11 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) ...@@ -1435,6 +1435,11 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
event->context_switch.next_prev_tid); event->context_switch.next_prev_tid);
} }
static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp)
{
return fprintf(fp, " lost %" PRIu64 "\n", event->lost.lost);
}
size_t perf_event__fprintf(union perf_event *event, FILE *fp) size_t perf_event__fprintf(union perf_event *event, FILE *fp)
{ {
size_t ret = fprintf(fp, "PERF_RECORD_%s", size_t ret = fprintf(fp, "PERF_RECORD_%s",
...@@ -1467,6 +1472,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp) ...@@ -1467,6 +1472,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)
case PERF_RECORD_SWITCH_CPU_WIDE: case PERF_RECORD_SWITCH_CPU_WIDE:
ret += perf_event__fprintf_switch(event, fp); ret += perf_event__fprintf_switch(event, fp);
break; break;
case PERF_RECORD_LOST:
ret += perf_event__fprintf_lost(event, fp);
break;
default: default:
ret += fprintf(fp, "\n"); ret += fprintf(fp, "\n");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册