Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1446260 > unrolled thread
| Started by | Song Shan Gong <gongss@linux.vnet.ibm.com> |
|---|---|
| First post | 2016-07-19 11:10 +0200 |
| Last post | 2016-07-19 13:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH RFC V1] perf tests: ignore symbols before kernel start Song Shan Gong <gongss@linux.vnet.ibm.com> - 2016-07-19 11:10 +0200
[Question] for duplicate symbols, kallsyms and vmlinux may retain different symbol Songshan Gong <gongss@linux.vnet.ibm.com> - 2016-07-19 13:20 +0200
| From | Song Shan Gong <gongss@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-07-19 11:10 +0200 |
| Subject | [PATCH RFC V1] perf tests: ignore symbols before kernel start |
| Message-ID | <rWzcl-27O-1@gated-at.bofh.it> |
perf gets kernel map start in function 'machine__get_running_kernel_start', by finding the first no-zero value of symbol start value of '_text' or '_stext'. Though kernel maybe start from a no-zero value, perf loads all symbols into a red-black tree, even if one symbol starts from zero (for example, '_text' is zero, '_stext' is kernel map start value, '_text' is also added to the red-black tree). In test function 'test__vmlinux_matches_kallsyms', perf traverses all vmlinux symbols by enumerating its red-black tree, but finding the pair symbol in kallsyms by 'machine__find_kernel_symbol'. For function 'machine__find_kernel_symbol', it will find the matched map firstly, then find the pair symbol in the red-black tree corresponding to that map. So when '_text' is zero, '_stext' is kernel map start(no-zero), we can get '_text' symbol of vmlinux, but we can't find the pair '_text' symbol of kallsyms, because there is no map starting from zero. This mismatch is incorrrect. Fix by just ignoring these symbols before kernel start. Signed-off-by: Song Shan Gong <gongss@linux.vnet.ibm.com> --- tools/perf/tests/vmlinux-kallsyms.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index e63abab..6766006 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -28,6 +28,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) enum map_type type = MAP__FUNCTION; struct maps *maps = &vmlinux.kmaps.maps[type]; u64 mem_start, mem_end; + u64 kernel_start; /* * Step 1: @@ -75,6 +76,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) * same value in the vmlinux file we load. */ kallsyms_map = machine__kernel_map(&kallsyms); + kernel_start = kallsyms_map->start; /* * Step 5: @@ -119,7 +121,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) sym = rb_entry(nd, struct symbol, rb_node); - if (sym->start == sym->end) + if (sym->start == sym->end || sym->start < kernel_start) continue; mem_start = vmlinux_map->unmap_ip(vmlinux_map, sym->start); -- 2.3.0
[toc] | [next] | [standalone]
| From | Songshan Gong <gongss@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-07-19 13:20 +0200 |
| Subject | [Question] for duplicate symbols, kallsyms and vmlinux may retain different symbol |
| Message-ID | <rWBea-3l1-25@gated-at.bofh.it> |
| In reply to | #1446260 |
I try to fix the failure of testcase 'test__vmlinux_matches_kallsyms',
and meet a kind of failure because of duplicate symbols.
For example,two functions:
kretprobe_trampoline_holder and kretprobe_trampoline
(1)They all start from the same addr,0x011b180;
(2)kretprobe_trampoline_holder is STB_LOCAL,
kretprobe_trampoline is STB_GLOBAL;
(3) for kallsyms, because we cann't get the correct size of each symbol
from /proc/kallsyms, before symbols__fixup_duplicate(), perf assumes
each symbol's size is zero, so when choose_best_symbol(), we get
kretprobe_trampoline because perf prefers 'a global symbol over a
non-global one';
(4) for vmlinux, by readelf, I found that:
size of kretprobe_trampoline_holder is 4, not zero;
size of kretprobe_trampoline is zero;
So when choose_best_symbol(), we get pretprobe_trampoline_holder instead
because perf prefers 'A symbol with non-zero length' and this condition
is judged before 'prefer a global symbol';
I have a idea to fix this problem, but may be inappropriate:
Could we move the judge of symbol size to the bottom of the judge
whether a symbol is global?
Anyone else have good idea?
Song Shan Gong
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web