Commit d8836b5d authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Factor ordered_events__flush to be more generic

Centralizing the next_flush calculation under the ordered_events__flush
function.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-srwunsy7o5wl17vpt4a10oxp@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c64c7e1a
......@@ -451,6 +451,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;
......@@ -564,7 +569,7 @@ 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,
static int __ordered_events__flush(struct perf_session *s,
struct perf_tool *tool)
{
struct ordered_events *oe = &s->ordered_events;
......@@ -615,6 +620,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.
......@@ -658,11 +689,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 @@ static int __perf_session__process_pipe_events(struct perf_session *session,
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);
......@@ -1393,8 +1419,7 @@ int __perf_session__process_events(struct perf_session *session,
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment