If you see [unknown]
, the following might be useful assuming you're using --call-stack dwarf
:
-
Note that
--call-graph dwarf,1024
(where1024
is the stack size) dumps first 1024 bytes of the stack to the record file, then use DWARF debug information to deduce the frames later.This is quite inefficient (because it dumps the whole stack instead of just the addresses for each sample), but more importantly, if the stack is too deep (1024 bytes is insufficient) then the result is [unknown] frames.
So, either try increasing it to
dwarf,65528
(which is the maximum on my machine), or if it still doesn't work,--call-graph lbr
or--call-graph fp
(the last one may need recompile).
Other things to try:
-
echo 0 |sudo tee /proc/sys/kernel/kptr_restrict
(suggested in https://users.rust-lang.org/t/flamegraph-shows-every-caller-is-unknown/52408) -
perf map file must be owned by the correct user (https://stackoverflow.com/a/39662781/5267751)
-
sudo sysctl kernel.perf_event_paranoid=-1
(perf script
would print this out if needed) -
Flame graph can be generated by
perf script flamegraph -F 100 ./program args
but you can also explicitly separate the recording and the reporting step (to aid with debugging) by
perf record --call-graph lbr -F 100 ./program args perf script report flamegraph
Questions that needs to be cleaned up:
- https://stackoverflow.com/questions/27842281/unknown-events-in-nodejs-v8-flamegraph-using-perf-events
- https://stackoverflow.com/questions/10933408/how-can-i-get-perf-to-find-symbols-in-my-program
- https://stackoverflow.com/questions/68259699/how-can-you-get-frame-pointer-perf-call-stacks-flamegraphs-involving-the-c-sta
- https://unix.stackexchange.com/questions/276179/missing-stack-symbols-with-perf-events-perf-report-despite-fno-omit-frame-poi
References:
Notes:
- https://brendangregg.com/flamegraphs.html --- explains what is a flame chart (similar to flamegraph, but order the blocks by time instead of by size. I think
perf
doesn't support this...? Not sure if there's a way)
Other unrelated issues: