From: Jiri Olsa <jolsa@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Jiri Olsa <jolsa@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jeremie Galarneau <jgalar@efficios.com>,
Namhyung Kim <namhyung@gmail.com>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Tom Zanussi <tzanussi@gmail.com>
Subject: [PATCH 7/8] perf data: Enable stream flush within processing
Date: Wed, 3 Dec 2014 17:24:01 +0100 [thread overview]
Message-ID: <1417623842-14331-8-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1417623842-14331-1-git-send-email-jolsa@kernel.org>
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.
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jeremie Galarneau <jgalar@efficios.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/data-convert-bt.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 2bc70b8d128d..df95fac399d7 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -43,6 +43,7 @@ struct evsel_priv {
struct ctf_stream {
struct bt_ctf_stream *stream;
int cpu;
+ u32 count;
};
struct ctf_writer {
@@ -392,7 +393,10 @@ static int ctf_stream__flush(struct ctf_stream *cs)
if (err)
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;
@@ -490,6 +494,19 @@ static int get_sample_cpu(struct ctf_writer *cw, struct perf_sample *sample,
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,
union perf_event *_event __maybe_unused,
struct perf_sample *sample,
@@ -535,8 +552,13 @@ static int process_sample_event(struct perf_tool *tool,
}
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_event_put(event);
return cs ? 0 : -1;
@@ -724,7 +746,7 @@ static int setup_streams(struct ctf_writer *cw, struct perf_session *session)
* Try to get the number of cpus used in the data file,
* if not present fallback to the MAX_CPUS.
*/
- if (!ph)
+ if (!ph || !ph->env.nr_cpus_avail)
ncpus = MAX_CPUS;
else
ncpus = ph->env.nr_cpus_avail;
--
1.9.3
next prev parent reply other threads:[~2014-12-03 16:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 16:23 [PATCH 0/8] perf tools: Add perf data CTF conversion Jiri Olsa
2014-12-03 16:23 ` [PATCH 1/8] perf tools: Add feature check for libbabeltrace Jiri Olsa
2014-12-08 8:07 ` Namhyung Kim
2014-12-09 10:14 ` Jiri Olsa
2014-12-03 16:23 ` [PATCH 2/8] perf tools: Add new perf data command Jiri Olsa
2014-12-03 16:23 ` [PATCH 3/8] perf data: Add perf data to CTF conversion support Jiri Olsa
2014-12-08 8:13 ` Namhyung Kim
2014-12-09 10:16 ` Jiri Olsa
2014-12-03 16:23 ` [PATCH 4/8] perf data: Add a 'perf' prefix to the generic fields Jiri Olsa
2014-12-03 16:23 ` [PATCH 5/8] perf data: Add tracepoint events fields CTF conversion support Jiri Olsa
2014-12-03 16:24 ` [PATCH 6/8] perf data: Switch to multiple cpu stream files Jiri Olsa
2014-12-08 8:17 ` Namhyung Kim
2014-12-09 10:18 ` Jiri Olsa
2014-12-03 16:24 ` Jiri Olsa [this message]
2014-12-03 16:24 ` [PATCH 8/8] perf data: Add support for setting ordered_events queue size Jiri Olsa
-- strict thread matches above, loose matches on Subject: below --
2014-12-11 15:12 [PATCHv2 0/8] perf tools: Add perf data CTF conversion Jiri Olsa
2014-12-11 15:12 ` [PATCH 7/8] perf data: Enable stream flush within processing Jiri Olsa
2015-01-15 16:15 [PATCHv3 0/8] perf tools: Add perf data CTF conversion Jiri Olsa
2015-01-15 16:15 ` [PATCH 7/8] perf data: Enable stream flush within processing Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417623842-14331-8-git-send-email-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=acme@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=jgalar@efficios.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=tzanussi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox