提交 89e5fa88 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf data: Enable stream flush within processing

For big data files the size of data allocated for stream instance could
get really high. It's needed to flush the data out of the stream once in
a while.

Unfortunately there's no size indication in the stream object, so we
govern the flush based on the number of stored events. Current flush
limit is set ot 100000 events.
Reviewed-by: NDavid Ahern <dsahern@gmail.com>
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Acked-by: NNamhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jgalar@efficios.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1429372220-6406-4-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 90e129ff
...@@ -43,6 +43,7 @@ struct evsel_priv { ...@@ -43,6 +43,7 @@ struct evsel_priv {
struct ctf_stream { struct ctf_stream {
struct bt_ctf_stream *stream; struct bt_ctf_stream *stream;
int cpu; int cpu;
u32 count;
}; };
struct ctf_writer { struct ctf_writer {
...@@ -392,7 +393,10 @@ static int ctf_stream__flush(struct ctf_stream *cs) ...@@ -392,7 +393,10 @@ static int ctf_stream__flush(struct ctf_stream *cs)
if (err) if (err)
pr_err("CTF stream %d flush failed\n", cs->cpu); pr_err("CTF stream %d flush failed\n", cs->cpu);
pr("Flush stream for cpu %d\n", cs->cpu); pr("Flush stream for cpu %d (%u samples)\n",
cs->cpu, cs->count);
cs->count = 0;
} }
return err; return err;
...@@ -490,6 +494,19 @@ static int get_sample_cpu(struct ctf_writer *cw, struct perf_sample *sample, ...@@ -490,6 +494,19 @@ static int get_sample_cpu(struct ctf_writer *cw, struct perf_sample *sample,
return cpu; return cpu;
} }
#define STREAM_FLUSH_COUNT 100000
/*
* Currently we have no other way to determine the
* time for the stream flush other than keep track
* of the number of events and check it against
* threshold.
*/
static bool is_flush_needed(struct ctf_stream *cs)
{
return cs->count >= STREAM_FLUSH_COUNT;
}
static int process_sample_event(struct perf_tool *tool, static int process_sample_event(struct perf_tool *tool,
union perf_event *_event __maybe_unused, union perf_event *_event __maybe_unused,
struct perf_sample *sample, struct perf_sample *sample,
...@@ -535,8 +552,13 @@ static int process_sample_event(struct perf_tool *tool, ...@@ -535,8 +552,13 @@ static int process_sample_event(struct perf_tool *tool,
} }
cs = ctf_stream(cw, get_sample_cpu(cw, sample, evsel)); cs = ctf_stream(cw, get_sample_cpu(cw, sample, evsel));
if (cs) if (cs) {
if (is_flush_needed(cs))
ctf_stream__flush(cs);
cs->count++;
bt_ctf_stream_append_event(cs->stream, event); bt_ctf_stream_append_event(cs->stream, event);
}
bt_ctf_event_put(event); bt_ctf_event_put(event);
return cs ? 0 : -1; return cs ? 0 : -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册