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