[PATCH 19/19] perf tools: Allow out of order messages in forced flush

From: Jiri Olsa
Date: Sun Jul 20 2014 - 17:57:26 EST


In forced flush (OE_FLUSH__HALF) we break the rules of the
flush timestamp via PERF_RECORD_FINISHED_ROUND event, so
we could get out of order event.

Do not force error in this case plus changing the
output warning to use WARN_ONCE.

Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Jean Pihet <jean.pihet@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/ordered-events.c | 4 ++++
tools/perf/util/ordered-events.h | 2 ++
tools/perf/util/session.c | 8 ++++++--
3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index d7ee387cad51..5dbde56d69f6 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -181,6 +181,7 @@ int ordered_events_flush(struct perf_session *s, struct perf_tool *tool,
{
struct ordered_events *oe = &s->ordered_events;
static const char * const str[] = {
+ "NONE",
"FINAL",
"ROUND",
"HALF ",
@@ -210,6 +211,7 @@ int ordered_events_flush(struct perf_session *s, struct perf_tool *tool,
}

case OE_FLUSH__ROUND:
+ case OE_FLUSH__NONE:
default:
break;
};
@@ -226,6 +228,8 @@ int ordered_events_flush(struct perf_session *s, struct perf_tool *tool,
if (!err) {
if (how == OE_FLUSH__ROUND)
oe->next_flush = oe->max_timestamp;
+
+ oe->last_flush_type = how;
}

if (unlikely(debug_ordered_events)) {
diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h
index a4fc435f0fc6..6dd36dd01be6 100644
--- a/tools/perf/util/ordered-events.h
+++ b/tools/perf/util/ordered-events.h
@@ -14,6 +14,7 @@ struct ordered_event {
};

enum oe_flush {
+ OE_FLUSH__NONE,
OE_FLUSH__FINAL,
OE_FLUSH__ROUND,
OE_FLUSH__HALF,
@@ -32,6 +33,7 @@ struct ordered_events {
struct ordered_event *last;
int buffer_idx;
unsigned int nr_events;
+ enum oe_flush last_flush_type;
};

struct ordered_event *ordered_events_new(struct ordered_events *oe, u64 timestamp);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 4e748142a13f..3db8ab12f12d 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -15,6 +15,7 @@
#include "cpumap.h"
#include "perf_regs.h"
#include "vdso.h"
+#include "asm/bug.h"

static int perf_session__open(struct perf_session *session)
{
@@ -502,8 +503,11 @@ int perf_session_queue_event(struct perf_session *s, union perf_event *event,
return -ETIME;

if (timestamp < s->ordered_events.last_flush) {
- printf("Warning: Timestamp below last timeslice flush\n");
- return -EINVAL;
+ WARN_ONCE(1, "Timestamp below last timeslice flush\n");
+
+ /* We could get out of order messages after forced flush. */
+ if (oe->last_flush_type != OE_FLUSH__HALF)
+ return -EINVAL;
}

new = ordered_events_new(oe, timestamp);
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/