aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2010-05-27 10:27:47 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2010-06-24 17:36:23 -0400
commitffabd99e051e73344efe4e53d58f11643f180512 (patch)
tree89de8034980b80c05982b0854f31bb42a53ff1f0 /tools
parent6fcf7ddbb73d677b3bb7b16f0fff1419cb8349e9 (diff)
perf: Report lost events in perf trace debug mode
Account and report lost events in perf trace debugging mode, useful to check the reliability of the traces. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Masami Hiramatsu <mhiramat@redhat.com> Cc: Tom Zanussi <tzanussi@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-trace.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 83df8db4f358..294da725a57d 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -11,7 +11,7 @@
11 11
12static char const *script_name; 12static char const *script_name;
13static char const *generate_script_lang; 13static char const *generate_script_lang;
14static bool debug_ordering; 14static bool debug_mode;
15static u64 last_timestamp; 15static u64 last_timestamp;
16static u64 nr_unordered; 16static u64 nr_unordered;
17 17
@@ -92,7 +92,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
92 } 92 }
93 93
94 if (session->sample_type & PERF_SAMPLE_RAW) { 94 if (session->sample_type & PERF_SAMPLE_RAW) {
95 if (debug_ordering) { 95 if (debug_mode) {
96 if (data.time < last_timestamp) { 96 if (data.time < last_timestamp) {
97 pr_err("Samples misordered, previous: %llu " 97 pr_err("Samples misordered, previous: %llu "
98 "this: %llu\n", last_timestamp, 98 "this: %llu\n", last_timestamp,
@@ -116,6 +116,15 @@ static int process_sample_event(event_t *event, struct perf_session *session)
116 return 0; 116 return 0;
117} 117}
118 118
119static u64 nr_lost;
120
121static int process_lost_event(event_t *event, struct perf_session *session __used)
122{
123 nr_lost += event->lost.lost;
124
125 return 0;
126}
127
119static struct perf_event_ops event_ops = { 128static struct perf_event_ops event_ops = {
120 .sample = process_sample_event, 129 .sample = process_sample_event,
121 .comm = event__process_comm, 130 .comm = event__process_comm,
@@ -123,6 +132,7 @@ static struct perf_event_ops event_ops = {
123 .event_type = event__process_event_type, 132 .event_type = event__process_event_type,
124 .tracing_data = event__process_tracing_data, 133 .tracing_data = event__process_tracing_data,
125 .build_id = event__process_build_id, 134 .build_id = event__process_build_id,
135 .lost = process_lost_event,
126 .ordered_samples = true, 136 .ordered_samples = true,
127}; 137};
128 138
@@ -141,8 +151,10 @@ static int __cmd_trace(struct perf_session *session)
141 151
142 ret = perf_session__process_events(session, &event_ops); 152 ret = perf_session__process_events(session, &event_ops);
143 153
144 if (debug_ordering) 154 if (debug_mode) {
145 pr_err("Misordered timestamps: %llu\n", nr_unordered); 155 pr_err("Misordered timestamps: %llu\n", nr_unordered);
156 pr_err("Lost events: %llu\n", nr_lost);
157 }
146 158
147 return ret; 159 return ret;
148} 160}
@@ -554,8 +566,8 @@ static const struct option options[] = {
554 "generate perf-trace.xx script in specified language"), 566 "generate perf-trace.xx script in specified language"),
555 OPT_STRING('i', "input", &input_name, "file", 567 OPT_STRING('i', "input", &input_name, "file",
556 "input file name"), 568 "input file name"),
557 OPT_BOOLEAN('d', "debug-ordering", &debug_ordering, 569 OPT_BOOLEAN('d', "debug-mode", &debug_mode,
558 "check that samples time ordering is monotonic"), 570 "do various checks like samples ordering and lost events"),
559 571
560 OPT_END() 572 OPT_END()
561}; 573};