Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf record: Display data size on pipe mode

Currently pipe mode doesn't set the file size and it results in a
misleading message of 0 data size at the end. Although it might miss
some accounting for pipe header or more, just displaying the data size
would reduce the possible confusion.

Before:
$ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ] <====== (here)
99.58% perf perf [.] noploop

After:
$ perf record -o- perf test -w noploop | perf report -i- -q --percent-limit=1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.229 MB - ]
99.46% perf perf [.] noploop

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20240112231340.779469-1-namhyung@kernel.org

+4 -1
+4 -1
tools/perf/builtin-record.c
··· 1773 1773 struct perf_data *data = &rec->data; 1774 1774 int fd = perf_data__fd(data); 1775 1775 1776 - if (data->is_pipe) 1776 + if (data->is_pipe) { 1777 + /* Just to display approx. size */ 1778 + data->file.size = rec->bytes_written; 1777 1779 return; 1780 + } 1778 1781 1779 1782 rec->session->header.data_size += rec->bytes_written; 1780 1783 data->file.size = lseek(perf_data__fd(data), 0, SEEK_CUR);