linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: fix handling of .debug cache for kernel symbols
@ 2011-12-02  4:48 Stephane Eranian
  2011-12-02  6:05 ` David Ahern
  0 siblings, 1 reply; 2+ messages in thread
From: Stephane Eranian @ 2011-12-02  4:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: acme, dsahern, peterz, mingo, fweisbec

There was a bug in the way perf was looking for
kernel symbols when the .debug cache was not in $HOME.

With the /etc/perfconfig or $HOME/.perfconfig files, it
is possible to use an alternate location for the .debug
buildid + binary cache.

The problem is that the alternate location was ignored
for kernel symbols, leading to partial profiles in case
the host kernel was  not the one used to collect the profile,
e.g., with remote profiling.

This patch fixes the problem by adding the buildi_dir prefix
to the lookup path used in dso__load_kernel_sym().

The change to util.h is necessary to avoid a redefinition
of _GNU_SOURCE.

Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 632b50c..8ace954 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -16,6 +16,7 @@
 #include "debug.h"
 #include "symbol.h"
 #include "strlist.h"
+#include "util.h"
 
 #include <libelf.h>
 #include <gelf.h>
@@ -2082,8 +2083,8 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
 				  sbuild_id);
 
 		if (asprintf(&kallsyms_allocated_filename,
-			     "%s/.debug/[kernel.kallsyms]/%s",
-			     getenv("HOME"), sbuild_id) == -1) {
+			     "%s/[kernel.kallsyms]/%s",
+			     buildid_dir, sbuild_id) == -1) {
 			pr_err("Not enough memory for kallsyms file lookup\n");
 			return -1;
 		}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0128906..4b90e93 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -40,7 +40,9 @@
 #define decimal_length(x)	((int)(sizeof(x) * 2.56 + 0.5) + 1)
 
 #define _ALL_SOURCE 1
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
+#endif
 #define _BSD_SOURCE 1
 #define HAS_BOOL
 

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

* Re: [PATCH] perf: fix handling of .debug cache for kernel symbols
  2011-12-02  4:48 [PATCH] perf: fix handling of .debug cache for kernel symbols Stephane Eranian
@ 2011-12-02  6:05 ` David Ahern
  0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2011-12-02  6:05 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, acme, peterz, mingo, fweisbec



On 12/01/2011 09:48 PM, Stephane Eranian wrote:
> There was a bug in the way perf was looking for
> kernel symbols when the .debug cache was not in $HOME.

By chance have you encountered problems with annotate in this scenario?
 i.e., remote analysis with a copy of /proc/kallsyms from the target and
using the --vmlinux argument.

For example, 'perf report --kallsyms kallsyms --vmlinux vmlinux ...' and
then attempting to use the annotate option? I have a hit a few issues
with this path - and kernel modules with a symfs path -- that I have not
had time to debug yet.

David


> 
> With the /etc/perfconfig or $HOME/.perfconfig files, it
> is possible to use an alternate location for the .debug
> buildid + binary cache.
> 
> The problem is that the alternate location was ignored
> for kernel symbols, leading to partial profiles in case
> the host kernel was  not the one used to collect the profile,
> e.g., with remote profiling.
> 
> This patch fixes the problem by adding the buildi_dir prefix
> to the lookup path used in dso__load_kernel_sym().
> 
> The change to util.h is necessary to avoid a redefinition
> of _GNU_SOURCE.
> 
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
> 
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 632b50c..8ace954 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -16,6 +16,7 @@
>  #include "debug.h"
>  #include "symbol.h"
>  #include "strlist.h"
> +#include "util.h"
>  
>  #include <libelf.h>
>  #include <gelf.h>
> @@ -2082,8 +2083,8 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
>  				  sbuild_id);
>  
>  		if (asprintf(&kallsyms_allocated_filename,
> -			     "%s/.debug/[kernel.kallsyms]/%s",
> -			     getenv("HOME"), sbuild_id) == -1) {
> +			     "%s/[kernel.kallsyms]/%s",
> +			     buildid_dir, sbuild_id) == -1) {
>  			pr_err("Not enough memory for kallsyms file lookup\n");
>  			return -1;
>  		}
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 0128906..4b90e93 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -40,7 +40,9 @@
>  #define decimal_length(x)	((int)(sizeof(x) * 2.56 + 0.5) + 1)
>  
>  #define _ALL_SOURCE 1
> +#ifndef _GNU_SOURCE
>  #define _GNU_SOURCE 1
> +#endif
>  #define _BSD_SOURCE 1
>  #define HAS_BOOL
>  

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

end of thread, other threads:[~2011-12-02  6:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-02  4:48 [PATCH] perf: fix handling of .debug cache for kernel symbols Stephane Eranian
2011-12-02  6:05 ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).