linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: Avoid resolving [kernel.kallsyms] to real path for buildid cache
@ 2011-03-03 15:23 Lin Ming
  2011-03-09 14:38 ` Lin Ming
  2011-03-10  6:36 ` [tip:perf/urgent] perf symbols: " tip-bot for Lin Ming
  0 siblings, 2 replies; 4+ messages in thread
From: Lin Ming @ 2011-03-03 15:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Han Pingtian, Peter Zijlstra, Ingo Molnar, linux-kernel,
	linux-perf-users

kallsyms has a virtual file name [kernel.kallsyms].
Currently, it can't be added to buildid cache successfully
because the code(build_id_cache__add_s) tries to resolve
[kernel.kallsyms]to a real absolute pathname and that fails.

Fixes it by not resolving it and just use the name [kernel.kallsyms].
So dir ~/.debug/[kernel.kallsyms] is created.

Original bug report at:
https://lkml.org/lkml/2011/3/1/524

Tested-by: Han Pingtian <phan@redhat.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 tools/perf/util/header.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 72c124d..1f8883b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -271,11 +271,15 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
 			  const char *name, bool is_kallsyms)
 {
 	const size_t size = PATH_MAX;
-	char *realname = realpath(name, NULL),
-	     *filename = malloc(size),
+	char *realname, *filename = malloc(size),
 	     *linkname = malloc(size), *targetname;
 	int len, err = -1;
 
+	if (is_kallsyms)
+		realname = (char *)name;
+	else
+		realname = realpath(name, NULL);
+
 	if (realname == NULL || filename == NULL || linkname == NULL)
 		goto out_free;
 
@@ -307,7 +311,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
 	if (symlink(targetname, linkname) == 0)
 		err = 0;
 out_free:
-	free(realname);
+	if (!is_kallsyms)
+		free(realname);
 	free(filename);
 	free(linkname);
 	return err;
-- 
1.7.2.3


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

* Re: [PATCH] perf: Avoid resolving [kernel.kallsyms] to real path for buildid cache
  2011-03-03 15:23 [PATCH] perf: Avoid resolving [kernel.kallsyms] to real path for buildid cache Lin Ming
@ 2011-03-09 14:38 ` Lin Ming
  2011-03-09 15:57   ` Arnaldo Carvalho de Melo
  2011-03-10  6:36 ` [tip:perf/urgent] perf symbols: " tip-bot for Lin Ming
  1 sibling, 1 reply; 4+ messages in thread
From: Lin Ming @ 2011-03-09 14:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Lin Ming
  Cc: Han Pingtian, Peter Zijlstra, Ingo Molnar, linux-kernel,
	linux-perf-users

Hi, Arnaldo

Could you have a look at this patch?

Thanks,
Lin Ming

On Thu, Mar 3, 2011 at 11:23 PM, Lin Ming <ming.m.lin@intel.com> wrote:
> kallsyms has a virtual file name [kernel.kallsyms].
> Currently, it can't be added to buildid cache successfully
> because the code(build_id_cache__add_s) tries to resolve
> [kernel.kallsyms]to a real absolute pathname and that fails.
>
> Fixes it by not resolving it and just use the name [kernel.kallsyms].
> So dir ~/.debug/[kernel.kallsyms] is created.
>
> Original bug report at:
> https://lkml.org/lkml/2011/3/1/524
>
> Tested-by: Han Pingtian <phan@redhat.com>
> Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> ---
>  tools/perf/util/header.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 72c124d..1f8883b 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -271,11 +271,15 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
>                          const char *name, bool is_kallsyms)
>  {
>        const size_t size = PATH_MAX;
> -       char *realname = realpath(name, NULL),
> -            *filename = malloc(size),
> +       char *realname, *filename = malloc(size),
>             *linkname = malloc(size), *targetname;
>        int len, err = -1;
>
> +       if (is_kallsyms)
> +               realname = (char *)name;
> +       else
> +               realname = realpath(name, NULL);
> +
>        if (realname == NULL || filename == NULL || linkname == NULL)
>                goto out_free;
>
> @@ -307,7 +311,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
>        if (symlink(targetname, linkname) == 0)
>                err = 0;
>  out_free:
> -       free(realname);
> +       if (!is_kallsyms)
> +               free(realname);
>        free(filename);
>        free(linkname);
>        return err;
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] perf: Avoid resolving [kernel.kallsyms] to real path for buildid cache
  2011-03-09 14:38 ` Lin Ming
@ 2011-03-09 15:57   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-03-09 15:57 UTC (permalink / raw)
  To: Lin Ming
  Cc: Lin Ming, Han Pingtian, Peter Zijlstra, Franck Bui-Huu,
	Ingo Molnar, linux-kernel, linux-perf-users

Em Wed, Mar 09, 2011 at 10:38:52PM +0800, Lin Ming escreveu:
> Hi, Arnaldo
> 
> Could you have a look at this patch?
> 
> Thanks,
> Lin Ming

Seems ok, problem was introduced in:

commit 68a7a771ad0e2959983729bf88cbc74a7014438f
Author: Franck Bui-Huu <fbuihuu@gmail.com>
Date:   Fri Dec 10 22:06:26 2010 +0100

    perf buildid-cache: Fix symbolic link handling
    
    This was broken since link(2) doesn't dereference symbolic
    links. Instead 'filename' becomes a symbolic link to the same file
    that 'name' refers to.
    
    This had the bad effect to create dangling symlinks in the case that
    even can't be removed with perf-buildid-cache(1).
    
    LKML-Reference: <m38vzxxrql.fsf@gmail.com>
    Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

[acme@emilia linux]$ git describe 68a7a771
v2.6.37-rc5-71-g68a7a77

So I'll add a CC: stable@kernel.org when pushing to perf/urgent.

- Arnaldo

 
> On Thu, Mar 3, 2011 at 11:23 PM, Lin Ming <ming.m.lin@intel.com> wrote:
> > kallsyms has a virtual file name [kernel.kallsyms].
> > Currently, it can't be added to buildid cache successfully
> > because the code(build_id_cache__add_s) tries to resolve
> > [kernel.kallsyms]to a real absolute pathname and that fails.
> >
> > Fixes it by not resolving it and just use the name [kernel.kallsyms].
> > So dir ~/.debug/[kernel.kallsyms] is created.
> >
> > Original bug report at:
> > https://lkml.org/lkml/2011/3/1/524
> >
> > Tested-by: Han Pingtian <phan@redhat.com>
> > Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> > ---
> >  tools/perf/util/header.c |   11 ++++++++---
> >  1 files changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index 72c124d..1f8883b 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -271,11 +271,15 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
> >                          const char *name, bool is_kallsyms)
> >  {
> >        const size_t size = PATH_MAX;
> > -       char *realname = realpath(name, NULL),
> > -            *filename = malloc(size),
> > +       char *realname, *filename = malloc(size),
> >             *linkname = malloc(size), *targetname;
> >        int len, err = -1;
> >
> > +       if (is_kallsyms)
> > +               realname = (char *)name;
> > +       else
> > +               realname = realpath(name, NULL);
> > +
> >        if (realname == NULL || filename == NULL || linkname == NULL)
> >                goto out_free;
> >
> > @@ -307,7 +311,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
> >        if (symlink(targetname, linkname) == 0)
> >                err = 0;
> >  out_free:
> > -       free(realname);
> > +       if (!is_kallsyms)
> > +               free(realname);
> >        free(filename);
> >        free(linkname);
> >        return err;
> > --
> > 1.7.2.3
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >

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

* [tip:perf/urgent] perf symbols: Avoid resolving [kernel.kallsyms] to real path for buildid cache
  2011-03-03 15:23 [PATCH] perf: Avoid resolving [kernel.kallsyms] to real path for buildid cache Lin Ming
  2011-03-09 14:38 ` Lin Ming
@ 2011-03-10  6:36 ` tip-bot for Lin Ming
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Lin Ming @ 2011-03-10  6:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, a.p.zijlstra, phan, ming.m.lin,
	tglx, mingo

Commit-ID:  7ee235efe5f86f239ce73915fd2e15f4d14259c6
Gitweb:     http://git.kernel.org/tip/7ee235efe5f86f239ce73915fd2e15f4d14259c6
Author:     Lin Ming <ming.m.lin@intel.com>
AuthorDate: Thu, 3 Mar 2011 23:23:57 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 9 Mar 2011 13:44:10 -0300

perf symbols: Avoid resolving [kernel.kallsyms] to real path for buildid cache

kallsyms has a virtual file name [kernel.kallsyms].  Currently, it can't
be added to buildid cache successfully because the code
(build_id_cache__add_s) tries to resolve [kernel.kallsyms] to a real
absolute pathname and that fails.

Fixes it by not resolving it and just use the name [kernel.kallsyms].
So dir ~/.debug/[kernel.kallsyms] is created.

Original bug report at:
https://lkml.org/lkml/2011/3/1/524

Tested-by: Han Pingtian <phan@redhat.com>
Cc: Han Pingtian <phan@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1299165837-27817-1-git-send-email-ming.m.lin@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/header.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index f6a929e7..0866bcd 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -270,11 +270,15 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
 			  const char *name, bool is_kallsyms)
 {
 	const size_t size = PATH_MAX;
-	char *realname = realpath(name, NULL),
-	     *filename = malloc(size),
+	char *realname, *filename = malloc(size),
 	     *linkname = malloc(size), *targetname;
 	int len, err = -1;
 
+	if (is_kallsyms)
+		realname = (char *)name;
+	else
+		realname = realpath(name, NULL);
+
 	if (realname == NULL || filename == NULL || linkname == NULL)
 		goto out_free;
 
@@ -306,7 +310,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
 	if (symlink(targetname, linkname) == 0)
 		err = 0;
 out_free:
-	free(realname);
+	if (!is_kallsyms)
+		free(realname);
 	free(filename);
 	free(linkname);
 	return err;

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

end of thread, other threads:[~2011-03-10  6:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-03 15:23 [PATCH] perf: Avoid resolving [kernel.kallsyms] to real path for buildid cache Lin Ming
2011-03-09 14:38 ` Lin Ming
2011-03-09 15:57   ` Arnaldo Carvalho de Melo
2011-03-10  6:36 ` [tip:perf/urgent] perf symbols: " tip-bot for Lin Ming

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).