perf record: Add support for limit perf output file size
PATCH v4 1/1 perf record: Add support for limit perf output file size
The patch adds a new option to limit the output file size, then based on it, we can create a wrapper of the perf command that uses the option to avoid exhausting the disk space by the unconscious user.
In order to make the perf.data parsable, we just limit the sample data size, since the perf.data consists of many headers and sample data and other data, the actual size of the recorded file will bigger than the setting value.
Testing it:
# ./perf record -a -g --max-size=10M Couldn't synthesize bpf events. WARNING: The perf data has already reached the limit, stop recording! [ perf record: Woken up 30 times to write data ] [ perf record: Captured and wrote 10.233 MB perf.data (175650 samples) ] Terminated
# ls -lh perf.data -rw------- 1 root root 11M Jul 17 14:01 perf.data
# ./perf record -a -g --max-size=10K WARNING: The perf data has already reached the limit, stop recording! Couldn't synthesize bpf events. [ perf record: Woken up 0 times to write data ] [ perf record: Captured and wrote 1.824 MB perf.data (67 samples) ] Terminated
# ls -lh perf.data -rw------- 1 root root 1.9M Jul 17 14:05 perf.data
---
v4 changes:
- Just show one WARNING message after reached the limit.
v3 changes:
- add a test result
- add the new option to tools/perf/Documentation/perf-record.txt
v2 changes:
- make patch based on latest Arnaldo's perf/core,
- display warning message when reached the limit.
--- tools/perf/Documentation/perf-record.txt | 4 +++ tools/perf/builtin-record.c | 42 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
tools/perf/Documentation/perf-record.txt +4 -0
@@ -564,6 +564,10 @@ config terms. For example: 'cycles/overwrite/' and 'instructions/no-overwrite/'. Implies --tail-synthesize. +--max-size=<size>:: +Limit the sample data max size, <size> is expected to be a number with +appended unit character - B/K/M/G + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +42 -0
72 lines not on this page · raw message
Signature · 1 line
2.20.1