All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf report: fix crash showing warning related to kernel maps
@ 2012-04-10 16:15 David Ahern
  2012-04-15 20:59 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2012-04-10 16:15 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, peterz, eranian, namhyung.kim, David Ahern

While testing https://lkml.org/lkml/2012/4/10/123 I hit this crash:

(gdb) bt
 0  0x000000000042000f in __cmd_report (rep=0x7fff80cec580) at builtin-report.c:380
 1  cmd_report (argc=0, argv=<optimized out>, prefix=<optimized out>) at builtin-report.c:759
 2  0x0000000000414513 in run_builtin (p=0x7724a8, argc=3, argv=0x7fff80ceca70) at perf.c:273
 3  0x0000000000413d41 in handle_internal_command (argv=0x7fff80ceca70, argc=3) at perf.c:345
 4  run_argv (argv=0x7fff80cec880, argcp=0x7fff80cec88c) at perf.c:389
 5  main (argc=3, argv=0x7fff80ceca70) at perf.c:487

kernel_map can be NULL, so need to handle it while dumping a warning
to user.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 tools/perf/builtin-report.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 2e31743..002c644 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -374,16 +374,23 @@ static int __cmd_report(struct perf_report *rep)
 	    (kernel_map->dso->hit &&
 	     (kernel_kmap->ref_reloc_sym == NULL ||
 	      kernel_kmap->ref_reloc_sym->addr == 0))) {
-		const struct dso *kdso = kernel_map->dso;
+		const char *desc = 
+		    "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
+		    "can't be resolved.";
+
+		if (kernel_map) {
+			const struct dso *kdso = kernel_map->dso;
+			if (RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
+				desc = "If some relocation was applied (e.g. "
+				       "kexec) symbols may be misresolved.";
+			}
+		}
 
 		ui__warning(
 "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
 "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
 "Samples in kernel modules can't be resolved as well.\n\n",
-			    RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ?
-"As no suitable kallsyms nor vmlinux was found, kernel samples\n"
-"can't be resolved." :
-"If some relocation was applied (e.g. kexec) symbols may be misresolved.");
+		desc);
 	}
 
 	if (dump_trace) {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf report: fix crash showing warning related to kernel maps
  2012-04-10 16:15 [PATCH] perf report: fix crash showing warning related to kernel maps David Ahern
@ 2012-04-15 20:59 ` David Ahern
  0 siblings, 0 replies; 3+ messages in thread
From: David Ahern @ 2012-04-15 20:59 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, mingo, peterz, eranian, namhyung.kim

Hi Arnaldo:

Haven't seen this one come through your urgent queue.

On 4/10/12 10:15 AM, David Ahern wrote:
> While testing https://lkml.org/lkml/2012/4/10/123 I hit this crash:
>
> (gdb) bt
>   0  0x000000000042000f in __cmd_report (rep=0x7fff80cec580) at builtin-report.c:380
>   1  cmd_report (argc=0, argv=<optimized out>, prefix=<optimized out>) at builtin-report.c:759
>   2  0x0000000000414513 in run_builtin (p=0x7724a8, argc=3, argv=0x7fff80ceca70) at perf.c:273
>   3  0x0000000000413d41 in handle_internal_command (argv=0x7fff80ceca70, argc=3) at perf.c:345
>   4  run_argv (argv=0x7fff80cec880, argcp=0x7fff80cec88c) at perf.c:389
>   5  main (argc=3, argv=0x7fff80ceca70) at perf.c:487
>
> kernel_map can be NULL, so need to handle it while dumping a warning
> to user.
>
> Signed-off-by: David Ahern<dsahern@gmail.com>
> ---
>   tools/perf/builtin-report.c |   17 ++++++++++++-----
>   1 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 2e31743..002c644 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -374,16 +374,23 @@ static int __cmd_report(struct perf_report *rep)
>   	    (kernel_map->dso->hit&&
>   	(kernel_kmap->ref_reloc_sym == NULL ||
>   	      kernel_kmap->ref_reloc_sym->addr == 0))) {
> -		const struct dso *kdso = kernel_map->dso;
> +		const char *desc =
> +		    "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
> +		    "can't be resolved.";
> +
> +		if (kernel_map) {
> +			const struct dso *kdso = kernel_map->dso;
> +			if (RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
> +				desc = "If some relocation was applied (e.g. "
> +				       "kexec) symbols may be misresolved.";
> +			}
> +		}
>
>   		ui__warning(
>   "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
>   "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
>   "Samples in kernel modules can't be resolved as well.\n\n",
> -			    RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ?
> -"As no suitable kallsyms nor vmlinux was found, kernel samples\n"
> -"can't be resolved." :
> -"If some relocation was applied (e.g. kexec) symbols may be misresolved.");
> +		desc);
>   	}
>
>   	if (dump_trace) {


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] perf report: fix crash showing warning related to kernel maps
@ 2012-04-16  2:54 David Ahern
  0 siblings, 0 replies; 3+ messages in thread
From: David Ahern @ 2012-04-16  2:54 UTC (permalink / raw)
  To: acme, linux-kernel; +Cc: mingo, peterz, eranian, namhyung.kim, David Ahern

While testing https://lkml.org/lkml/2012/4/10/123 I hit this crash:

(gdb) bt
 0  0x000000000042000f in __cmd_report (rep=0x7fff80cec580) at builtin-report.c:380
 1  cmd_report (argc=0, argv=<optimized out>, prefix=<optimized out>) at builtin-report.c:759
 2  0x0000000000414513 in run_builtin (p=0x7724a8, argc=3, argv=0x7fff80ceca70) at perf.c:273
 3  0x0000000000413d41 in handle_internal_command (argv=0x7fff80ceca70, argc=3) at perf.c:345
 4  run_argv (argv=0x7fff80cec880, argcp=0x7fff80cec88c) at perf.c:389
 5  main (argc=3, argv=0x7fff80ceca70) at perf.c:487

kernel_map can be NULL, so need to handle it while dumping a warning
to user.

v2:
- fixed RB_EMPTY_ROOT check -- desc takes the altnerative output when RB_EMPTY_ROOT is false.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 tools/perf/builtin-report.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 2e31743..42c06db4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -374,16 +374,23 @@ static int __cmd_report(struct perf_report *rep)
 	    (kernel_map->dso->hit &&
 	     (kernel_kmap->ref_reloc_sym == NULL ||
 	      kernel_kmap->ref_reloc_sym->addr == 0))) {
-		const struct dso *kdso = kernel_map->dso;
+		const char *desc = 
+		    "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
+		    "can't be resolved.";
+
+		if (kernel_map) {
+			const struct dso *kdso = kernel_map->dso;
+			if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
+				desc = "If some relocation was applied (e.g. "
+				       "kexec) symbols may be misresolved.";
+			}
+		}
 
 		ui__warning(
 "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
 "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
 "Samples in kernel modules can't be resolved as well.\n\n",
-			    RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ?
-"As no suitable kallsyms nor vmlinux was found, kernel samples\n"
-"can't be resolved." :
-"If some relocation was applied (e.g. kexec) symbols may be misresolved.");
+		desc);
 	}
 
 	if (dump_trace) {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-16  2:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-10 16:15 [PATCH] perf report: fix crash showing warning related to kernel maps David Ahern
2012-04-15 20:59 ` David Ahern
2012-04-16  2:54 David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.