1)我的问题是:
当我使用perf报告时,它会得到如下结果:
# Overhead Command Shared Object Symbol
# . .
#
99.59% test test [.] 0x000003d4
0.21% test [kernel.kallsyms] [k] __do_fault
0.10% test [kernel.kallsyms] [k] run_timer_softirq
0.10% test [kernel.kallsyms] [k] __update_cpu_load
0.01% test [kernel.kallsyms] [k] set_task_comm
0.00% test [kernel.kallsyms] [k] intel_pmu_enable_all
那就是: perf可以在内核中找到符号但在我的程序中找不到符号。
我的节目在这里:
void longa()
{
int i,j;
for(i = 0; i < 1000000; i++)
j=i; //am I silly or crazy? I feel boring and desperate.
}
void foo2()
{
int i;
for(i=0 ; i < 10; i++)
longa();
}
void foo1()
{
int i;
for(i = 0; i< 100; i++)
longa();
}
int main(void)
{
foo1();
foo2();
}
2)我编译了程序,如:
gcc test.c -g -o test
我的环境: os:ubuntu内核:3.10.9
答案 0 :(得分:2)
今天,当我运行perf test
时,我收到一条消息vmlinux symtab matches kallsyms: Failed
。
当我找到原因时,我发现原因是/proc/sys/kernel/kptr_restrict
的值为1.当我们将其设置为0
时,我们将在程序中获得符号。< / p>
答案 1 :(得分:1)
该问题有两种可能的来源:
答案 2 :(得分:0)
如果它仍然不适合你,你可能想要检查调试符号是否正常,比如gdb。
% gcc test.c -g -o test
XXX@YYY
% perf record ./test
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.060 MB perf.data (~2620 samples) ]
XXX@YYY
% perf report --stdio
# ========
# captured on: Wed Oct 16 11:58:40 2013
# hostname : sundberg-office-antec
# os release : 3.8.0-31-generic
# perf version : 3.8.13.8
# arch : x86_64
# nrcpus online : 2
# nrcpus avail : 2
# cpudesc : AMD Phenom(tm) II X2 555 Processor
# cpuid : AuthenticAMD,16,4,3
# total memory : 16434276 kB
# cmdline : /usr/bin/perf_3.8.0-31 record ./test
# event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0, id = { 671, 672 }
# HEADER_CPU_TOPOLOGY info available, use -I to display
# HEADER_NUMA_TOPOLOGY info available, use -I to display
# pmu mappings: cpu = 4, software = 1, tracepoint = 2, ibs_fetch = 6, ibs_op = 7, breakpoint = 5
# ========
#
# Samples: 1K of event 'cycles'
# Event count (approx.): 1071717616
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. .........................
#
99.85% test test [.] longa
0.08% test [kernel.kallsyms] [k] call_timer_fn
0.08% test [kernel.kallsyms] [k] task_work_run
0.00% test [kernel.kallsyms] [k] clear_page_c
0.00% test [kernel.kallsyms] [k] native_write_msr_safe
#
# (For a higher level overview, try: perf report --sort comm,dso)
#
答案 3 :(得分:0)
我遇到了同样的问题,发现原因是我的性能的矮人功能没有开启。
一个简单的解决方案是重新编译性能:
% sudo apt-get install libdw-dev
% cd /path/to/perf/source/
% sudo make
% sudo make install
这使性能能够找到所有符号!
如果它仍然不适合您,请参阅此链接, how to compile a Linux perf tool with all features