perf symbols: Fix kallsyms kernel/module map splitting

On ARM, module addresss space is ahead of kernel space, so the module
symbols are handled before kernel symbol in dso__split_kallsyms, then
was causing one map to be created for each kernel symbol.

Reported-by: Ming Lei <tom.leiming@gmail.com>
Tested-by: Ming Lei <tom.leiming@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Ming Lei <tom.leiming@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20101124144540.GB15875@ghostprotocols.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+11 -5
+11 -5
tools/perf/util/symbol.c
··· 532 532 struct machine *machine = kmaps->machine; 533 533 struct map *curr_map = map; 534 534 struct symbol *pos; 535 - int count = 0; 535 + int count = 0, moved = 0; 536 536 struct rb_root *root = &self->symbols[map->type]; 537 537 struct rb_node *next = rb_first(root); 538 538 int kernel_range = 0; ··· 590 590 char dso_name[PATH_MAX]; 591 591 struct dso *dso; 592 592 593 + if (count == 0) { 594 + curr_map = map; 595 + goto filter_symbol; 596 + } 597 + 593 598 if (self->kernel == DSO_TYPE_GUEST_KERNEL) 594 599 snprintf(dso_name, sizeof(dso_name), 595 600 "[guest.kernel].%d", ··· 620 615 map_groups__insert(kmaps, curr_map); 621 616 ++kernel_range; 622 617 } 623 - 618 + filter_symbol: 624 619 if (filter && filter(curr_map, pos)) { 625 620 discard_symbol: rb_erase(&pos->rb_node, root); 626 621 symbol__delete(pos); ··· 628 623 if (curr_map != map) { 629 624 rb_erase(&pos->rb_node, root); 630 625 symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); 631 - } 632 - count++; 626 + ++moved; 627 + } else 628 + ++count; 633 629 } 634 630 } 635 631 ··· 640 634 dso__set_loaded(curr_map->dso, curr_map->type); 641 635 } 642 636 643 - return count; 637 + return count + moved; 644 638 } 645 639 646 640 int dso__load_kallsyms(struct dso *self, const char *filename,