From dcabb507fd3a2b19aed6b4068e2a954f5fd8de45 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Fri, 25 Jul 2014 16:56:16 +0200 Subject: perf record: Store PERF_RECORD_FINISHED_ROUND only for nonempty rounds Currently we store PERF_RECORD_FINISHED_ROUND event each time we go throught mmap buffers no matter if it contains any data, which is useless. Forcing the PERF_RECORD_FINISHED_ROUND event to be stored any time we finished the round AND wrote at least one event. Signed-off-by: Jiri Olsa Acked-by: Adrian Hunter Acked-by: David Ahern Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jean Pihet Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1406300177-31805-19-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4a1a54265b04..4869050e7194 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -238,6 +238,7 @@ static struct perf_event_header finished_round_event = { static int record__mmap_read_all(struct record *rec) { + u64 bytes_written = rec->bytes_written; int i; int rc = 0; @@ -250,7 +251,12 @@ static int record__mmap_read_all(struct record *rec) } } - rc = record__write(rec, &finished_round_event, sizeof(finished_round_event)); + /* + * Mark the round finished in case we wrote + * at least one event. + */ + if (bytes_written != rec->bytes_written) + rc = record__write(rec, &finished_round_event, sizeof(finished_round_event)); out: return rc; -- cgit v1.2.3