1PERF-RECORD(1)                    perf Manual                   PERF-RECORD(1)
2
3
4

NAME

6       perf-record - Run a command and record its profile into perf.data
7

SYNOPSIS

9       perf record [-e <EVENT> | --event=EVENT] [-a] <command>
10       perf record [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]
11

DESCRIPTION

13       This command runs a command and gathers a performance counter profile
14       from it, into perf.data - without displaying anything.
15
16       This file can then be inspected later on, using perf report.
17

OPTIONS

19       <command>...
20           Any command you can specify in a shell.
21
22       -e, --event=
23           Select the PMU event. Selection can be:
24
25           •   a symbolic event name (use perf list to list all events)
26
27           •   a raw PMU event in the form of rN where N is a hexadecimal
28               value that represents the raw register encoding with the layout
29               of the event control registers as described by entries in
30               /sys/bus/event_source/devices/cpu/format/*.
31
32           •   a symbolic or raw PMU event followed by an optional colon and a
33               list of event modifiers, e.g., cpu-cycles:p. See the perf-
34               list(1) man page for details on event modifiers.
35
36           •   a symbolically formed PMU event like pmu/param1=0x3,param2/
37               where param1, param2, etc are defined as formats for the PMU in
38               /sys/bus/event_source/devices/<pmu>/format/*.
39
40           •   a symbolically formed event like
41               pmu/config=M,config1=N,config3=K/
42
43                   where M, N, K are numbers (in decimal, hex, octal format). Acceptable
44                   values for each of 'config', 'config1' and 'config2' are defined by
45                   corresponding entries in /sys/bus/event_source/devices/<pmu>/format/*
46                   param1 and param2 are defined as formats for the PMU in:
47                   /sys/bus/event_source/devices/<pmu>/format/*
48
49                   There are also some parameters which are not defined in .../<pmu>/format/*.
50                   These params can be used to overload default config values per event.
51                   Here are some common parameters:
52                   - 'period': Set event sampling period
53                   - 'freq': Set event sampling frequency
54                   - 'time': Disable/enable time stamping. Acceptable values are 1 for
55                             enabling time stamping. 0 for disabling time stamping.
56                             The default is 1.
57                   - 'call-graph': Disable/enable callgraph. Acceptable str are "fp" for
58                                  FP mode, "dwarf" for DWARF mode, "lbr" for LBR mode and
59                                  "no" for disable callgraph.
60                   - 'stack-size': user stack size for dwarf mode
61                   - 'name' : User defined event name. Single quotes (') may be used to
62                             escape symbols in the name from parsing by shell and tool
63                             like this: name=\'CPU_CLK_UNHALTED.THREAD:cmask=0x1\'.
64                   - 'aux-output': Generate AUX records instead of events. This requires
65                                   that an AUX area event is also provided.
66                   - 'aux-sample-size': Set sample size for AUX area sampling. If the
67                   '--aux-sample' option has been used, set aux-sample-size=0 to disable
68                   AUX area sampling for the event.
69
70                   See the linkperf:perf-list[1] man page for more parameters.
71
72                   Note: If user explicitly sets options which conflict with the params,
73                   the value set by the parameters will be overridden.
74
75                   Also not defined in .../<pmu>/format/* are PMU driver specific
76                   configuration parameters.  Any configuration parameter preceded by
77                   the letter '@' is not interpreted in user space and sent down directly
78                   to the PMU driver.  For example:
79
80                   perf record -e some_event/@cfg1,@cfg2=config/ ...
81
82                   will see 'cfg1' and 'cfg2=config' pushed to the PMU driver associated
83                   with the event for further processing.  There is no restriction on
84                   what the configuration parameters are, as long as their semantic is
85                   understood and supported by the PMU driver.
86
87           •   a hardware breakpoint event in the form of
88               \mem:addr[/len][:access] where addr is the address in memory
89               you want to break in. Access is the memory access type (read,
90               write, execute) it can be passed as follows:
91               \mem:addr[:[r][w][x]]. len is the range, number of bytes from
92               specified addr, which the breakpoint will cover. If you want to
93               profile read-write accesses in 0x1000, just set mem:0x1000:rw.
94               If you want to profile write accesses in [0x1000~1008), just
95               set mem:0x1000/8:w.
96
97           •   a BPF source file (ending in .c) or a precompiled object file
98               (ending in .o) selects one or more BPF events. The BPF program
99               can attach to various perf events based on the ELF section
100               names.
101
102                   When processing a '.c' file, perf searches an installed LLVM to compile it
103                   into an object file first. Optional clang options can be passed via the
104                   '--clang-opt' command line option, e.g.:
105
106                   perf record --clang-opt "-DLINUX_VERSION_CODE=0x50000" \
107                               -e tests/bpf-script-example.c
108
109                   Note: '--clang-opt' must be placed before '--event/-e'.
110
111           •   a group of events surrounded by a pair of brace
112               ("{event1,event2,...}"). Each event is separated by commas and
113               the group should be quoted to prevent the shell interpretation.
114               You also need to use --group on "perf report" to view group
115               events together.
116
117       --filter=<filter>
118           Event filter. This option should follow an event selector (-e)
119           which selects either tracepoint event(s) or a hardware trace PMU
120           (e.g. Intel PT or CoreSight).
121
122           •   tracepoint filters
123
124                   In the case of tracepoints, multiple '--filter' options are combined
125                   using '&&'.
126
127           •   address filters
128
129                   A hardware trace PMU advertises its ability to accept a number of
130                   address filters by specifying a non-zero value in
131                   /sys/bus/event_source/devices/<pmu>/nr_addr_filters.
132
133                   Address filters have the format:
134
135                   filter|start|stop|tracestop <start> [/ <size>] [@<file name>]
136
137                   Where:
138                   - 'filter': defines a region that will be traced.
139                   - 'start': defines an address at which tracing will begin.
140                   - 'stop': defines an address at which tracing will stop.
141                   - 'tracestop': defines a region in which tracing will stop.
142
143                   <file name> is the name of the object file, <start> is the offset to the
144                   code to trace in that file, and <size> is the size of the region to
145                   trace. 'start' and 'stop' filters need not specify a <size>.
146
147                   If no object file is specified then the kernel is assumed, in which case
148                   the start address must be a current kernel memory address.
149
150                   <start> can also be specified by providing the name of a symbol. If the
151                   symbol name is not unique, it can be disambiguated by inserting #n where
152                   'n' selects the n'th symbol in address order. Alternately #0, #g or #G
153                   select only a global symbol. <size> can also be specified by providing
154                   the name of a symbol, in which case the size is calculated to the end
155                   of that symbol. For 'filter' and 'tracestop' filters, if <size> is
156                   omitted and <start> is a symbol, then the size is calculated to the end
157                   of that symbol.
158
159                   If <size> is omitted and <start> is '*', then the start and size will
160                   be calculated from the first and last symbols, i.e. to trace the whole
161                   file.
162
163                   If symbol names (or '*') are provided, they must be surrounded by white
164                   space.
165
166                   The filter passed to the kernel is not necessarily the same as entered.
167                   To see the filter that is passed, use the -v option.
168
169                   The kernel may not be able to configure a trace region if it is not
170                   within a single mapping.  MMAP events (or /proc/<pid>/maps) can be
171                   examined to determine if that is a possibility.
172
173                   Multiple filters can be separated with space or comma.
174
175       --exclude-perf
176           Don’t record events issued by perf itself. This option should
177           follow an event selector (-e) which selects tracepoint event(s). It
178           adds a filter expression common_pid != $PERFPID to filters. If
179           other --filter exists, the new filter expression will be combined
180           with them by &&.
181
182       -a, --all-cpus
183           System-wide collection from all CPUs (default if no target is
184           specified).
185
186       -p, --pid=
187           Record events on existing process ID (comma separated list).
188
189       -t, --tid=
190           Record events on existing thread ID (comma separated list). This
191           option also disables inheritance by default. Enable it by adding
192           --inherit.
193
194       -u, --uid=
195           Record events in threads owned by uid. Name or number.
196
197       -r, --realtime=
198           Collect data with this RT SCHED_FIFO priority.
199
200       --no-buffering
201           Collect data without buffering.
202
203       -c, --count=
204           Event period to sample.
205
206       -o, --output=
207           Output file name.
208
209       -i, --no-inherit
210           Child tasks do not inherit counters.
211
212       -F, --freq=
213           Profile at this frequency. Use max to use the currently maximum
214           allowed frequency, i.e. the value in the
215           kernel.perf_event_max_sample_rate sysctl. Will throttle down to the
216           currently maximum allowed frequency. See --strict-freq.
217
218       --strict-freq
219           Fail if the specified frequency can’t be used.
220
221       -m, --mmap-pages=
222           Number of mmap data pages (must be a power of two) or size
223           specification with appended unit character - B/K/M/G. The size is
224           rounded up to have nearest pages power of two value. Also, by
225           adding a comma, the number of mmap pages for AUX area tracing can
226           be specified.
227
228       --group
229           Put all events in a single event group. This precedes the --event
230           option and remains only for backward compatibility. See --event.
231
232       -g
233           Enables call-graph (stack chain/backtrace) recording for both
234           kernel space and user space.
235
236       --call-graph
237           Setup and enable call-graph (stack chain/backtrace) recording,
238           implies -g. Default is "fp" (for user space).
239
240               The unwinding method used for kernel space is dependent on the
241               unwinder used by the active kernel configuration, i.e
242               CONFIG_UNWINDER_FRAME_POINTER (fp) or CONFIG_UNWINDER_ORC (orc)
243
244               Any option specified here controls the method used for user space.
245
246               Valid options are "fp" (frame pointer), "dwarf" (DWARF's CFI -
247               Call Frame Information) or "lbr" (Hardware Last Branch Record
248               facility).
249
250               In some systems, where binaries are build with gcc
251               --fomit-frame-pointer, using the "fp" method will produce bogus
252               call graphs, using "dwarf", if available (perf tools linked to
253               the libunwind or libdw library) should be used instead.
254               Using the "lbr" method doesn't require any compiler options. It
255               will produce call graphs from the hardware LBR registers. The
256               main limitation is that it is only available on new Intel
257               platforms, such as Haswell. It can only get user call chain. It
258               doesn't work with branch stack sampling at the same time.
259
260               When "dwarf" recording is used, perf also records (user) stack dump
261               when sampled.  Default size of the stack dump is 8192 (bytes).
262               User can change the size by passing the size after comma like
263               "--call-graph dwarf,4096".
264
265               When "fp" recording is used, perf tries to save stack enties
266               up to the number specified in sysctl.kernel.perf_event_max_stack
267               by default.  User can change the number by passing it after comma
268               like "--call-graph fp,32".
269
270       -q, --quiet
271           Don’t print any warnings or messages, useful for scripting.
272
273       -v, --verbose
274           Be more verbose (show counter open errors, etc).
275
276       -s, --stat
277           Record per-thread event counts. Use it with perf report -T to see
278           the values.
279
280       -d, --data
281           Record the sample virtual addresses.
282
283       --phys-data
284           Record the sample physical addresses.
285
286       --data-page-size
287           Record the sampled data address data page size.
288
289       --code-page-size
290           Record the sampled code address (ip) page size
291
292       -T, --timestamp
293           Record the sample timestamps. Use it with perf report -D to see the
294           timestamps, for instance.
295
296       -P, --period
297           Record the sample period.
298
299       --sample-cpu
300           Record the sample cpu.
301
302       --sample-identifier
303           Record the sample identifier i.e. PERF_SAMPLE_IDENTIFIER bit set in
304           the sample_type member of the struct perf_event_attr argument to
305           the perf_event_open system call.
306
307       -n, --no-samples
308           Don’t sample.
309
310       -R, --raw-samples
311           Collect raw sample records from all opened counters (default for
312           tracepoint counters).
313
314       -C, --cpu
315           Collect samples only on the list of CPUs provided. Multiple CPUs
316           can be provided as a comma-separated list with no space: 0,1.
317           Ranges of CPUs are specified with -: 0-2. In per-thread mode with
318           inheritance mode on (default), samples are captured only when the
319           thread executes on the designated CPUs. Default is to monitor all
320           CPUs.
321
322       -B, --no-buildid
323           Do not save the build ids of binaries in the perf.data files. This
324           skips post processing after recording, which sometimes makes the
325           final step in the recording process to take a long time, as it
326           needs to process all events looking for mmap records. The downside
327           is that it can misresolve symbols if the workload binaries used
328           when recording get locally rebuilt or upgraded, because the only
329           key available in this case is the pathname. You can also set the
330           "record.build-id" config variable to 'skip to have this behaviour
331           permanently.
332
333       -N, --no-buildid-cache
334           Do not update the buildid cache. This saves some overhead in
335           situations where the information in the perf.data file (which
336           includes buildids) is sufficient. You can also set the
337           "record.build-id" config variable to no-cache to have the same
338           effect.
339
340       -G name,..., --cgroup name,...
341           monitor only in the container (cgroup) called "name". This option
342           is available only in per-cpu mode. The cgroup filesystem must be
343           mounted. All threads belonging to container "name" are monitored
344           when they run on the monitored CPUs. Multiple cgroups can be
345           provided. Each cgroup is applied to the corresponding event, i.e.,
346           first cgroup to first event, second cgroup to second event and so
347           on. It is possible to provide an empty cgroup (monitor all the
348           time) using, e.g., -G foo,,bar. Cgroups must have corresponding
349           events, i.e., they always refer to events defined earlier on the
350           command line. If the user wants to track multiple events for a
351           specific cgroup, the user can use -e e1 -e e2 -G foo,foo or just
352           use -e e1 -e e2 -G foo.
353
354       If wanting to monitor, say, cycles for a cgroup and also for system
355       wide, this command line can be used: perf stat -e cycles -G cgroup_name
356       -a -e cycles.
357
358       -b, --branch-any
359           Enable taken branch stack sampling. Any type of taken branch may be
360           sampled. This is a shortcut for --branch-filter any. See
361           --branch-filter for more infos.
362
363       -j, --branch-filter
364           Enable taken branch stack sampling. Each sample captures a series
365           of consecutive taken branches. The number of branches captured with
366           each sample depends on the underlying hardware, the type of
367           branches of interest, and the executed code. It is possible to
368           select the types of branches captured by enabling filters. The
369           following filters are defined:
370
371           •   any: any type of branches
372
373           •   any_call: any function call or system call
374
375           •   any_ret: any function return or system call return
376
377           •   ind_call: any indirect branch
378
379           •   call: direct calls, including far (to/from kernel) calls
380
381           •   u: only when the branch target is at the user level
382
383           •   k: only when the branch target is in the kernel
384
385           •   hv: only when the target is at the hypervisor level
386
387           •   in_tx: only when the target is in a hardware transaction
388
389           •   no_tx: only when the target is not in a hardware transaction
390
391           •   abort_tx: only when the target is a hardware transaction abort
392
393           •   cond: conditional branches
394
395           •   save_type: save branch type during sampling in case binary is
396               not available later For the platforms with Intel Arch LBR
397               support (12th-Gen+ client or 4th-Gen Xeon+ server), the save
398               branch type is unconditionally enabled when the taken branch
399               stack sampling is enabled.
400
401           •   priv: save privilege state during sampling in case binary is
402               not available later
403
404           The option requires at least one branch type among any, any_call,
405           any_ret, ind_call, cond. The privilege levels may be omitted, in
406           which case, the privilege levels of the associated event are
407           applied to the branch filter. Both kernel (k) and hypervisor (hv)
408           privilege levels are subject to permissions. When sampling on
409           multiple events, branch stack sampling is enabled for all the
410           sampling events. The sampled branch type is the same for all
411           events. The various filters must be specified as a comma separated
412           list: --branch-filter any_ret,u,k Note that this feature may not be
413           available on all processors.
414
415       -W, --weight
416           Enable weightened sampling. An additional weight is recorded per
417           sample and can be displayed with the weight and local_weight sort
418           keys. This currently works for TSX abort events and some memory
419           events in precise mode on modern Intel CPUs.
420
421       --namespaces
422           Record events of type PERF_RECORD_NAMESPACES. This enables
423           cgroup_id sort key.
424
425       --all-cgroups
426           Record events of type PERF_RECORD_CGROUP. This enables cgroup sort
427           key.
428
429       --transaction
430           Record transaction flags for transaction related events.
431
432       --per-thread
433           Use per-thread mmaps. By default per-cpu mmaps are created. This
434           option overrides that and uses per-thread mmaps. A side-effect of
435           that is that inheritance is automatically disabled. --per-thread is
436           ignored with a warning if combined with -a or -C options.
437
438       -D, --delay=
439           After starting the program, wait msecs before measuring (-1: start
440           with events disabled), or enable events only for specified ranges
441           of msecs (e.g. -D 10-20,30-40 means wait 10 msecs, enable for 10
442           msecs, wait 10 msecs, enable for 10 msecs, then stop). Note,
443           delaying enabling of events is useful to filter out the startup
444           phase of the program, which is often very different.
445
446       -I, --intr-regs
447           Capture machine state (registers) at interrupt, i.e., on counter
448           overflows for each sample. List of captured registers depends on
449           the architecture. This option is off by default. It is possible to
450           select the registers to sample using their symbolic names, e.g. on
451           x86, ax, si. To list the available registers use --intr-regs=\?. To
452           name registers, pass a comma separated list such as
453           --intr-regs=ax,bx. The list of register is architecture dependent.
454
455       --user-regs
456           Similar to -I, but capture user registers at sample time. To list
457           the available user registers use --user-regs=\?.
458
459       --running-time
460           Record running and enabled time for read events (:S)
461
462       -k, --clockid
463           Sets the clock id to use for the various time fields in the
464           perf_event_type records. See clock_gettime(). In particular
465           CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW are supported, some events
466           might also allow CLOCK_BOOTTIME, CLOCK_REALTIME and CLOCK_TAI.
467
468       -S, --snapshot
469           Select AUX area tracing Snapshot Mode. This option is valid only
470           with an AUX area tracing event. Optionally, certain snapshot
471           capturing parameters can be specified in a string that follows this
472           option: e: take one last snapshot on exit; guarantees that there is
473           at least one snapshot in the output file; <size>: if the PMU
474           supports this, specify the desired snapshot size.
475
476       In Snapshot Mode trace data is captured only when signal SIGUSR2 is
477       received and on exit if the above e option is given.
478
479       --aux-sample[=OPTIONS]
480           Select AUX area sampling. At least one of the events selected by
481           the -e option must be an AUX area event. Samples on other events
482           will be created containing data from the AUX area. Optionally
483           sample size may be specified, otherwise it defaults to 4KiB.
484
485       --proc-map-timeout
486           When processing pre-existing threads /proc/XXX/mmap, it may take a
487           long time, because the file may be huge. A time out is needed in
488           such cases. This option sets the time out limit. The default value
489           is 500 ms.
490
491       --switch-events
492           Record context switch events i.e. events of type PERF_RECORD_SWITCH
493           or PERF_RECORD_SWITCH_CPU_WIDE. In some cases (e.g. Intel PT,
494           CoreSight or Arm SPE) switch events will be enabled automatically,
495           which can be suppressed by by the option --no-switch-events.
496
497       --clang-path=PATH
498           Path to clang binary to use for compiling BPF scriptlets. (enabled
499           when BPF support is on)
500
501       --clang-opt=OPTIONS
502           Options passed to clang when compiling BPF scriptlets. (enabled
503           when BPF support is on)
504
505       --vmlinux=PATH
506           Specify vmlinux path which has debuginfo. (enabled when BPF
507           prologue is on)
508
509       --buildid-all
510           Record build-id of all DSOs regardless whether it’s actually hit or
511           not.
512
513       --buildid-mmap
514           Record build ids in mmap2 events, disables build id cache (implies
515           --no-buildid).
516
517       --aio[=n]
518           Use <n> control blocks in asynchronous (Posix AIO) trace writing
519           mode (default: 1, max: 4). Asynchronous mode is supported only when
520           linking Perf tool with libc library providing implementation for
521           Posix AIO API.
522
523       --affinity=mode
524           Set affinity mask of trace reading thread according to the policy
525           defined by mode value: node - thread affinity mask is set to NUMA
526           node cpu mask of the processed mmap buffer cpu - thread affinity
527           mask is set to cpu of the processed mmap buffer
528
529       --mmap-flush=number
530           Specify minimal number of bytes that is extracted from mmap data
531           pages and processed for output. One can specify the number using
532           B/K/M/G suffixes.
533
534       The maximal allowed value is a quarter of the size of mmaped data
535       pages.
536
537       The default option value is 1 byte which means that every time that the
538       output writing thread finds some new data in the mmaped buffer the data
539       is extracted, possibly compressed (-z) and written to the output,
540       perf.data or pipe.
541
542       Larger data chunks are compressed more effectively in comparison to
543       smaller chunks so extraction of larger chunks from the mmap data pages
544       is preferable from the perspective of output size reduction.
545
546       Also at some cases executing less output write syscalls with bigger
547       data size can take less time than executing more output write syscalls
548       with smaller data size thus lowering runtime profiling overhead.
549
550       -z, --compression-level[=n]
551           Produce compressed trace using specified level n (default: 1 -
552           fastest compression, 22 - smallest trace)
553
554       --all-kernel
555           Configure all used events to run in kernel space.
556
557       --all-user
558           Configure all used events to run in user space.
559
560       --kernel-callchains
561           Collect callchains only from kernel space. I.e. this option sets
562           perf_event_attr.exclude_callchain_user to 1.
563
564       --user-callchains
565           Collect callchains only from user space. I.e. this option sets
566           perf_event_attr.exclude_callchain_kernel to 1.
567
568       Don’t use both --kernel-callchains and --user-callchains at the same
569       time or no callchains will be collected.
570
571       --timestamp-filename Append timestamp to output file name.
572
573       --timestamp-boundary
574           Record timestamp boundary (time of first/last samples).
575
576       --switch-output[=mode]
577           Generate multiple perf.data files, timestamp prefixed, switching to
578           a new one based on mode value: "signal" - when receiving a SIGUSR2
579           (default value) or <size> - when reaching the size threshold, size
580           is expected to be a number with appended unit character - B/K/M/G
581           <time> - when reaching the time threshold, size is expected to be a
582           number with appended unit character - s/m/h/d
583
584               Note: the precision of  the size  threshold  hugely depends
585               on your configuration  - the number and size of  your  ring
586               buffers (-m). It is generally more precise for higher sizes
587               (like >5M), for lower values expect different sizes.
588
589       A possible use case is to, given an external event, slice the perf.data
590       file that gets then processed, possibly via a perf script, to decide if
591       that particular perf.data snapshot should be kept or not.
592
593       Implies --timestamp-filename, --no-buildid and --no-buildid-cache. The
594       reason for the latter two is to reduce the data file switching
595       overhead. You can still switch them on with:
596
597           --switch-output --no-no-buildid  --no-no-buildid-cache
598
599       --switch-output-event
600           Events that will cause the switch of the perf.data file,
601           auto-selecting --switch-output=signal, the results are similar as
602           internally the side band thread will also send a SIGUSR2 to the
603           main one.
604
605       Uses the same syntax as --event, it will just not be recorded, serving
606       only to switch the perf.data file as soon as the --switch-output event
607       is processed by a separate sideband thread.
608
609       This sideband thread is also used to other purposes, like processing
610       the PERF_RECORD_BPF_EVENT records as they happen, asking the kernel for
611       extra BPF information, etc.
612
613       --switch-max-files=N
614           When rotating perf.data with --switch-output, only keep N files.
615
616       --dry-run
617           Parse options then exit. --dry-run can be used to detect errors in
618           cmdline options.
619
620       perf record --dry-run -e can act as a BPF script compiler if
621       llvm.dump-obj in config file is set to true.
622
623       --synth=TYPE
624           Collect and synthesize given type of events (comma separated). Note
625           that this option controls the synthesis from the /proc filesystem
626           which represent task status for pre-existing threads.
627
628       Kernel (and some other) events are recorded regardless of the choice in
629       this option. For example, --synth=no would have MMAP events for kernel
630       and modules.
631
632       Available types are: task - synthesize FORK and COMM events for each
633       task mmap - synthesize MMAP events for each process (implies task)
634       cgroup - synthesize CGROUP events for each cgroup all - synthesize all
635       events (default) no - do not synthesize any of the above events
636
637       --tail-synthesize
638           Instead of collecting non-sample events (for example, fork, comm,
639           mmap) at the beginning of record, collect them during finalizing an
640           output file. The collected non-sample events reflects the status of
641           the system when record is finished.
642
643       --overwrite
644           Makes all events use an overwritable ring buffer. An overwritable
645           ring buffer works like a flight recorder: when it gets full, the
646           kernel will overwrite the oldest records, that thus will never make
647           it to the perf.data file.
648
649       When --overwrite and --switch-output are used perf records and drops
650       events until it receives a signal, meaning that something unusual was
651       detected that warrants taking a snapshot of the most current events,
652       those fitting in the ring buffer at that moment.
653
654       overwrite attribute can also be set or canceled for an event using
655       config terms. For example: cycles/overwrite/ and
656       instructions/no-overwrite/.
657
658       Implies --tail-synthesize.
659
660       --kcore
661           Make a copy of /proc/kcore and place it into a directory with the
662           perf data file.
663
664       --max-size=<size>
665           Limit the sample data max size, <size> is expected to be a number
666           with appended unit character - B/K/M/G
667
668       --num-thread-synthesize
669           The number of threads to run when synthesizing events for existing
670           processes. By default, the number of threads equals 1.
671
672       --control=fifo:ctl-fifo[,ack-fifo], --control=fd:ctl-fd[,ack-fd]
673           ctl-fifo / ack-fifo are opened and used as ctl-fd / ack-fd as
674           follows. Listen on ctl-fd descriptor for command to control
675           measurement.
676
677       Available commands: enable : enable events disable : disable events
678       enable name : enable event name disable name : disable event name
679       snapshot : AUX area tracing snapshot). stop : stop perf record ping :
680       ping
681
682           'evlist [-v|-g|-F] : display all events
683                                -F  Show just the sample frequency used for each event.
684                                -v  Show all fields.
685                                -g  Show event group information.
686
687       Measurements can be started with events disabled using --delay=-1
688       option. Optionally send control command completion (ack\n) to ack-fd
689       descriptor to synchronize with the controlling process. Example of bash
690       shell script to enable and disable events during measurements:
691
692           #!/bin/bash
693
694           ctl_dir=/tmp/
695
696           ctl_fifo=${ctl_dir}perf_ctl.fifo
697           test -p ${ctl_fifo} && unlink ${ctl_fifo}
698           mkfifo ${ctl_fifo}
699           exec {ctl_fd}<>${ctl_fifo}
700
701           ctl_ack_fifo=${ctl_dir}perf_ctl_ack.fifo
702           test -p ${ctl_ack_fifo} && unlink ${ctl_ack_fifo}
703           mkfifo ${ctl_ack_fifo}
704           exec {ctl_fd_ack}<>${ctl_ack_fifo}
705
706           perf record -D -1 -e cpu-cycles -a               \
707                       --control fd:${ctl_fd},${ctl_fd_ack} \
708                       -- sleep 30 &
709           perf_pid=$!
710
711           sleep 5  && echo 'enable' >&${ctl_fd} && read -u ${ctl_fd_ack} e1 && echo "enabled(${e1})"
712           sleep 10 && echo 'disable' >&${ctl_fd} && read -u ${ctl_fd_ack} d1 && echo "disabled(${d1})"
713
714           exec {ctl_fd_ack}>&-
715           unlink ${ctl_ack_fifo}
716
717           exec {ctl_fd}>&-
718           unlink ${ctl_fifo}
719
720           wait -n ${perf_pid}
721           exit $?
722
723       --threads=<spec>
724           Write collected trace data into several data files using parallel
725           threads. <spec> value can be user defined list of masks. Masks
726           separated by colon define CPUs to be monitored by a thread and
727           affinity mask of that thread is separated by slash:
728
729               <cpus mask 1>/<affinity mask 1>:<cpus mask 2>/<affinity mask 2>:...
730
731       CPUs or affinity masks must not overlap with other corresponding masks.
732       Invalid CPUs are ignored, but masks containing only invalid CPUs are
733       not allowed.
734
735       For example user specification like the following:
736
737           0,2-4/2-4:1,5-7/5-7
738
739       specifies parallel threads layout that consists of two threads, the
740       first thread monitors CPUs 0 and 2-4 with the affinity mask 2-4, the
741       second monitors CPUs 1 and 5-7 with the affinity mask 5-7.
742
743       <spec> value can also be a string meaning predefined parallel threads
744       layout:
745
746           cpu    - create new data streaming thread for every monitored cpu
747           core   - create new thread to monitor CPUs grouped by a core
748           package - create new thread to monitor CPUs grouped by a package
749           numa   - create new threed to monitor CPUs grouped by a NUMA domain
750
751       Predefined layouts can be used on systems with large number of CPUs in
752       order not to spawn multiple per-cpu streaming threads but still avoid
753       LOST events in data directory files. Option specified with no or empty
754       value defaults to CPU layout. Masks defined or provided by the option
755       value are filtered through the mask provided by -C option.
756
757       --debuginfod[=URLs]
758           Specify debuginfod URL to be used when cacheing perf.data binaries,
759           it follows the same syntax as the DEBUGINFOD_URLS variable, like:
760
761               http://192.168.122.174:8002
762
763               If the URLs is not specified, the value of DEBUGINFOD_URLS
764               system environment variable is used.
765
766       --off-cpu
767           Enable off-cpu profiling with BPF. The BPF program will collect
768           task scheduling information with (user) stacktrace and save them as
769           sample data of a software event named "offcpu-time". The sample
770           period will have the time the task slept in nanoseconds.
771
772               Note that BPF can collect stack traces using frame pointer ("fp")
773               only, as of now.  So the applications built without the frame
774               pointer might see bogus addresses.
775

INTEL HYBRID SUPPORT

777       Support for Intel hybrid events within perf tools.
778
779       For some Intel platforms, such as AlderLake, which is hybrid platform
780       and it consists of atom cpu and core cpu. Each cpu has dedicated event
781       list. Part of events are available on core cpu, part of events are
782       available on atom cpu and even part of events are available on both.
783
784       Kernel exports two new cpu pmus via sysfs: /sys/devices/cpu_core
785       /sys/devices/cpu_atom
786
787       The cpus files are created under the directories. For example,
788
789       cat /sys/devices/cpu_core/cpus 0-15
790
791       cat /sys/devices/cpu_atom/cpus 16-23
792
793       It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus.
794
795       As before, use perf-list to list the symbolic event.
796
797       perf list
798
799       inst_retired.any [Fixed Counter: Counts the number of instructions
800       retired. Unit: cpu_atom] inst_retired.any [Number of instructions
801       retired. Fixed Counter - architectural event. Unit: cpu_core]
802
803       The Unit: xxx is added to brief description to indicate which pmu the
804       event is belong to. Same event name but with different pmu can be
805       supported.
806
807       Enable hybrid event with a specific pmu
808
809       To enable a core only event or atom only event, following syntax is
810       supported:
811
812                   cpu_core/<event name>/
813           or
814                   cpu_atom/<event name>/
815
816       For example, count the cycles event on core cpus.
817
818           perf stat -e cpu_core/cycles/
819
820       Create two events for one hardware event automatically
821
822       When creating one event and the event is available on both atom and
823       core, two events are created automatically. One is for atom, the other
824       is for core. Most of hardware events and cache events are available on
825       both cpu_core and cpu_atom.
826
827       For hardware events, they have pre-defined configs (e.g. 0 for cycles).
828       But on hybrid platform, kernel needs to know where the event comes from
829       (from atom or from core). The original perf event type
830       PERF_TYPE_HARDWARE can’t carry pmu information. So now this type is
831       extended to be PMU aware type. The PMU type ID is stored at
832       attr.config[63:32].
833
834       PMU type ID is retrieved from sysfs. /sys/devices/cpu_atom/type
835       /sys/devices/cpu_core/type
836
837       The new attr.config layout for PERF_TYPE_HARDWARE:
838
839       PERF_TYPE_HARDWARE: 0xEEEEEEEE000000AA AA: hardware event ID EEEEEEEE:
840       PMU type ID
841
842       Cache event is similar. The type PERF_TYPE_HW_CACHE is extended to be
843       PMU aware type. The PMU type ID is stored at attr.config[63:32].
844
845       The new attr.config layout for PERF_TYPE_HW_CACHE:
846
847       PERF_TYPE_HW_CACHE: 0xEEEEEEEE00DDCCBB BB: hardware cache ID CC:
848       hardware cache op ID DD: hardware cache op result ID EEEEEEEE: PMU type
849       ID
850
851       When enabling a hardware event without specified pmu, such as, perf
852       stat -e cycles -a (use system-wide in this example), two events are
853       created automatically.
854
855           ------------------------------------------------------------
856           perf_event_attr:
857             size                             120
858             config                           0x400000000
859             sample_type                      IDENTIFIER
860             read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
861             disabled                         1
862             inherit                          1
863             exclude_guest                    1
864           ------------------------------------------------------------
865
866       and
867
868           ------------------------------------------------------------
869           perf_event_attr:
870             size                             120
871             config                           0x800000000
872             sample_type                      IDENTIFIER
873             read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
874             disabled                         1
875             inherit                          1
876             exclude_guest                    1
877           ------------------------------------------------------------
878
879       type 0 is PERF_TYPE_HARDWARE. 0x4 in 0x400000000 indicates it’s
880       cpu_core pmu. 0x8 in 0x800000000 indicates it’s cpu_atom pmu (atom pmu
881       type id is random).
882
883       The kernel creates cycles (0x400000000) on cpu0-cpu15 (core cpus), and
884       create cycles (0x800000000) on cpu16-cpu23 (atom cpus).
885
886       For perf-stat result, it displays two events:
887
888           Performance counter stats for 'system wide':
889
890           6,744,979      cpu_core/cycles/
891           1,965,552      cpu_atom/cycles/
892
893       The first cycles is core event, the second cycles is atom event.
894
895       Thread mode example:
896
897       perf-stat reports the scaled counts for hybrid event and with a
898       percentage displayed. The percentage is the event’s running
899       time/enabling time.
900
901       One example, triad_loop runs on cpu16 (atom core), while we can see the
902       scaled value for core cycles is 160,444,092 and the percentage is
903       0.47%.
904
905       perf stat -e cycles -- taskset -c 16 ./triad_loop
906
907       As previous, two events are created.
908
909
910           .ft C
911           perf_event_attr:
912             size                             120
913             config                           0x400000000
914             sample_type                      IDENTIFIER
915             read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
916             disabled                         1
917             inherit                          1
918             enable_on_exec                   1
919             exclude_guest                    1
920           .ft
921
922
923       and
924
925
926           .ft C
927           perf_event_attr:
928             size                             120
929             config                           0x800000000
930             sample_type                      IDENTIFIER
931             read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
932             disabled                         1
933             inherit                          1
934             enable_on_exec                   1
935             exclude_guest                    1
936           .ft
937
938
939           Performance counter stats for 'taskset -c 16 ./triad_loop':
940
941           233,066,666      cpu_core/cycles/                                              (0.43%)
942           604,097,080      cpu_atom/cycles/                                              (99.57%)
943
944       perf-record:
945
946       If there is no -e specified in perf record, on hybrid platform, it
947       creates two default cycles and adds them to event list. One is for
948       core, the other is for atom.
949
950       perf-stat:
951
952       If there is no -e specified in perf stat, on hybrid platform, besides
953       of software events, following events are created and added to event
954       list in order.
955
956       cpu_core/cycles/, cpu_atom/cycles/, cpu_core/instructions/,
957       cpu_atom/instructions/, cpu_core/branches/, cpu_atom/branches/,
958       cpu_core/branch-misses/, cpu_atom/branch-misses/
959
960       Of course, both perf-stat and perf-record support to enable hybrid
961       event with a specific pmu.
962
963       e.g. perf stat -e cpu_core/cycles/ perf stat -e cpu_atom/cycles/ perf
964       stat -e cpu_core/r1a/ perf stat -e cpu_atom/L1-icache-loads/ perf stat
965       -e cpu_core/cycles/,cpu_atom/instructions/ perf stat -e
966       {cpu_core/cycles/,cpu_core/instructions/}
967
968       But {cpu_core/cycles/,cpu_atom/instructions/} will return warning and
969       disable grouping, because the pmus in group are not matched (cpu_core
970       vs. cpu_atom).
971

SEE ALSO

973       perf-stat(1), perf-list(1), perf-intel-pt(1)
974
975
976
977perf                              01/12/2023                    PERF-RECORD(1)
Impressum