Why isn't `perf` following a forked process?

Context

Paraphrased, stackoverflow.com/revisions/44866868/1 explains that:

perf record without -a option record all processes, forked (and threads cloned) from target process after starting of record. With perf record ./program it will profile all child processes too, and with perf record -p $PID with attaching to already running $PID it will profile target process and all child processes started after attaching. Profiling inheritance is enabled by default (code as required: attr->inherit = !opts->no_inherit; & no_inherit), and can be disabled with -i option and also disabled by -t and --per-thread.

Problem

However, it doesn’t for me. Using strace -Ttrf code, I can see where:

[pid 50176] 11:53:22 (+     0.000813) +++ exited with 0 +++
11:53:22 (+     0.000778) +++ exited with 0 +++
RokeJulianLockhart@Beedell:~$ strace -Ttrf code
11:53:25 (+     0.000000) execve("/usr/bin/code", ["code"], 0x7ffe57e4e9a8 /* 87 vars */) = 0 <0.000146>

[1]

Questions

Consequently:

  1. Why isn’t it following forked processes by default?

  2. How can I explicitly instruct perf to follow the child process?


  1. github.com/microsoft/vscode/issues/250181#issuecomment-2924965674 ↩︎