perf_annotate
Annotate function source and assembly with per-line sample percentages to pinpoint exactly where CPU time is spent, enabling targeted optimization.
Instructions
Source/assembly annotation: shows per-line or per-instruction sample percentages inside a specific function.
Use this after perf_report to drill into a hot function and see exactly which lines or instructions are consuming time.
Key parameters:
symbol: function name to annotate (default: hottest symbol).
dsos: restrict to a specific binary/library.
source: true (default) to interleave source code with assembly.
disassembler_style: 'intel' for Intel syntax (default: AT&T).
percent_type: 'local-period' (default), 'global-period', 'local-hits', 'global-hits'.
data_type: annotate a specific data type (DWARF data-type profiling).
code_with_type: show data type annotations on code.
Output: source/assembly listing with % annotations per line. Requires: debuginfo packages for source interleaving. Works on any perf.data from perf record.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cpu | No | List of CPUs to filter | |
| dsos | No | Only consider these DSOs | |
| force | No | Don't complain, do it | |
| group | No | Show event group information | |
| input | Yes | Path to perf.data file | |
| quiet | No | Do not show any warnings or messages | |
| symfs | No | Symbol filesystem root | |
| itrace | No | Instruction Tracing options | |
| prefix | No | Add prefix to source file paths | |
| source | No | Interleave source code with assembly (default on) | |
| symbol | No | Symbol name to annotate | |
| asm_raw | No | Display raw encoding of assembly | |
| modules | No | Load module symbols | |
| verbose | No | Verbosity level (0-2) | |
| vmlinux | No | vmlinux pathname | |
| demangle | No | Symbol demangling (default on) | |
| data_type | No | Name of data type to annotate | |
| insn_stat | No | Show instruction statistics | |
| type_stat | No | Show type annotation statistics | |
| full_paths | No | Display full source file paths | |
| print_line | No | Print source line number | |
| skip_empty | No | Do not display empty events | |
| percent_type | No | Percent type | |
| prefix_strip | No | Strip first N entries of source file path | |
| skip_missing | No | Skip symbols that cannot be annotated | |
| percent_limit | No | Don't show entries under this percent | |
| code_with_type | No | Show data type annotation for code | |
| dump_raw_trace | No | Dump raw trace in ASCII | |
| ignore_vmlinux | No | Don't load vmlinux even if found | |
| demangle_kernel | No | Enable kernel symbol demangling | |
| show_nr_samples | No | Show column with sample count | |
| show_total_period | No | Show column with sum of periods | |
| disassembler_style | No | Disassembler style (e.g. 'intel') |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |