162306a36Sopenharmony_ciperf-record(1) 262306a36Sopenharmony_ci============== 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciNAME 562306a36Sopenharmony_ci---- 662306a36Sopenharmony_ciperf-record - Run a command and record its profile into perf.data 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciSYNOPSIS 962306a36Sopenharmony_ci-------- 1062306a36Sopenharmony_ci[verse] 1162306a36Sopenharmony_ci'perf record' [-e <EVENT> | --event=EVENT] [-a] <command> 1262306a36Sopenharmony_ci'perf record' [-e <EVENT> | --event=EVENT] [-a] \-- <command> [<options>] 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciDESCRIPTION 1562306a36Sopenharmony_ci----------- 1662306a36Sopenharmony_ciThis command runs a command and gathers a performance counter profile 1762306a36Sopenharmony_cifrom it, into perf.data - without displaying anything. 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ciThis file can then be inspected later on, using 'perf report'. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciOPTIONS 2362306a36Sopenharmony_ci------- 2462306a36Sopenharmony_ci<command>...:: 2562306a36Sopenharmony_ci Any command you can specify in a shell. 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci-e:: 2862306a36Sopenharmony_ci--event=:: 2962306a36Sopenharmony_ci Select the PMU event. Selection can be: 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci - a symbolic event name (use 'perf list' to list all events) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci - a raw PMU event in the form of rN where N is a hexadecimal value 3462306a36Sopenharmony_ci that represents the raw register encoding with the layout of the 3562306a36Sopenharmony_ci event control registers as described by entries in 3662306a36Sopenharmony_ci /sys/bus/event_source/devices/cpu/format/*. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci - a symbolic or raw PMU event followed by an optional colon 3962306a36Sopenharmony_ci and a list of event modifiers, e.g., cpu-cycles:p. See the 4062306a36Sopenharmony_ci linkperf:perf-list[1] man page for details on event modifiers. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where 4362306a36Sopenharmony_ci 'param1', 'param2', etc are defined as formats for the PMU in 4462306a36Sopenharmony_ci /sys/bus/event_source/devices/<pmu>/format/*. 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci - a symbolically formed event like 'pmu/config=M,config1=N,config3=K/' 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci where M, N, K are numbers (in decimal, hex, octal format). Acceptable 4962306a36Sopenharmony_ci values for each of 'config', 'config1' and 'config2' are defined by 5062306a36Sopenharmony_ci corresponding entries in /sys/bus/event_source/devices/<pmu>/format/* 5162306a36Sopenharmony_ci param1 and param2 are defined as formats for the PMU in: 5262306a36Sopenharmony_ci /sys/bus/event_source/devices/<pmu>/format/* 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci There are also some parameters which are not defined in .../<pmu>/format/*. 5562306a36Sopenharmony_ci These params can be used to overload default config values per event. 5662306a36Sopenharmony_ci Here are some common parameters: 5762306a36Sopenharmony_ci - 'period': Set event sampling period 5862306a36Sopenharmony_ci - 'freq': Set event sampling frequency 5962306a36Sopenharmony_ci - 'time': Disable/enable time stamping. Acceptable values are 1 for 6062306a36Sopenharmony_ci enabling time stamping. 0 for disabling time stamping. 6162306a36Sopenharmony_ci The default is 1. 6262306a36Sopenharmony_ci - 'call-graph': Disable/enable callgraph. Acceptable str are "fp" for 6362306a36Sopenharmony_ci FP mode, "dwarf" for DWARF mode, "lbr" for LBR mode and 6462306a36Sopenharmony_ci "no" for disable callgraph. 6562306a36Sopenharmony_ci - 'stack-size': user stack size for dwarf mode 6662306a36Sopenharmony_ci - 'name' : User defined event name. Single quotes (') may be used to 6762306a36Sopenharmony_ci escape symbols in the name from parsing by shell and tool 6862306a36Sopenharmony_ci like this: name=\'CPU_CLK_UNHALTED.THREAD:cmask=0x1\'. 6962306a36Sopenharmony_ci - 'aux-output': Generate AUX records instead of events. This requires 7062306a36Sopenharmony_ci that an AUX area event is also provided. 7162306a36Sopenharmony_ci - 'aux-sample-size': Set sample size for AUX area sampling. If the 7262306a36Sopenharmony_ci '--aux-sample' option has been used, set aux-sample-size=0 to disable 7362306a36Sopenharmony_ci AUX area sampling for the event. 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci See the linkperf:perf-list[1] man page for more parameters. 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci Note: If user explicitly sets options which conflict with the params, 7862306a36Sopenharmony_ci the value set by the parameters will be overridden. 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci Also not defined in .../<pmu>/format/* are PMU driver specific 8162306a36Sopenharmony_ci configuration parameters. Any configuration parameter preceded by 8262306a36Sopenharmony_ci the letter '@' is not interpreted in user space and sent down directly 8362306a36Sopenharmony_ci to the PMU driver. For example: 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci perf record -e some_event/@cfg1,@cfg2=config/ ... 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci will see 'cfg1' and 'cfg2=config' pushed to the PMU driver associated 8862306a36Sopenharmony_ci with the event for further processing. There is no restriction on 8962306a36Sopenharmony_ci what the configuration parameters are, as long as their semantic is 9062306a36Sopenharmony_ci understood and supported by the PMU driver. 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci - a hardware breakpoint event in the form of '\mem:addr[/len][:access]' 9362306a36Sopenharmony_ci where addr is the address in memory you want to break in. 9462306a36Sopenharmony_ci Access is the memory access type (read, write, execute) it can 9562306a36Sopenharmony_ci be passed as follows: '\mem:addr[:[r][w][x]]'. len is the range, 9662306a36Sopenharmony_ci number of bytes from specified addr, which the breakpoint will cover. 9762306a36Sopenharmony_ci If you want to profile read-write accesses in 0x1000, just set 9862306a36Sopenharmony_ci 'mem:0x1000:rw'. 9962306a36Sopenharmony_ci If you want to profile write accesses in [0x1000~1008), just set 10062306a36Sopenharmony_ci 'mem:0x1000/8:w'. 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci - a group of events surrounded by a pair of brace ("{event1,event2,...}"). 10362306a36Sopenharmony_ci Each event is separated by commas and the group should be quoted to 10462306a36Sopenharmony_ci prevent the shell interpretation. You also need to use --group on 10562306a36Sopenharmony_ci "perf report" to view group events together. 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci--filter=<filter>:: 10862306a36Sopenharmony_ci Event filter. This option should follow an event selector (-e). 10962306a36Sopenharmony_ci If the event is a tracepoint, the filter string will be parsed by 11062306a36Sopenharmony_ci the kernel. If the event is a hardware trace PMU (e.g. Intel PT 11162306a36Sopenharmony_ci or CoreSight), it'll be processed as an address filter. Otherwise 11262306a36Sopenharmony_ci it means a general filter using BPF which can be applied for any 11362306a36Sopenharmony_ci kind of event. 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci - tracepoint filters 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci In the case of tracepoints, multiple '--filter' options are combined 11862306a36Sopenharmony_ci using '&&'. 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci - address filters 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci A hardware trace PMU advertises its ability to accept a number of 12362306a36Sopenharmony_ci address filters by specifying a non-zero value in 12462306a36Sopenharmony_ci /sys/bus/event_source/devices/<pmu>/nr_addr_filters. 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci Address filters have the format: 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci filter|start|stop|tracestop <start> [/ <size>] [@<file name>] 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci Where: 13162306a36Sopenharmony_ci - 'filter': defines a region that will be traced. 13262306a36Sopenharmony_ci - 'start': defines an address at which tracing will begin. 13362306a36Sopenharmony_ci - 'stop': defines an address at which tracing will stop. 13462306a36Sopenharmony_ci - 'tracestop': defines a region in which tracing will stop. 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci <file name> is the name of the object file, <start> is the offset to the 13762306a36Sopenharmony_ci code to trace in that file, and <size> is the size of the region to 13862306a36Sopenharmony_ci trace. 'start' and 'stop' filters need not specify a <size>. 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci If no object file is specified then the kernel is assumed, in which case 14162306a36Sopenharmony_ci the start address must be a current kernel memory address. 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci <start> can also be specified by providing the name of a symbol. If the 14462306a36Sopenharmony_ci symbol name is not unique, it can be disambiguated by inserting #n where 14562306a36Sopenharmony_ci 'n' selects the n'th symbol in address order. Alternately #0, #g or #G 14662306a36Sopenharmony_ci select only a global symbol. <size> can also be specified by providing 14762306a36Sopenharmony_ci the name of a symbol, in which case the size is calculated to the end 14862306a36Sopenharmony_ci of that symbol. For 'filter' and 'tracestop' filters, if <size> is 14962306a36Sopenharmony_ci omitted and <start> is a symbol, then the size is calculated to the end 15062306a36Sopenharmony_ci of that symbol. 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci If <size> is omitted and <start> is '*', then the start and size will 15362306a36Sopenharmony_ci be calculated from the first and last symbols, i.e. to trace the whole 15462306a36Sopenharmony_ci file. 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci If symbol names (or '*') are provided, they must be surrounded by white 15762306a36Sopenharmony_ci space. 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci The filter passed to the kernel is not necessarily the same as entered. 16062306a36Sopenharmony_ci To see the filter that is passed, use the -v option. 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci The kernel may not be able to configure a trace region if it is not 16362306a36Sopenharmony_ci within a single mapping. MMAP events (or /proc/<pid>/maps) can be 16462306a36Sopenharmony_ci examined to determine if that is a possibility. 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci Multiple filters can be separated with space or comma. 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci - bpf filters 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci A BPF filter can access the sample data and make a decision based on the 17162306a36Sopenharmony_ci data. Users need to set an appropriate sample type to use the BPF 17262306a36Sopenharmony_ci filter. BPF filters need root privilege. 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci The sample data field can be specified in lower case letter. Multiple 17562306a36Sopenharmony_ci filters can be separated with comma. For example, 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci --filter 'period > 1000, cpu == 1' 17862306a36Sopenharmony_ci or 17962306a36Sopenharmony_ci --filter 'mem_op == load || mem_op == store, mem_lvl > l1' 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci The former filter only accept samples with period greater than 1000 AND 18262306a36Sopenharmony_ci CPU number is 1. The latter one accepts either load and store memory 18362306a36Sopenharmony_ci operations but it should have memory level above the L1. Since the 18462306a36Sopenharmony_ci mem_op and mem_lvl fields come from the (memory) data_source, it'd only 18562306a36Sopenharmony_ci work with some events which set the data_source field. 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci Also user should request to collect that information (with -d option in 18862306a36Sopenharmony_ci the above case). Otherwise, the following message will be shown. 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci $ sudo perf record -e cycles --filter 'mem_op == load' 19162306a36Sopenharmony_ci Error: cycles event does not have PERF_SAMPLE_DATA_SRC 19262306a36Sopenharmony_ci Hint: please add -d option to perf record. 19362306a36Sopenharmony_ci failed to set filter "BPF" on event cycles with 22 (Invalid argument) 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci Essentially the BPF filter expression is: 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci <term> <operator> <value> (("," | "||") <term> <operator> <value>)* 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci The <term> can be one of: 20062306a36Sopenharmony_ci ip, id, tid, pid, cpu, time, addr, period, txn, weight, phys_addr, 20162306a36Sopenharmony_ci code_pgsz, data_pgsz, weight1, weight2, weight3, ins_lat, retire_lat, 20262306a36Sopenharmony_ci p_stage_cyc, mem_op, mem_lvl, mem_snoop, mem_remote, mem_lock, 20362306a36Sopenharmony_ci mem_dtlb, mem_blk, mem_hops 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci The <operator> can be one of: 20662306a36Sopenharmony_ci ==, !=, >, >=, <, <=, & 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci The <value> can be one of: 20962306a36Sopenharmony_ci <number> (for any term) 21062306a36Sopenharmony_ci na, load, store, pfetch, exec (for mem_op) 21162306a36Sopenharmony_ci l1, l2, l3, l4, cxl, io, any_cache, lfb, ram, pmem (for mem_lvl) 21262306a36Sopenharmony_ci na, none, hit, miss, hitm, fwd, peer (for mem_snoop) 21362306a36Sopenharmony_ci remote (for mem_remote) 21462306a36Sopenharmony_ci na, locked (for mem_locked) 21562306a36Sopenharmony_ci na, l1_hit, l1_miss, l2_hit, l2_miss, any_hit, any_miss, walk, fault (for mem_dtlb) 21662306a36Sopenharmony_ci na, by_data, by_addr (for mem_blk) 21762306a36Sopenharmony_ci hops0, hops1, hops2, hops3 (for mem_hops) 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci--exclude-perf:: 22062306a36Sopenharmony_ci Don't record events issued by perf itself. This option should follow 22162306a36Sopenharmony_ci an event selector (-e) which selects tracepoint event(s). It adds a 22262306a36Sopenharmony_ci filter expression 'common_pid != $PERFPID' to filters. If other 22362306a36Sopenharmony_ci '--filter' exists, the new filter expression will be combined with 22462306a36Sopenharmony_ci them by '&&'. 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci-a:: 22762306a36Sopenharmony_ci--all-cpus:: 22862306a36Sopenharmony_ci System-wide collection from all CPUs (default if no target is specified). 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci-p:: 23162306a36Sopenharmony_ci--pid=:: 23262306a36Sopenharmony_ci Record events on existing process ID (comma separated list). 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci-t:: 23562306a36Sopenharmony_ci--tid=:: 23662306a36Sopenharmony_ci Record events on existing thread ID (comma separated list). 23762306a36Sopenharmony_ci This option also disables inheritance by default. Enable it by adding 23862306a36Sopenharmony_ci --inherit. 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_ci-u:: 24162306a36Sopenharmony_ci--uid=:: 24262306a36Sopenharmony_ci Record events in threads owned by uid. Name or number. 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci-r:: 24562306a36Sopenharmony_ci--realtime=:: 24662306a36Sopenharmony_ci Collect data with this RT SCHED_FIFO priority. 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci--no-buffering:: 24962306a36Sopenharmony_ci Collect data without buffering. 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci-c:: 25262306a36Sopenharmony_ci--count=:: 25362306a36Sopenharmony_ci Event period to sample. 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci-o:: 25662306a36Sopenharmony_ci--output=:: 25762306a36Sopenharmony_ci Output file name. 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci-i:: 26062306a36Sopenharmony_ci--no-inherit:: 26162306a36Sopenharmony_ci Child tasks do not inherit counters. 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci-F:: 26462306a36Sopenharmony_ci--freq=:: 26562306a36Sopenharmony_ci Profile at this frequency. Use 'max' to use the currently maximum 26662306a36Sopenharmony_ci allowed frequency, i.e. the value in the kernel.perf_event_max_sample_rate 26762306a36Sopenharmony_ci sysctl. Will throttle down to the currently maximum allowed frequency. 26862306a36Sopenharmony_ci See --strict-freq. 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci--strict-freq:: 27162306a36Sopenharmony_ci Fail if the specified frequency can't be used. 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci-m:: 27462306a36Sopenharmony_ci--mmap-pages=:: 27562306a36Sopenharmony_ci Number of mmap data pages (must be a power of two) or size 27662306a36Sopenharmony_ci specification with appended unit character - B/K/M/G. The 27762306a36Sopenharmony_ci size is rounded up to have nearest pages power of two value. 27862306a36Sopenharmony_ci Also, by adding a comma, the number of mmap pages for AUX 27962306a36Sopenharmony_ci area tracing can be specified. 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci-g:: 28262306a36Sopenharmony_ci Enables call-graph (stack chain/backtrace) recording for both 28362306a36Sopenharmony_ci kernel space and user space. 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci--call-graph:: 28662306a36Sopenharmony_ci Setup and enable call-graph (stack chain/backtrace) recording, 28762306a36Sopenharmony_ci implies -g. Default is "fp" (for user space). 28862306a36Sopenharmony_ci 28962306a36Sopenharmony_ci The unwinding method used for kernel space is dependent on the 29062306a36Sopenharmony_ci unwinder used by the active kernel configuration, i.e 29162306a36Sopenharmony_ci CONFIG_UNWINDER_FRAME_POINTER (fp) or CONFIG_UNWINDER_ORC (orc) 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci Any option specified here controls the method used for user space. 29462306a36Sopenharmony_ci 29562306a36Sopenharmony_ci Valid options are "fp" (frame pointer), "dwarf" (DWARF's CFI - 29662306a36Sopenharmony_ci Call Frame Information) or "lbr" (Hardware Last Branch Record 29762306a36Sopenharmony_ci facility). 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci In some systems, where binaries are build with gcc 30062306a36Sopenharmony_ci --fomit-frame-pointer, using the "fp" method will produce bogus 30162306a36Sopenharmony_ci call graphs, using "dwarf", if available (perf tools linked to 30262306a36Sopenharmony_ci the libunwind or libdw library) should be used instead. 30362306a36Sopenharmony_ci Using the "lbr" method doesn't require any compiler options. It 30462306a36Sopenharmony_ci will produce call graphs from the hardware LBR registers. The 30562306a36Sopenharmony_ci main limitation is that it is only available on new Intel 30662306a36Sopenharmony_ci platforms, such as Haswell. It can only get user call chain. It 30762306a36Sopenharmony_ci doesn't work with branch stack sampling at the same time. 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci When "dwarf" recording is used, perf also records (user) stack dump 31062306a36Sopenharmony_ci when sampled. Default size of the stack dump is 8192 (bytes). 31162306a36Sopenharmony_ci User can change the size by passing the size after comma like 31262306a36Sopenharmony_ci "--call-graph dwarf,4096". 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_ci When "fp" recording is used, perf tries to save stack enties 31562306a36Sopenharmony_ci up to the number specified in sysctl.kernel.perf_event_max_stack 31662306a36Sopenharmony_ci by default. User can change the number by passing it after comma 31762306a36Sopenharmony_ci like "--call-graph fp,32". 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci-q:: 32062306a36Sopenharmony_ci--quiet:: 32162306a36Sopenharmony_ci Don't print any warnings or messages, useful for scripting. 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci-v:: 32462306a36Sopenharmony_ci--verbose:: 32562306a36Sopenharmony_ci Be more verbose (show counter open errors, etc). 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci-s:: 32862306a36Sopenharmony_ci--stat:: 32962306a36Sopenharmony_ci Record per-thread event counts. Use it with 'perf report -T' to see 33062306a36Sopenharmony_ci the values. 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_ci-d:: 33362306a36Sopenharmony_ci--data:: 33462306a36Sopenharmony_ci Record the sample virtual addresses. 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci--phys-data:: 33762306a36Sopenharmony_ci Record the sample physical addresses. 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci--data-page-size:: 34062306a36Sopenharmony_ci Record the sampled data address data page size. 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci--code-page-size:: 34362306a36Sopenharmony_ci Record the sampled code address (ip) page size 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci-T:: 34662306a36Sopenharmony_ci--timestamp:: 34762306a36Sopenharmony_ci Record the sample timestamps. Use it with 'perf report -D' to see the 34862306a36Sopenharmony_ci timestamps, for instance. 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ci-P:: 35162306a36Sopenharmony_ci--period:: 35262306a36Sopenharmony_ci Record the sample period. 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci--sample-cpu:: 35562306a36Sopenharmony_ci Record the sample cpu. 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci--sample-identifier:: 35862306a36Sopenharmony_ci Record the sample identifier i.e. PERF_SAMPLE_IDENTIFIER bit set in 35962306a36Sopenharmony_ci the sample_type member of the struct perf_event_attr argument to the 36062306a36Sopenharmony_ci perf_event_open system call. 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci-n:: 36362306a36Sopenharmony_ci--no-samples:: 36462306a36Sopenharmony_ci Don't sample. 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci-R:: 36762306a36Sopenharmony_ci--raw-samples:: 36862306a36Sopenharmony_ciCollect raw sample records from all opened counters (default for tracepoint counters). 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci-C:: 37162306a36Sopenharmony_ci--cpu:: 37262306a36Sopenharmony_ciCollect samples only on the list of CPUs provided. Multiple CPUs can be provided as a 37362306a36Sopenharmony_cicomma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. 37462306a36Sopenharmony_ciIn per-thread mode with inheritance mode on (default), samples are captured only when 37562306a36Sopenharmony_cithe thread executes on the designated CPUs. Default is to monitor all CPUs. 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ci-B:: 37862306a36Sopenharmony_ci--no-buildid:: 37962306a36Sopenharmony_ciDo not save the build ids of binaries in the perf.data files. This skips 38062306a36Sopenharmony_cipost processing after recording, which sometimes makes the final step in 38162306a36Sopenharmony_cithe recording process to take a long time, as it needs to process all 38262306a36Sopenharmony_cievents looking for mmap records. The downside is that it can misresolve 38362306a36Sopenharmony_cisymbols if the workload binaries used when recording get locally rebuilt 38462306a36Sopenharmony_cior upgraded, because the only key available in this case is the 38562306a36Sopenharmony_cipathname. You can also set the "record.build-id" config variable to 38662306a36Sopenharmony_ci'skip to have this behaviour permanently. 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci-N:: 38962306a36Sopenharmony_ci--no-buildid-cache:: 39062306a36Sopenharmony_ciDo not update the buildid cache. This saves some overhead in situations 39162306a36Sopenharmony_ciwhere the information in the perf.data file (which includes buildids) 39262306a36Sopenharmony_ciis sufficient. You can also set the "record.build-id" config variable to 39362306a36Sopenharmony_ci'no-cache' to have the same effect. 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci-G name,...:: 39662306a36Sopenharmony_ci--cgroup name,...:: 39762306a36Sopenharmony_cimonitor only in the container (cgroup) called "name". This option is available only 39862306a36Sopenharmony_ciin per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to 39962306a36Sopenharmony_cicontainer "name" are monitored when they run on the monitored CPUs. Multiple cgroups 40062306a36Sopenharmony_cican be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup 40162306a36Sopenharmony_cito first event, second cgroup to second event and so on. It is possible to provide 40262306a36Sopenharmony_cian empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have 40362306a36Sopenharmony_cicorresponding events, i.e., they always refer to events defined earlier on the command 40462306a36Sopenharmony_ciline. If the user wants to track multiple events for a specific cgroup, the user can 40562306a36Sopenharmony_ciuse '-e e1 -e e2 -G foo,foo' or just use '-e e1 -e e2 -G foo'. 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ciIf wanting to monitor, say, 'cycles' for a cgroup and also for system wide, this 40862306a36Sopenharmony_cicommand line can be used: 'perf stat -e cycles -G cgroup_name -a -e cycles'. 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci-b:: 41162306a36Sopenharmony_ci--branch-any:: 41262306a36Sopenharmony_ciEnable taken branch stack sampling. Any type of taken branch may be sampled. 41362306a36Sopenharmony_ciThis is a shortcut for --branch-filter any. See --branch-filter for more infos. 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ci-j:: 41662306a36Sopenharmony_ci--branch-filter:: 41762306a36Sopenharmony_ciEnable taken branch stack sampling. Each sample captures a series of consecutive 41862306a36Sopenharmony_citaken branches. The number of branches captured with each sample depends on the 41962306a36Sopenharmony_ciunderlying hardware, the type of branches of interest, and the executed code. 42062306a36Sopenharmony_ciIt is possible to select the types of branches captured by enabling filters. The 42162306a36Sopenharmony_cifollowing filters are defined: 42262306a36Sopenharmony_ci 42362306a36Sopenharmony_ci - any: any type of branches 42462306a36Sopenharmony_ci - any_call: any function call or system call 42562306a36Sopenharmony_ci - any_ret: any function return or system call return 42662306a36Sopenharmony_ci - ind_call: any indirect branch 42762306a36Sopenharmony_ci - ind_jmp: any indirect jump 42862306a36Sopenharmony_ci - call: direct calls, including far (to/from kernel) calls 42962306a36Sopenharmony_ci - u: only when the branch target is at the user level 43062306a36Sopenharmony_ci - k: only when the branch target is in the kernel 43162306a36Sopenharmony_ci - hv: only when the target is at the hypervisor level 43262306a36Sopenharmony_ci - in_tx: only when the target is in a hardware transaction 43362306a36Sopenharmony_ci - no_tx: only when the target is not in a hardware transaction 43462306a36Sopenharmony_ci - abort_tx: only when the target is a hardware transaction abort 43562306a36Sopenharmony_ci - cond: conditional branches 43662306a36Sopenharmony_ci - call_stack: save call stack 43762306a36Sopenharmony_ci - no_flags: don't save branch flags e.g prediction, misprediction etc 43862306a36Sopenharmony_ci - no_cycles: don't save branch cycles 43962306a36Sopenharmony_ci - hw_index: save branch hardware index 44062306a36Sopenharmony_ci - save_type: save branch type during sampling in case binary is not available later 44162306a36Sopenharmony_ci For the platforms with Intel Arch LBR support (12th-Gen+ client or 44262306a36Sopenharmony_ci 4th-Gen Xeon+ server), the save branch type is unconditionally enabled 44362306a36Sopenharmony_ci when the taken branch stack sampling is enabled. 44462306a36Sopenharmony_ci - priv: save privilege state during sampling in case binary is not available later 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ci+ 44762306a36Sopenharmony_ciThe option requires at least one branch type among any, any_call, any_ret, ind_call, cond. 44862306a36Sopenharmony_ciThe privilege levels may be omitted, in which case, the privilege levels of the associated 44962306a36Sopenharmony_cievent are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege 45062306a36Sopenharmony_cilevels are subject to permissions. When sampling on multiple events, branch stack sampling 45162306a36Sopenharmony_ciis enabled for all the sampling events. The sampled branch type is the same for all events. 45262306a36Sopenharmony_ciThe various filters must be specified as a comma separated list: --branch-filter any_ret,u,k 45362306a36Sopenharmony_ciNote that this feature may not be available on all processors. 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ci-W:: 45662306a36Sopenharmony_ci--weight:: 45762306a36Sopenharmony_ciEnable weightened sampling. An additional weight is recorded per sample and can be 45862306a36Sopenharmony_cidisplayed with the weight and local_weight sort keys. This currently works for TSX 45962306a36Sopenharmony_ciabort events and some memory events in precise mode on modern Intel CPUs. 46062306a36Sopenharmony_ci 46162306a36Sopenharmony_ci--namespaces:: 46262306a36Sopenharmony_ciRecord events of type PERF_RECORD_NAMESPACES. This enables 'cgroup_id' sort key. 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci--all-cgroups:: 46562306a36Sopenharmony_ciRecord events of type PERF_RECORD_CGROUP. This enables 'cgroup' sort key. 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci--transaction:: 46862306a36Sopenharmony_ciRecord transaction flags for transaction related events. 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci--per-thread:: 47162306a36Sopenharmony_ciUse per-thread mmaps. By default per-cpu mmaps are created. This option 47262306a36Sopenharmony_cioverrides that and uses per-thread mmaps. A side-effect of that is that 47362306a36Sopenharmony_ciinheritance is automatically disabled. --per-thread is ignored with a warning 47462306a36Sopenharmony_ciif combined with -a or -C options. 47562306a36Sopenharmony_ci 47662306a36Sopenharmony_ci-D:: 47762306a36Sopenharmony_ci--delay=:: 47862306a36Sopenharmony_ciAfter starting the program, wait msecs before measuring (-1: start with events 47962306a36Sopenharmony_cidisabled), or enable events only for specified ranges of msecs (e.g. 48062306a36Sopenharmony_ci-D 10-20,30-40 means wait 10 msecs, enable for 10 msecs, wait 10 msecs, enable 48162306a36Sopenharmony_cifor 10 msecs, then stop). Note, delaying enabling of events is useful to filter 48262306a36Sopenharmony_ciout the startup phase of the program, which is often very different. 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci-I:: 48562306a36Sopenharmony_ci--intr-regs:: 48662306a36Sopenharmony_ciCapture machine state (registers) at interrupt, i.e., on counter overflows for 48762306a36Sopenharmony_cieach sample. List of captured registers depends on the architecture. This option 48862306a36Sopenharmony_ciis off by default. It is possible to select the registers to sample using their 48962306a36Sopenharmony_cisymbolic names, e.g. on x86, ax, si. To list the available registers use 49062306a36Sopenharmony_ci--intr-regs=\?. To name registers, pass a comma separated list such as 49162306a36Sopenharmony_ci--intr-regs=ax,bx. The list of register is architecture dependent. 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_ci--user-regs:: 49462306a36Sopenharmony_ciSimilar to -I, but capture user registers at sample time. To list the available 49562306a36Sopenharmony_ciuser registers use --user-regs=\?. 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci--running-time:: 49862306a36Sopenharmony_ciRecord running and enabled time for read events (:S) 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci-k:: 50162306a36Sopenharmony_ci--clockid:: 50262306a36Sopenharmony_ciSets the clock id to use for the various time fields in the perf_event_type 50362306a36Sopenharmony_cirecords. See clock_gettime(). In particular CLOCK_MONOTONIC and 50462306a36Sopenharmony_ciCLOCK_MONOTONIC_RAW are supported, some events might also allow 50562306a36Sopenharmony_ciCLOCK_BOOTTIME, CLOCK_REALTIME and CLOCK_TAI. 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci-S:: 50862306a36Sopenharmony_ci--snapshot:: 50962306a36Sopenharmony_ciSelect AUX area tracing Snapshot Mode. This option is valid only with an 51062306a36Sopenharmony_ciAUX area tracing event. Optionally, certain snapshot capturing parameters 51162306a36Sopenharmony_cican be specified in a string that follows this option: 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci - 'e': take one last snapshot on exit; guarantees that there is at least one 51462306a36Sopenharmony_ci snapshot in the output file; 51562306a36Sopenharmony_ci - <size>: if the PMU supports this, specify the desired snapshot size. 51662306a36Sopenharmony_ci 51762306a36Sopenharmony_ciIn Snapshot Mode trace data is captured only when signal SIGUSR2 is received 51862306a36Sopenharmony_ciand on exit if the above 'e' option is given. 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_ci--aux-sample[=OPTIONS]:: 52162306a36Sopenharmony_ciSelect AUX area sampling. At least one of the events selected by the -e option 52262306a36Sopenharmony_cimust be an AUX area event. Samples on other events will be created containing 52362306a36Sopenharmony_cidata from the AUX area. Optionally sample size may be specified, otherwise it 52462306a36Sopenharmony_cidefaults to 4KiB. 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci--proc-map-timeout:: 52762306a36Sopenharmony_ciWhen processing pre-existing threads /proc/XXX/mmap, it may take a long time, 52862306a36Sopenharmony_cibecause the file may be huge. A time out is needed in such cases. 52962306a36Sopenharmony_ciThis option sets the time out limit. The default value is 500 ms. 53062306a36Sopenharmony_ci 53162306a36Sopenharmony_ci--switch-events:: 53262306a36Sopenharmony_ciRecord context switch events i.e. events of type PERF_RECORD_SWITCH or 53362306a36Sopenharmony_ciPERF_RECORD_SWITCH_CPU_WIDE. In some cases (e.g. Intel PT, CoreSight or Arm SPE) 53462306a36Sopenharmony_ciswitch events will be enabled automatically, which can be suppressed by 53562306a36Sopenharmony_ciby the option --no-switch-events. 53662306a36Sopenharmony_ci 53762306a36Sopenharmony_ci--vmlinux=PATH:: 53862306a36Sopenharmony_ciSpecify vmlinux path which has debuginfo. 53962306a36Sopenharmony_ci(enabled when BPF prologue is on) 54062306a36Sopenharmony_ci 54162306a36Sopenharmony_ci--buildid-all:: 54262306a36Sopenharmony_ciRecord build-id of all DSOs regardless whether it's actually hit or not. 54362306a36Sopenharmony_ci 54462306a36Sopenharmony_ci--buildid-mmap:: 54562306a36Sopenharmony_ciRecord build ids in mmap2 events, disables build id cache (implies --no-buildid). 54662306a36Sopenharmony_ci 54762306a36Sopenharmony_ci--aio[=n]:: 54862306a36Sopenharmony_ciUse <n> control blocks in asynchronous (Posix AIO) trace writing mode (default: 1, max: 4). 54962306a36Sopenharmony_ciAsynchronous mode is supported only when linking Perf tool with libc library 55062306a36Sopenharmony_ciproviding implementation for Posix AIO API. 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_ci--affinity=mode:: 55362306a36Sopenharmony_ciSet affinity mask of trace reading thread according to the policy defined by 'mode' value: 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ci - node - thread affinity mask is set to NUMA node cpu mask of the processed mmap buffer 55662306a36Sopenharmony_ci - cpu - thread affinity mask is set to cpu of the processed mmap buffer 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_ci--mmap-flush=number:: 55962306a36Sopenharmony_ci 56062306a36Sopenharmony_ciSpecify minimal number of bytes that is extracted from mmap data pages and 56162306a36Sopenharmony_ciprocessed for output. One can specify the number using B/K/M/G suffixes. 56262306a36Sopenharmony_ci 56362306a36Sopenharmony_ciThe maximal allowed value is a quarter of the size of mmaped data pages. 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_ciThe default option value is 1 byte which means that every time that the output 56662306a36Sopenharmony_ciwriting thread finds some new data in the mmaped buffer the data is extracted, 56762306a36Sopenharmony_cipossibly compressed (-z) and written to the output, perf.data or pipe. 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_ciLarger data chunks are compressed more effectively in comparison to smaller 57062306a36Sopenharmony_cichunks so extraction of larger chunks from the mmap data pages is preferable 57162306a36Sopenharmony_cifrom the perspective of output size reduction. 57262306a36Sopenharmony_ci 57362306a36Sopenharmony_ciAlso at some cases executing less output write syscalls with bigger data size 57462306a36Sopenharmony_cican take less time than executing more output write syscalls with smaller data 57562306a36Sopenharmony_cisize thus lowering runtime profiling overhead. 57662306a36Sopenharmony_ci 57762306a36Sopenharmony_ci-z:: 57862306a36Sopenharmony_ci--compression-level[=n]:: 57962306a36Sopenharmony_ciProduce compressed trace using specified level n (default: 1 - fastest compression, 58062306a36Sopenharmony_ci22 - smallest trace) 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_ci--all-kernel:: 58362306a36Sopenharmony_ciConfigure all used events to run in kernel space. 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_ci--all-user:: 58662306a36Sopenharmony_ciConfigure all used events to run in user space. 58762306a36Sopenharmony_ci 58862306a36Sopenharmony_ci--kernel-callchains:: 58962306a36Sopenharmony_ciCollect callchains only from kernel space. I.e. this option sets 59062306a36Sopenharmony_ciperf_event_attr.exclude_callchain_user to 1. 59162306a36Sopenharmony_ci 59262306a36Sopenharmony_ci--user-callchains:: 59362306a36Sopenharmony_ciCollect callchains only from user space. I.e. this option sets 59462306a36Sopenharmony_ciperf_event_attr.exclude_callchain_kernel to 1. 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_ciDon't use both --kernel-callchains and --user-callchains at the same time or no 59762306a36Sopenharmony_cicallchains will be collected. 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_ci--timestamp-filename 60062306a36Sopenharmony_ciAppend timestamp to output file name. 60162306a36Sopenharmony_ci 60262306a36Sopenharmony_ci--timestamp-boundary:: 60362306a36Sopenharmony_ciRecord timestamp boundary (time of first/last samples). 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_ci--switch-output[=mode]:: 60662306a36Sopenharmony_ciGenerate multiple perf.data files, timestamp prefixed, switching to a new one 60762306a36Sopenharmony_cibased on 'mode' value: 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci - "signal" - when receiving a SIGUSR2 (default value) or 61062306a36Sopenharmony_ci - <size> - when reaching the size threshold, size is expected to 61162306a36Sopenharmony_ci be a number with appended unit character - B/K/M/G 61262306a36Sopenharmony_ci - <time> - when reaching the time threshold, size is expected to 61362306a36Sopenharmony_ci be a number with appended unit character - s/m/h/d 61462306a36Sopenharmony_ci 61562306a36Sopenharmony_ci Note: the precision of the size threshold hugely depends 61662306a36Sopenharmony_ci on your configuration - the number and size of your ring 61762306a36Sopenharmony_ci buffers (-m). It is generally more precise for higher sizes 61862306a36Sopenharmony_ci (like >5M), for lower values expect different sizes. 61962306a36Sopenharmony_ci 62062306a36Sopenharmony_ciA possible use case is to, given an external event, slice the perf.data file 62162306a36Sopenharmony_cithat gets then processed, possibly via a perf script, to decide if that 62262306a36Sopenharmony_ciparticular perf.data snapshot should be kept or not. 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_ciImplies --timestamp-filename, --no-buildid and --no-buildid-cache. 62562306a36Sopenharmony_ciThe reason for the latter two is to reduce the data file switching 62662306a36Sopenharmony_cioverhead. You can still switch them on with: 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_ci --switch-output --no-no-buildid --no-no-buildid-cache 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_ci--switch-output-event:: 63162306a36Sopenharmony_ciEvents that will cause the switch of the perf.data file, auto-selecting 63262306a36Sopenharmony_ci--switch-output=signal, the results are similar as internally the side band 63362306a36Sopenharmony_cithread will also send a SIGUSR2 to the main one. 63462306a36Sopenharmony_ci 63562306a36Sopenharmony_ciUses the same syntax as --event, it will just not be recorded, serving only to 63662306a36Sopenharmony_ciswitch the perf.data file as soon as the --switch-output event is processed by 63762306a36Sopenharmony_cia separate sideband thread. 63862306a36Sopenharmony_ci 63962306a36Sopenharmony_ciThis sideband thread is also used to other purposes, like processing the 64062306a36Sopenharmony_ciPERF_RECORD_BPF_EVENT records as they happen, asking the kernel for extra BPF 64162306a36Sopenharmony_ciinformation, etc. 64262306a36Sopenharmony_ci 64362306a36Sopenharmony_ci--switch-max-files=N:: 64462306a36Sopenharmony_ci 64562306a36Sopenharmony_ciWhen rotating perf.data with --switch-output, only keep N files. 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_ci--dry-run:: 64862306a36Sopenharmony_ciParse options then exit. --dry-run can be used to detect errors in cmdline 64962306a36Sopenharmony_cioptions. 65062306a36Sopenharmony_ci 65162306a36Sopenharmony_ci'perf record --dry-run -e' can act as a BPF script compiler if llvm.dump-obj 65262306a36Sopenharmony_ciin config file is set to true. 65362306a36Sopenharmony_ci 65462306a36Sopenharmony_ci--synth=TYPE:: 65562306a36Sopenharmony_ciCollect and synthesize given type of events (comma separated). Note that 65662306a36Sopenharmony_cithis option controls the synthesis from the /proc filesystem which represent 65762306a36Sopenharmony_citask status for pre-existing threads. 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_ciKernel (and some other) events are recorded regardless of the 66062306a36Sopenharmony_cichoice in this option. For example, --synth=no would have MMAP events for 66162306a36Sopenharmony_cikernel and modules. 66262306a36Sopenharmony_ci 66362306a36Sopenharmony_ciAvailable types are: 66462306a36Sopenharmony_ci 66562306a36Sopenharmony_ci - 'task' - synthesize FORK and COMM events for each task 66662306a36Sopenharmony_ci - 'mmap' - synthesize MMAP events for each process (implies 'task') 66762306a36Sopenharmony_ci - 'cgroup' - synthesize CGROUP events for each cgroup 66862306a36Sopenharmony_ci - 'all' - synthesize all events (default) 66962306a36Sopenharmony_ci - 'no' - do not synthesize any of the above events 67062306a36Sopenharmony_ci 67162306a36Sopenharmony_ci--tail-synthesize:: 67262306a36Sopenharmony_ciInstead of collecting non-sample events (for example, fork, comm, mmap) at 67362306a36Sopenharmony_cithe beginning of record, collect them during finalizing an output file. 67462306a36Sopenharmony_ciThe collected non-sample events reflects the status of the system when 67562306a36Sopenharmony_cirecord is finished. 67662306a36Sopenharmony_ci 67762306a36Sopenharmony_ci--overwrite:: 67862306a36Sopenharmony_ciMakes all events use an overwritable ring buffer. An overwritable ring 67962306a36Sopenharmony_cibuffer works like a flight recorder: when it gets full, the kernel will 68062306a36Sopenharmony_cioverwrite the oldest records, that thus will never make it to the 68162306a36Sopenharmony_ciperf.data file. 68262306a36Sopenharmony_ci 68362306a36Sopenharmony_ciWhen '--overwrite' and '--switch-output' are used perf records and drops 68462306a36Sopenharmony_cievents until it receives a signal, meaning that something unusual was 68562306a36Sopenharmony_cidetected that warrants taking a snapshot of the most current events, 68662306a36Sopenharmony_cithose fitting in the ring buffer at that moment. 68762306a36Sopenharmony_ci 68862306a36Sopenharmony_ci'overwrite' attribute can also be set or canceled for an event using 68962306a36Sopenharmony_ciconfig terms. For example: 'cycles/overwrite/' and 'instructions/no-overwrite/'. 69062306a36Sopenharmony_ci 69162306a36Sopenharmony_ciImplies --tail-synthesize. 69262306a36Sopenharmony_ci 69362306a36Sopenharmony_ci--kcore:: 69462306a36Sopenharmony_ciMake a copy of /proc/kcore and place it into a directory with the perf data file. 69562306a36Sopenharmony_ci 69662306a36Sopenharmony_ci--max-size=<size>:: 69762306a36Sopenharmony_ciLimit the sample data max size, <size> is expected to be a number with 69862306a36Sopenharmony_ciappended unit character - B/K/M/G 69962306a36Sopenharmony_ci 70062306a36Sopenharmony_ci--num-thread-synthesize:: 70162306a36Sopenharmony_ci The number of threads to run when synthesizing events for existing processes. 70262306a36Sopenharmony_ci By default, the number of threads equals 1. 70362306a36Sopenharmony_ci 70462306a36Sopenharmony_ciifdef::HAVE_LIBPFM[] 70562306a36Sopenharmony_ci--pfm-events events:: 70662306a36Sopenharmony_ciSelect a PMU event using libpfm4 syntax (see http://perfmon2.sf.net) 70762306a36Sopenharmony_ciincluding support for event filters. For example '--pfm-events 70862306a36Sopenharmony_ciinst_retired:any_p:u:c=1:i'. More than one event can be passed to the 70962306a36Sopenharmony_cioption using the comma separator. Hardware events and generic hardware 71062306a36Sopenharmony_cievents cannot be mixed together. The latter must be used with the -e 71162306a36Sopenharmony_cioption. The -e option and this one can be mixed and matched. Events 71262306a36Sopenharmony_cican be grouped using the {} notation. 71362306a36Sopenharmony_ciendif::HAVE_LIBPFM[] 71462306a36Sopenharmony_ci 71562306a36Sopenharmony_ci--control=fifo:ctl-fifo[,ack-fifo]:: 71662306a36Sopenharmony_ci--control=fd:ctl-fd[,ack-fd]:: 71762306a36Sopenharmony_cictl-fifo / ack-fifo are opened and used as ctl-fd / ack-fd as follows. 71862306a36Sopenharmony_ciListen on ctl-fd descriptor for command to control measurement. 71962306a36Sopenharmony_ci 72062306a36Sopenharmony_ciAvailable commands: 72162306a36Sopenharmony_ci 72262306a36Sopenharmony_ci - 'enable' : enable events 72362306a36Sopenharmony_ci - 'disable' : disable events 72462306a36Sopenharmony_ci - 'enable name' : enable event 'name' 72562306a36Sopenharmony_ci - 'disable name' : disable event 'name' 72662306a36Sopenharmony_ci - 'snapshot' : AUX area tracing snapshot). 72762306a36Sopenharmony_ci - 'stop' : stop perf record 72862306a36Sopenharmony_ci - 'ping' : ping 72962306a36Sopenharmony_ci - 'evlist [-v|-g|-F] : display all events 73062306a36Sopenharmony_ci 73162306a36Sopenharmony_ci -F Show just the sample frequency used for each event. 73262306a36Sopenharmony_ci -v Show all fields. 73362306a36Sopenharmony_ci -g Show event group information. 73462306a36Sopenharmony_ci 73562306a36Sopenharmony_ciMeasurements can be started with events disabled using --delay=-1 option. Optionally 73662306a36Sopenharmony_cisend control command completion ('ack\n') to ack-fd descriptor to synchronize with the 73762306a36Sopenharmony_cicontrolling process. Example of bash shell script to enable and disable events during 73862306a36Sopenharmony_cimeasurements: 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_ci #!/bin/bash 74162306a36Sopenharmony_ci 74262306a36Sopenharmony_ci ctl_dir=/tmp/ 74362306a36Sopenharmony_ci 74462306a36Sopenharmony_ci ctl_fifo=${ctl_dir}perf_ctl.fifo 74562306a36Sopenharmony_ci test -p ${ctl_fifo} && unlink ${ctl_fifo} 74662306a36Sopenharmony_ci mkfifo ${ctl_fifo} 74762306a36Sopenharmony_ci exec {ctl_fd}<>${ctl_fifo} 74862306a36Sopenharmony_ci 74962306a36Sopenharmony_ci ctl_ack_fifo=${ctl_dir}perf_ctl_ack.fifo 75062306a36Sopenharmony_ci test -p ${ctl_ack_fifo} && unlink ${ctl_ack_fifo} 75162306a36Sopenharmony_ci mkfifo ${ctl_ack_fifo} 75262306a36Sopenharmony_ci exec {ctl_fd_ack}<>${ctl_ack_fifo} 75362306a36Sopenharmony_ci 75462306a36Sopenharmony_ci perf record -D -1 -e cpu-cycles -a \ 75562306a36Sopenharmony_ci --control fd:${ctl_fd},${ctl_fd_ack} \ 75662306a36Sopenharmony_ci -- sleep 30 & 75762306a36Sopenharmony_ci perf_pid=$! 75862306a36Sopenharmony_ci 75962306a36Sopenharmony_ci sleep 5 && echo 'enable' >&${ctl_fd} && read -u ${ctl_fd_ack} e1 && echo "enabled(${e1})" 76062306a36Sopenharmony_ci sleep 10 && echo 'disable' >&${ctl_fd} && read -u ${ctl_fd_ack} d1 && echo "disabled(${d1})" 76162306a36Sopenharmony_ci 76262306a36Sopenharmony_ci exec {ctl_fd_ack}>&- 76362306a36Sopenharmony_ci unlink ${ctl_ack_fifo} 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci exec {ctl_fd}>&- 76662306a36Sopenharmony_ci unlink ${ctl_fifo} 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_ci wait -n ${perf_pid} 76962306a36Sopenharmony_ci exit $? 77062306a36Sopenharmony_ci 77162306a36Sopenharmony_ci--threads=<spec>:: 77262306a36Sopenharmony_ciWrite collected trace data into several data files using parallel threads. 77362306a36Sopenharmony_ci<spec> value can be user defined list of masks. Masks separated by colon 77462306a36Sopenharmony_cidefine CPUs to be monitored by a thread and affinity mask of that thread 77562306a36Sopenharmony_ciis separated by slash: 77662306a36Sopenharmony_ci 77762306a36Sopenharmony_ci <cpus mask 1>/<affinity mask 1>:<cpus mask 2>/<affinity mask 2>:... 77862306a36Sopenharmony_ci 77962306a36Sopenharmony_ciCPUs or affinity masks must not overlap with other corresponding masks. 78062306a36Sopenharmony_ciInvalid CPUs are ignored, but masks containing only invalid CPUs are not 78162306a36Sopenharmony_ciallowed. 78262306a36Sopenharmony_ci 78362306a36Sopenharmony_ciFor example user specification like the following: 78462306a36Sopenharmony_ci 78562306a36Sopenharmony_ci 0,2-4/2-4:1,5-7/5-7 78662306a36Sopenharmony_ci 78762306a36Sopenharmony_cispecifies parallel threads layout that consists of two threads, 78862306a36Sopenharmony_cithe first thread monitors CPUs 0 and 2-4 with the affinity mask 2-4, 78962306a36Sopenharmony_cithe second monitors CPUs 1 and 5-7 with the affinity mask 5-7. 79062306a36Sopenharmony_ci 79162306a36Sopenharmony_ci<spec> value can also be a string meaning predefined parallel threads 79262306a36Sopenharmony_cilayout: 79362306a36Sopenharmony_ci 79462306a36Sopenharmony_ci - cpu - create new data streaming thread for every monitored cpu 79562306a36Sopenharmony_ci - core - create new thread to monitor CPUs grouped by a core 79662306a36Sopenharmony_ci - package - create new thread to monitor CPUs grouped by a package 79762306a36Sopenharmony_ci - numa - create new threed to monitor CPUs grouped by a NUMA domain 79862306a36Sopenharmony_ci 79962306a36Sopenharmony_ciPredefined layouts can be used on systems with large number of CPUs in 80062306a36Sopenharmony_ciorder not to spawn multiple per-cpu streaming threads but still avoid LOST 80162306a36Sopenharmony_cievents in data directory files. Option specified with no or empty value 80262306a36Sopenharmony_cidefaults to CPU layout. Masks defined or provided by the option value are 80362306a36Sopenharmony_cifiltered through the mask provided by -C option. 80462306a36Sopenharmony_ci 80562306a36Sopenharmony_ci--debuginfod[=URLs]:: 80662306a36Sopenharmony_ci Specify debuginfod URL to be used when cacheing perf.data binaries, 80762306a36Sopenharmony_ci it follows the same syntax as the DEBUGINFOD_URLS variable, like: 80862306a36Sopenharmony_ci 80962306a36Sopenharmony_ci http://192.168.122.174:8002 81062306a36Sopenharmony_ci 81162306a36Sopenharmony_ci If the URLs is not specified, the value of DEBUGINFOD_URLS 81262306a36Sopenharmony_ci system environment variable is used. 81362306a36Sopenharmony_ci 81462306a36Sopenharmony_ci--off-cpu:: 81562306a36Sopenharmony_ci Enable off-cpu profiling with BPF. The BPF program will collect 81662306a36Sopenharmony_ci task scheduling information with (user) stacktrace and save them 81762306a36Sopenharmony_ci as sample data of a software event named "offcpu-time". The 81862306a36Sopenharmony_ci sample period will have the time the task slept in nanoseconds. 81962306a36Sopenharmony_ci 82062306a36Sopenharmony_ci Note that BPF can collect stack traces using frame pointer ("fp") 82162306a36Sopenharmony_ci only, as of now. So the applications built without the frame 82262306a36Sopenharmony_ci pointer might see bogus addresses. 82362306a36Sopenharmony_ci 82462306a36Sopenharmony_ciinclude::intel-hybrid.txt[] 82562306a36Sopenharmony_ci 82662306a36Sopenharmony_ciSEE ALSO 82762306a36Sopenharmony_ci-------- 82862306a36Sopenharmony_cilinkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-intel-pt[1] 829