Skip to content

Commit dcabb50

Browse files
olsajiriacmel
authored andcommitted
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 <jolsa@kernel.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: David 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/r/1406300177-31805-19-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 33bf748 commit dcabb50

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tools/perf/builtin-record.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ static struct perf_event_header finished_round_event = {
238238

239239
static int record__mmap_read_all(struct record *rec)
240240
{
241+
u64 bytes_written = rec->bytes_written;
241242
int i;
242243
int rc = 0;
243244

@@ -250,7 +251,12 @@ static int record__mmap_read_all(struct record *rec)
250251
}
251252
}
252253

253-
rc = record__write(rec, &finished_round_event, sizeof(finished_round_event));
254+
/*
255+
* Mark the round finished in case we wrote
256+
* at least one event.
257+
*/
258+
if (bytes_written != rec->bytes_written)
259+
rc = record__write(rec, &finished_round_event, sizeof(finished_round_event));
254260

255261
out:
256262
return rc;

0 commit comments

Comments
 (0)