[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1406300177-31805-7-git-send-email-jolsa@kernel.org>
Date: Fri, 25 Jul 2014 16:56:04 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: Jiri Olsa <jolsa@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
David Ahern <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Jean Pihet <jean.pihet@...aro.org>,
Namhyung Kim <namhyung@...nel.org>,
Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 06/19] perf tools: Factor ordered_events_flush to be more generic
Centralizing the next_flush calculation under the
ordered_events_flush function.
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Jean Pihet <jean.pihet@...aro.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/util/session.c | 47 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 12b72bc90125..f94ec7e55749 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -453,6 +453,11 @@ struct ordered_event {
struct list_head list;
};
+enum oe_flush {
+ OE_FLUSH__FINAL,
+ OE_FLUSH__ROUND,
+};
+
static void perf_session_free_sample_buffers(struct perf_session *session)
{
struct ordered_events *oe = &session->ordered_events;
@@ -566,8 +571,8 @@ static int perf_session_deliver_event(struct perf_session *session,
struct perf_tool *tool,
u64 file_offset);
-static int ordered_events_flush(struct perf_session *s,
- struct perf_tool *tool)
+static int __ordered_events_flush(struct perf_session *s,
+ struct perf_tool *tool)
{
struct ordered_events *oe = &s->ordered_events;
struct list_head *head = &oe->events;
@@ -617,6 +622,32 @@ static int ordered_events_flush(struct perf_session *s,
return 0;
}
+static int ordered_events_flush(struct perf_session *s, struct perf_tool *tool,
+ enum oe_flush how)
+{
+ struct ordered_events *oe = &s->ordered_events;
+ int err;
+
+ switch (how) {
+ case OE_FLUSH__FINAL:
+ oe->next_flush = ULLONG_MAX;
+ break;
+
+ case OE_FLUSH__ROUND:
+ default:
+ break;
+ };
+
+ err = __ordered_events_flush(s, tool);
+
+ if (!err) {
+ if (how == OE_FLUSH__ROUND)
+ oe->next_flush = oe->max_timestamp;
+ }
+
+ return err;
+}
+
/*
* When perf record finishes a pass on every buffers, it records this pseudo
* event.
@@ -660,11 +691,7 @@ static int process_finished_round(struct perf_tool *tool,
union perf_event *event __maybe_unused,
struct perf_session *session)
{
- int ret = ordered_events_flush(session, tool);
- if (!ret)
- session->ordered_events.next_flush = session->ordered_events.max_timestamp;
-
- return ret;
+ return ordered_events_flush(session, tool, OE_FLUSH__ROUND);
}
int perf_session_queue_event(struct perf_session *s, union perf_event *event,
@@ -1247,8 +1274,7 @@ more:
goto more;
done:
/* do the final flush for ordered samples */
- session->ordered_events.next_flush = ULLONG_MAX;
- err = ordered_events_flush(session, tool);
+ err = ordered_events_flush(session, tool, OE_FLUSH__FINAL);
out_err:
free(buf);
perf_session__warn_about_errors(session, tool);
@@ -1389,8 +1415,7 @@ more:
out:
/* do the final flush for ordered samples */
- session->ordered_events.next_flush = ULLONG_MAX;
- err = ordered_events_flush(session, tool);
+ err = ordered_events_flush(session, tool, OE_FLUSH__FINAL);
out_err:
ui_progress__finish();
perf_session__warn_about_errors(session, tool);
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists