diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-08 08:10:00 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-13 08:06:25 -0500 |
commit | fad2918ed5171e6299a9b4b885d0459f35ee7377 (patch) | |
tree | 80d36a6a68b18ba4692b45eb81353e0860d853d6 /tools/perf/builtin-report.c | |
parent | 88aca8d966a1349631a0946ed77c7ed360519ed4 (diff) |
perf report: Move logic to warn about kptr_restrict'ed kernels to separate function
Its too big, better have a separate function for it so that the main
logic gets shorter/clearer.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-ahh6vfzyh8fsygjwrsbroeu0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index bf8dd2e893e4..f2ff8609e98e 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -412,14 +412,41 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
412 | return 0; | 412 | return 0; |
413 | } | 413 | } |
414 | 414 | ||
415 | static void report__warn_kptr_restrict(const struct report *rep) | ||
416 | { | ||
417 | struct map *kernel_map = rep->session->machines.host.vmlinux_maps[MAP__FUNCTION]; | ||
418 | struct kmap *kernel_kmap = map__kmap(kernel_map); | ||
419 | |||
420 | if (kernel_map == NULL || | ||
421 | (kernel_map->dso->hit && | ||
422 | (kernel_kmap->ref_reloc_sym == NULL || | ||
423 | kernel_kmap->ref_reloc_sym->addr == 0))) { | ||
424 | const char *desc = | ||
425 | "As no suitable kallsyms nor vmlinux was found, kernel samples\n" | ||
426 | "can't be resolved."; | ||
427 | |||
428 | if (kernel_map) { | ||
429 | const struct dso *kdso = kernel_map->dso; | ||
430 | if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) { | ||
431 | desc = "If some relocation was applied (e.g. " | ||
432 | "kexec) symbols may be misresolved."; | ||
433 | } | ||
434 | } | ||
435 | |||
436 | ui__warning( | ||
437 | "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n" | ||
438 | "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n" | ||
439 | "Samples in kernel modules can't be resolved as well.\n\n", | ||
440 | desc); | ||
441 | } | ||
442 | } | ||
443 | |||
415 | static int __cmd_report(struct report *rep) | 444 | static int __cmd_report(struct report *rep) |
416 | { | 445 | { |
417 | int ret = -EINVAL; | 446 | int ret = -EINVAL; |
418 | u64 nr_samples; | 447 | u64 nr_samples; |
419 | struct perf_session *session = rep->session; | 448 | struct perf_session *session = rep->session; |
420 | struct perf_evsel *pos; | 449 | struct perf_evsel *pos; |
421 | struct map *kernel_map; | ||
422 | struct kmap *kernel_kmap; | ||
423 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; | 450 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; |
424 | struct ui_progress prog; | 451 | struct ui_progress prog; |
425 | struct perf_data_file *file = session->file; | 452 | struct perf_data_file *file = session->file; |
@@ -444,30 +471,7 @@ static int __cmd_report(struct report *rep) | |||
444 | if (ret) | 471 | if (ret) |
445 | return ret; | 472 | return ret; |
446 | 473 | ||
447 | kernel_map = session->machines.host.vmlinux_maps[MAP__FUNCTION]; | 474 | report__warn_kptr_restrict(rep); |
448 | kernel_kmap = map__kmap(kernel_map); | ||
449 | if (kernel_map == NULL || | ||
450 | (kernel_map->dso->hit && | ||
451 | (kernel_kmap->ref_reloc_sym == NULL || | ||
452 | kernel_kmap->ref_reloc_sym->addr == 0))) { | ||
453 | const char *desc = | ||
454 | "As no suitable kallsyms nor vmlinux was found, kernel samples\n" | ||
455 | "can't be resolved."; | ||
456 | |||
457 | if (kernel_map) { | ||
458 | const struct dso *kdso = kernel_map->dso; | ||
459 | if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) { | ||
460 | desc = "If some relocation was applied (e.g. " | ||
461 | "kexec) symbols may be misresolved."; | ||
462 | } | ||
463 | } | ||
464 | |||
465 | ui__warning( | ||
466 | "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n" | ||
467 | "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n" | ||
468 | "Samples in kernel modules can't be resolved as well.\n\n", | ||
469 | desc); | ||
470 | } | ||
471 | 475 | ||
472 | if (use_browser == 0) { | 476 | if (use_browser == 0) { |
473 | if (verbose > 3) | 477 | if (verbose > 3) |