Skip to content

Commit

Permalink
perf: Add a perf trace option to check samples ordering reliability
Browse files Browse the repository at this point in the history
To ensure sample events time reordering is reliable, add a -d option
to perf trace to check that automatically.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
  • Loading branch information
Frederic Weisbecker committed Apr 24, 2010
1 parent 9df9bbb commit e1889d7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

static char const *script_name;
static char const *generate_script_lang;
static bool debug_ordering;
static u64 last_timestamp;

static int default_start_script(const char *script __unused,
int argc __unused,
Expand Down Expand Up @@ -87,6 +89,14 @@ static int process_sample_event(event_t *event, struct perf_session *session)
}

if (session->sample_type & PERF_SAMPLE_RAW) {
if (debug_ordering) {
if (data.time < last_timestamp) {
pr_err("Samples misordered, previous: %llu "
"this: %llu\n", last_timestamp,
data.time);
}
last_timestamp = data.time;
}
/*
* FIXME: better resolve from pid from the struct trace_entry
* field, although it should be the same than this perf
Expand Down Expand Up @@ -532,6 +542,8 @@ static const struct option options[] = {
"generate perf-trace.xx script in specified language"),
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
OPT_BOOLEAN('d', "debug-ordering", &debug_ordering,
"check that samples time ordering is monotonic"),

OPT_END()
};
Expand Down

0 comments on commit e1889d7

Please sign in to comment.