Commit 6cff0e8dbaa4d5d822a814e5028683d7e71c3291

Authored by Kirill Smelkov
Committed by Ingo Molnar
1 parent 7a2b620986

perf top: Teach it to autolocate vmlinux

By relying on logic in dso__load_kernel_sym(), we can
automatically load vmlinux.

The only thing which needs to be adjusted, is how --sym-annotate
option is handled - now we can't rely on vmlinux been loaded
until full successful pass of dso__load_vmlinux(), but that's
not the case if we'll do sym_filter_entry setup in
symbol_filter().

So move this step right after event__process_sample() where we
know the whole dso__load_kernel_sym() pass is done.

By the way, though conceptually similar `perf top` still can't
annotate userspace - see next patches with fixes.

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-9-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 2 changed files with 24 additions and 17 deletions Side-by-side Diff

tools/perf/Documentation/perf-top.txt
... ... @@ -74,7 +74,7 @@
74 74  
75 75 -s <symbol>::
76 76 --sym-annotate=<symbol>::
77   - Annotate this symbol. Requires -k option.
  77 + Annotate this symbol.
78 78  
79 79 -v::
80 80 --verbose::
tools/perf/builtin-top.c
... ... @@ -94,6 +94,7 @@
94 94  
95 95 static char *sym_filter = NULL;
96 96 struct sym_entry *sym_filter_entry = NULL;
  97 +struct sym_entry *sym_filter_entry_sched = NULL;
97 98 static int sym_pcnt_filter = 5;
98 99 static int sym_counter = 0;
99 100 static int display_weighted = -1;
... ... @@ -695,11 +696,9 @@
695 696  
696 697 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter);
697 698  
698   - if (symbol_conf.vmlinux_name) {
699   - fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter);
700   - fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
701   - fprintf(stdout, "\t[S] stop annotation.\n");
702   - }
  699 + fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter);
  700 + fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
  701 + fprintf(stdout, "\t[S] stop annotation.\n");
703 702  
704 703 if (nr_counters > 1)
705 704 fprintf(stdout, "\t[w] toggle display weighted/count[E]r. \t(%d)\n", display_weighted ? 1 : 0);
706 705  
... ... @@ -725,14 +724,13 @@
725 724 case 'Q':
726 725 case 'K':
727 726 case 'U':
  727 + case 'F':
  728 + case 's':
  729 + case 'S':
728 730 return 1;
729 731 case 'E':
730 732 case 'w':
731 733 return nr_counters > 1 ? 1 : 0;
732   - case 'F':
733   - case 's':
734   - case 'S':
735   - return symbol_conf.vmlinux_name ? 1 : 0;
736 734 default:
737 735 break;
738 736 }
739 737  
... ... @@ -910,9 +908,13 @@
910 908 syme = symbol__priv(sym);
911 909 syme->map = map;
912 910 syme->src = NULL;
913   - if (!sym_filter_entry && sym_filter && !strcmp(name, sym_filter))
914   - sym_filter_entry = syme;
915 911  
  912 + if (!sym_filter_entry && sym_filter && !strcmp(name, sym_filter)) {
  913 + /* schedule initial sym_filter_entry setup */
  914 + sym_filter_entry_sched = syme;
  915 + sym_filter = NULL;
  916 + }
  917 +
916 918 for (i = 0; skip_symbols[i]; i++) {
917 919 if (!strcmp(skip_symbols[i], name)) {
918 920 syme->skip = 1;
... ... @@ -976,6 +978,13 @@
976 978 return;
977 979 }
978 980  
  981 + /* let's see, whether we need to install initial sym_filter_entry */
  982 + if (sym_filter_entry_sched) {
  983 + sym_filter_entry = sym_filter_entry_sched;
  984 + sym_filter_entry_sched = NULL;
  985 + parse_source(sym_filter_entry);
  986 + }
  987 +
979 988 syme = symbol__priv(al.sym);
980 989 if (!syme->skip) {
981 990 syme->count[counter]++;
... ... @@ -1270,7 +1279,7 @@
1270 1279 OPT_BOOLEAN('i', "inherit", &inherit,
1271 1280 "child tasks inherit counters"),
1272 1281 OPT_STRING('s', "sym-annotate", &sym_filter, "symbol name",
1273   - "symbol to annotate - requires -k option"),
  1282 + "symbol to annotate"),
1274 1283 OPT_BOOLEAN('z', "zero", &zero,
1275 1284 "zero history across updates"),
1276 1285 OPT_INTEGER('F', "freq", &freq,
1277 1286  
... ... @@ -1306,15 +1315,13 @@
1306 1315  
1307 1316 symbol_conf.priv_size = (sizeof(struct sym_entry) +
1308 1317 (nr_counters + 1) * sizeof(unsigned long));
1309   - if (symbol_conf.vmlinux_name == NULL)
1310   - symbol_conf.try_vmlinux_path = true;
  1318 +
  1319 + symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
1311 1320 if (symbol__init() < 0)
1312 1321 return -1;
1313 1322  
1314 1323 if (delay_secs < 1)
1315 1324 delay_secs = 1;
1316   -
1317   - parse_source(sym_filter_entry);
1318 1325  
1319 1326 /*
1320 1327 * User specified count overrides default frequency.