Skip to content

Commit

Permalink
perf test: Look forward for symbol aliases
Browse files Browse the repository at this point in the history
Not just before, fixing these false positives:

[acme@mica linux]$ perf test -v 1
 1: vmlinux symtab matches kallsyms:
--- start ---
Looking at the vmlinux_path (6 entries long)
Using //lib/modules/2.6.37-rc5-00180-ge06b6bf/build/vmlinux for symbols
0xffffffff81058dc0: diff name v: sys_vm86old k: sys_ni_syscall
0xffffffff81058dc0: diff name v: sys_vm86 k: sys_ni_syscall
0xffffffff81058dc0: diff name v: sys_subpage_prot k: sys_ni_syscall
0xffffffff810b5f7c: diff name v: probe_kernel_write k: __probe_kernel_write
0xffffffff810b5fe5: diff name v: probe_kernel_read k: __probe_kernel_read
0xffffffff811bc380: diff name v: __memset k: memset
0xffffffff81384a98: diff name v: __sched_text_start k: sleep_on_common
0xffffffff81386750: diff name v: __sched_text_end k: _raw_spin_trylock
0xffffffff8138cee8: diff name v: __irqentry_text_start k: do_IRQ
0xffffffff8138f079: diff name v: __start_notes k: _etext
0xffffffff8138f079: diff name v: __stop_notes k: _etext
---- end ----
vmlinux symtab matches kallsyms: FAILED!

[acme@mica linux]$

Some are weak functions, others are just markers, etc. They get in the rb tree
with the same addr, so we need to look around to find the symbol with the same
name.

We were looking just at the previous entries with the same addr, look forward
too.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Han Pingtian <phan@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Dec 22, 2010
1 parent 3b01a41 commit d367875
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tools/perf/builtin-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ static int test__vmlinux_matches_kallsyms(void)
* end addresses too.
*/
for (nd = rb_first(&vmlinux_map->dso->symbols[type]); nd; nd = rb_next(nd)) {
struct symbol *pair;
struct symbol *pair, *first_pair;
bool backwards = true;

sym = rb_entry(nd, struct symbol, rb_node);
pair = machine__find_kernel_symbol(&kallsyms, type, sym->start, NULL, NULL);

if (sym->start == sym->end)
continue;

first_pair = machine__find_kernel_symbol(&kallsyms, type, sym->start, NULL, NULL);
pair = first_pair;

if (pair && pair->start == sym->start) {
next_pair:
Expand All @@ -143,8 +149,10 @@ static int test__vmlinux_matches_kallsyms(void)
pr_debug("%#Lx: diff end addr for %s v: %#Lx k: %#Lx\n",
sym->start, sym->name, sym->end, pair->end);
} else {
struct rb_node *nnd = rb_prev(&pair->rb_node);

struct rb_node *nnd;
detour:
nnd = backwards ? rb_prev(&pair->rb_node) :
rb_next(&pair->rb_node);
if (nnd) {
struct symbol *next = rb_entry(nnd, struct symbol, rb_node);

Expand All @@ -153,6 +161,13 @@ static int test__vmlinux_matches_kallsyms(void)
goto next_pair;
}
}

if (backwards) {
backwards = false;
pair = first_pair;
goto detour;
}

pr_debug("%#Lx: diff name v: %s k: %s\n",
sym->start, sym->name, pair->name);
}
Expand Down

0 comments on commit d367875

Please sign in to comment.