0

I am trying to use perf to profile a program that I have written on a work server. I have sudo privilege but should limit what I do with it.

$ rm perf.data
$ perf record ./catch-hedging stress_BS_EURUSD_03M_delta_gamma_n_2_1_1
WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
check /proc/sys/kernel/kptr_restrict.

Samples in kernel functions may not be resolved if a suitable vmlinux
file is not found in the buildid cache or in the vmlinux path.

Samples in kernel modules won't be resolved at all.

If some relocation was applied (e.g. kexec) symbols may be misresolved
even with a suitable vmlinux or kallsyms file.

Lowering default frequency rate to 250.
Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
Cannot read kernel map
Couldn't record kernel reference relocation symbol
Symbol resolution may be skewed if relocation was used (e.g. kexec).
Check /proc/kallsyms permission or run as root.
Read 'results-gcc.txt', got 285 results. Took 0.000514 seconds
===============================================================================
All tests passed (1 assertion in 1 test case)

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.007 MB perf.data (143 samples) ]

When I run perf report I get entries such as:

10.79%  catch-hedging  [unknown]         [k] 0xffffffff81614733

Now that I have sudo privilege I thought that would solve my problem with unresolved kernel symbols. So I run:

$ sudo perf record ./catch-hedging stress_BS_EURUSD_03M_delta_gamma_n_2_1_1
Lowering default frequency rate to 250.
Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
Read 'results-gcc.txt', got 285 results. Took 0.000942 seconds
===============================================================================
All tests passed (1 assertion in 1 test case)

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.020 MB perf.data (149 samples) ]

Which seems better but when I run sudo perf report -f symbols from my own code don't seem to be resolved:

17.13%  catch-hedging  catch-hedging      [.] 0x000000000002eced

Why are the symbols from my program not resolved? What can I do to resolve both the kernel symbols and the symbols from my program at the same time?

For reference a typical compilation command looks like (some names have been changed):

g++ -Wunused -pthread -std=c++17 -g -fno-omit-frame-pointer -O2 -pthread -std=c++17 -Wno-parentheses -Wsequence-point -Wconversion -Wuninitialized -Wunused -Wmissing-field-initializers -g -fno-omit-frame-pointer -O2 -Isome-include-directories-omitted -D__stdcall= -DWINAPI= '-D__declspec(X)='  -c -o file.o file.cpp

I am using g++ 8.1.0.

  • Did you compile your program with -g? – meuh Jul 24 '18 at 13:22
  • @meuh thanks for the query. I have edited to include my compilation flags. To answer your question directly, I am compiling with -g (and -fno-omit-frame-pointer). – Bowie Owens Jul 24 '18 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.