]> git.ipfire.org Git - thirdparty/linux.git/commit
perf inject: Add --convert-callchain option
authorNamhyung Kim <namhyung@kernel.org>
Tue, 13 Jan 2026 23:29:02 +0000 (15:29 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Jan 2026 20:18:24 +0000 (17:18 -0300)
commit92ea788d2af4e65ad7a144ccfff50667e9a0d227
tree8dd3b0dde002032c5a857b6d6bf18a5f800a8df4
parent28cb835f7645892f4559b92fcfeb25a81646f4cf
perf inject: Add --convert-callchain option

There are applications not built with frame pointers, so DWARF is needed
to get the stack traces.

`perf record --call-graph dwarf` saves the stack and register data for
each sample to get the stacktrace offline.  But sometimes this data may
have sensitive information and we don't want to keep them in the file.

This new 'perf inject --convert-callchain' option creates the callchains
and discards the stack and register after that.

This saves storage space and processing time for the new data file.

Of course, users should remove the original data file to not keep
sensitive data around.  :)

The down side is that it cannot handle inlined callchain entries as they
all have the same IPs.

Maybe we can add an option to 'perf report' to look up inlined functions
using DWARF - IIUC it doesn't require stack and register data.

This is an example.

  $ perf record --call-graph dwarf -- perf test -w noploop

  $ perf report --stdio --no-children --percent-limit=0 > output-prev

  $ perf inject -i perf.data --convert-callchain -o perf.data.out

  $ perf report --stdio --no-children --percent-limit=0 -i perf.data.out > output-next

  $ diff -u output-prev output-next
  ...
        0.23%  perf          ld-linux-x86-64.so.2  [.] _dl_relocate_object_no_relro
               |
  -            ---elf_dynamic_do_Rela (inlined)
  -               _dl_relocate_object_no_relro
  +            ---_dl_relocate_object_no_relro
                  _dl_relocate_object
                  dl_main
                  _dl_sysdep_start
  -               _dl_start_final (inlined)
                  _dl_start
                  _start

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-inject.txt
tools/perf/builtin-inject.c