PERF-INJECT(1)
β¨ NAME β¨
okay bestie, welcome to the perf-inject page from the perf manual, section 1 π
β this one is literally a filter that augments your events stream with extra info, and it's kinda iconic.
π¦ SYNOPSIS π¦
perf inject <options>
π DESCRIPTION π
So perf-inject reads a perf record event stream and repipes it to stdout, no cap. And at literally any point, the processing code can inject other events into that stream β for example, build-ids (the -b option) get read and injected as needed into the event stream. Slay.
Build-ids are just the first user of perf-inject β potentially anything that needs userspace processing to augment the event stream with additional information could make use of this facility. It's giving main character energy for extensibility, fr fr.
πΈ OPTIONS πΈ
-b,--build-idsβ inject build-ids of DSOs hit by samples into the output stream. The catch: it has to process all theSAMPLErecords to find those DSOs. lowkey thorough.--buildid-allβ inject build-ids of all DSOs into the output stream regardless of hits, and skipSAMPLEprocessing. zero thoughts, just vibes.--known-build-ids=β override build-ids to inject using these comma-separated pairs of build-id and path. It also understandsfile://filenameto read these pairs from a file, which you can generate withperf buildid-list. iykyk.-v,--verboseβ be more verbose.-i,--input=β input file name. (default: stdin)-o,--output=β output file name. (default: stdout)-s,--sched-statβ mergesched_statandsched_switchto get events showing where and how long tasks slept.sched_switchcontains a callchain where a task slept, andsched_statcontains a timeslice of how long a task slept. it's giving detective work π.-k,--vmlinux=<file>βvmlinuxpathname--ignore-vmlinuxβ ignorevmlinuxfiles.--kallsyms=<file>βkallsymspathname--itraceβ decode Instruction Tracing data, replacing it with synthesized events. Options are:iβ synthesize instructions eventsyβ synthesize cycles eventsbβ synthesize branches eventscβ synthesize branches events (calls only)rβ synthesize branches events (returns only)xβ synthesize transactions eventswβ synthesize ptwrite eventspβ synthesize power events (incl. PSB events for Intel PT)oβ synthesize other events recorded due to the use of aux-output (refer toperf record)Iβ synthesize interrupt or similar (asynchronous) events (e.g. Intel PT Event Trace)eβ synthesize error eventsdβ create a debug logfβ synthesize first level cache eventsmβ synthesize last level cache eventsMβ synthesize memory eventstβ synthesize TLB eventsaβ synthesize remote access eventsgβ synthesize a call chain (use withiorx)Gβ synthesize a call chain on existing event recordslβ synthesize last branch entries (use withiorx)Lβ synthesize last branch entries on existing event recordssβ skip initial number of eventsqβ quicker (less detailed) decodingAβ approximate IPCZβ prefer to ignore timestamps (so-called "timeless" decoding)Tβ use the timestamp trace as kernel time
The default is all events i.e. the same as --itrace=iybxwpe, except for perf script where it is --itrace=ce.
In addition, the period (default 100000, except for perf script where it is 1) for instructions events can be specified in units of:
iβ instructionstβ ticksmsβ millisecondsusβ microsecondsnsβ nanoseconds (default)
Also the call chain size (default 16, max. 1024) for instructions or transactions events can be specified.
Also the number of last branch entries (default 64, max. 1024) for instructions or transactions events can be specified.
Similar to options g and l, size may also be specified for options G and L. On x86, note that G and L work poorly when data has been recorded with large PEBS. Refer linkperf:perf-intel-pt[1] man page for details.
It is also possible to skip events generated (instructions, branches, transactions, ptwrite, power) at the beginning. This is useful to ignore initialization code.
--itrace=i0nss1000000
skips the first million instructions. okay that's actually kinda cute.
The 'e' option may be followed by flags which affect what errors will or will not be reported. Each flag must be preceded by either + or -. The flags are:
oβ overflowlβ trace data lost
If supported, the 'd' option may be followed by flags which affect what debug messages will or will not be logged. Each flag must be preceded by either + or -. The flags are:
aβ all perf eventseβ output only on errors (size configurable - seelinkperf:perf-config[1])oβ output to stdout
If supported, the 'q' option may be repeated to increase the effect.
--stripβ use with--itraceto strip out non-synthesized events. bye, not-synthesized besties π.-j,--jitβ processjitdumpfiles by injecting themmaprecords corresponding to jitted functions. This option also generates the ELF images for each jitted function found in thejitdumpsfiles captured in the inputperf.datafile. Use this option if you are monitoring an environment using JIT runtimes, such as Java, DART or V8. very demure, very JIT.-f,--forceβ Don't complain, do it.--vm-time-correlation[=OPTIONS]β some architectures may capture AUX area data which contains timestamps affected by virtualization. This option will update those timestamps in place, to correlate with host timestamps. The in-place update means that an output file is not specified, and instead the input file is modified π³. The options are architecture specific, except that they may start with"dry-run"which will cause the file to be processed but without updating it. Currently this option is supported only by Intel PT, referperf-intel-pt(1).--guest-data=<path>,<pid>[,<time offset>[,<time scale>]]β insert events from aperf.datafile recorded in a virtual machine at the same time as the inputperf.datafile was recorded on the host. The Process ID (PID) of the QEMU hypervisor process must be provided, and the time offset and time scale (multiplier) will likely be needed to convert guest time stamps into host time stamps. For example, for x86 the TSC Offset and Multiplier could be provided for a virtual machine using the Linux command line optionno-kvmclock. Currently onlymmap,mmap2,comm,task,context_switch,ksymbol, andtext_pokeevents are inserted, as well as build ID information. The QEMU option-name debug-threads=onis needed so that thread names can be used to determine which thread is running which VCPU. Notelibvirtseems to use this by default. When usingperf recordin the guest, option--sample-identifiershould be used, and also--buildid-alland--switch-eventsmay be useful. guest mode slay π«Ά.--convert-callchainβ parse DWARF callchains and convert them to usual callchains. This also discards stack and register data from the samples. Heads up: this will lose inlined callchain entries. sad but true π.--guestmount=<path>β guest OS root file system mount directory. Users mount guest OS root directories under<path>by a specific filesystem access method, typicallysshfs. For example, start 2 guest OS, one's pid is8888and the other's is9999:
$ mkdir ~/guestmount
$ cd ~/guestmount
$ sshfs -o allow_other,direct_io -p 5551 localhost:/ 8888/
$ sshfs -o allow_other,direct_io -p 5552 localhost:/ 9999/
$ perf inject --guestmount=~/guestmount
π SEE ALSO π
perf-record(1), perf-report(1), perf-archive(1), perf-intel-pt(1)
okay that's the whole page bestie β¨ this masterpiece is from the perf manual, dated 10/31/2026, and it lives as PERF-INJECT(1) β periodt π
π
π¦ where this page comes from
- arch rolling: perf 7.3.1-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms