The [unknown] block in the perf report output refers to the name of the dynamic shared object (DSO). perf report could not resolve the DSO path and hence it prints [unknown]. Per the latest kernel source code tree (which is 5.3.9 at the time of writing), you can see this here.
It is important to know that the determination of the DSO symbols happen with the help of the sampled event address. The function thread__resolve is responsible for doing exactly that. In older kernels, the thread__resolve method had another name - perf_event__preprocess_sample_addr.
Given the snapshot of your output, it looks like the address of the event that was sampled during perf record, is 0. This means that the address could not be resolved at all. It is an address in the kernel space (looking at the symbol [k] 0000000000000000) and perf in your case, could not resolve it.
The comments highlight setting perf_event_paranoid to a suitable value so that you can probe both kernel and user-space events successfully. Setting perf_event_paranoid to a value that allows you to correctly probe events in the kernel space should "be a step" towards correctly resolving the address.
Missing stack symbols with perf_event's perf report, despite -fno-omit-frame-pointer compilation - Unix & Linux Stack Exchange
LINUX-KERNEL: Perf report shared objects showing unknown on ARM - Stack Overflow
perf profiling - unknown - C++ Forum
[unknown] functions
I'm compiling using more debugging options:
-Og -ggdb3 -fno-omit-frame-pointer
Then, when I record I'm not using -a option (that should monitor all the system processes), I'm using
perf record -e cycles -g --call-graph fp -- ./your_app your_args
Finally, to show the result I'm using
perf report -g graph
and the output looks like expected (note, I'm using debian 9 and the perf report output is ncurses based)
- 92.18% 0.00% stsm stsm [.] main ◆
- main ▒
- 91.77% STSM::run ▒
+ 56.86% STSM::generateCandidates ▒
- 25.22% STSM::detectBlocksOfAllSolidSequences ▒
+ 23.42% STSM::detectSolidSequenceBlocksFromSolidSequence ▒
0.81% Segment::unify ▒
+ 5.25% STSM::updateKernelsOfAllCandidates ▒
1.80% RangedSequence::range ▒
+ 1.45% STSM::updateMatchingPositions ▒
0.99% Segment::intersects ▒
+ 92.18% 0.00% stsm libc-2.24.so [.] __libc_start_main ▒
+ 92.18% 0.00% stsm [unknown] [k] 0x4d96258d4c544155 ▒
+ 91.77% 0.00% stsm stsm [.] STSM::run ▒
+ 56.86% 6.74% stsm stsm [.] STSM::generateCandidates ▒
+ 49.99% 49.99% stsm stsm [.] Segment::intersects ▒
+ 25.22% 0.00% stsm stsm [.] STSM::detectBlocksOfAllSolidSequences
This is an old topic but am sure it still happens to hundreds of people and because this StackExchange question still shows up high on Google results, am sharing answer found on StackOverflow that worked for me: https://stackoverflow.com/questions/33137543/linux-perf-top-kernel-symbol-not-found
Basically:
Before starting perf record
echo 0 > /proc/sys/kernel/kptr_restrict
Also it might be necessary to setup these
For RHEL/CentOS/Fedora/etc
yum install -y elfutils-libelf-devel libunwind-devel audit-libs-devel slang-devel
Or for Debian/Ubuntu/etc
apt-get install libelf-dev libunwind-dev libaudit-dev libslang-dev
hi,
i've started profiling my rust code (under linux, using perf) and I'm running into troubles. i'm basically following this tutorial
so I compile my benchmark, and use perf to get some data.
~/c/J/r/jimn ❯❯❯ perf record -g -- ./target/release/jimn-9d2a6ca5c444e0ff --bench bench_slow running 1 test test bentley_ottmann::tests::bench_slow ... bench: 58,791,165 ns/iter (+/- 3,952,229) test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured [ perf record: Woken up 20 times to write data ] [ perf record: Captured and wrote 5.000 MB perf.data (69974 samples) ]
now, my output using perf report looks like this:
Samples: 69K of event 'cycles:u', Event count (approx.): 49428164411
Children Self Command Shared Object Symbol
20,75% 20,74% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] <jimn::bentley_ottmann::KeyGenerator<'a, T> as jimn::
9,52% 0,00% jimn-9d2a6ca5c4 [unknown] [.] 0x0000000000000001
5,51% 5,51% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] <std::collections::hash::map::HashMap<K, V, S>>::make
5,19% 5,19% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] <std::collections::hash::map::DefaultHasher as core::
4,91% 4,91% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] <std::collections::hash::map::DefaultHasher as core::
4,79% 0,54% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] jimn::utils::coordinates_hash::CoordinatesHash::hash_
4,23% 0,19% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] collections::fmt::format
4,09% 0,00% jimn-9d2a6ca5c4 [unknown] [.] 0000000000000000
4,06% 4,04% jimn-9d2a6ca5c4 jimn-9d2a6ca5c444e0ff [.] jimn::bentley_ottmann::Cutter::run
so, I have two kinds of questions :
-
what are these unknown ? (and how to get to some useful symbols)
-
my main function is actually Cutter::run (last line). since it is the main function should'nt it have cumulatively 100% of all cycles and not just 4.06% ? if not, how to read the children and self percentages ?
thanks a lot for any hint.