As @osgx has already mentioned, the tool to look inside the perf.data
file is perf script
. perf script -D
dumps raw events from the perf.data
file in the hex format.
The perf.data
file contains all the events generated by the Performance Monitoring Units, plus some metadata. The on-disk perf.data
file usually begins with a perf_header
struct of the form below -
struct perf_header {
char magic[8]; /* PERFILE2 */
uint64_t size; /* size of the header */
uint64_t attr_size; /* size of an attribute in attrs */
struct perf_file_section attrs;
struct perf_file_section data;
struct perf_file_section event_types;
uint64_t flags;
uint64_t flags1[3];
};
The bulk of the perf.data
file includes perf events, which can include any of the event types mentioned here that contain metadata about each of the events, like the 32-bit process id and thread id, instruction pointer, information about the CPU being used etc. Storage of this metadata is subject to various flags being passed, like PERF_SAMPLE_PID
or PERF_SAMPLE_TID
etc. Look into the perf_event_open
manpage. You can disable recording some of the metadata and reduce the size of each event data being written to the file.
The PERF_RECORD_COMM
, PERF_RECORD_FORK
and PERF_RECORD_MMAP
etc. are sideband events recorded by the kernel, to help in further post-processing and detailed analysis. They are enabled by default in the kernel source code, which can be seen here.
struct perf_event_attr {
........
mmap : 1, /* include mmap data */
comm : 1, /* include comm data */
freq : 1, /* use freq, not period */
inherit_stat : 1, /* per task counts */
enable_on_exec : 1, /* next exec enables */
task : 1, /* trace fork/exit */
Having 1 in these fields means they are enabled by default, and to disable logging of these events, you'd have to make them 0 in the source code and recompile only the userspace perf module of the kernel. If set to 0, these events will not be recorded as can be seen here.
There are no command line switches or options with perf record
, that would enable these events to be disabled.
perf script
. It will dump every event recorded in the file. Also supports-D
option to add hex dump:perf script -D
. You asked perf to do system-wide recording with-a
options, and to be able to decode events in any program it must to record every program starting and exec segments mmaping for all 1800 seconds on every cpu. Don't know how to avoid recording these events in perf with option (perf by default asks OS to record with perf_event_open syscall args). You should check tracing tools like bpf (brendangregg.com/ebpf.html) or lttng. – osgx