linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] perf/urgent fixes
@ 2014-06-04 13:26 Jiri Olsa
  2014-06-04 13:26 ` [PATCH 1/2] perf probe: Fix a segfault if asked for variable it doesn't find Jiri Olsa
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiri Olsa @ 2014-06-04 13:26 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Jiri Olsa,
	Masami Hiramatsu, Namhyung Kim, Paul Mackerras, Peter Zijlstra

hi Ingo,
please consider pulling

thanks,
jirka


The following changes since commit b69cf53640da2b86439596118cfa95233154ee76:

  perf: Fix a race between ring_buffer_detach() and ring_buffer_attach() (2014-05-19 21:44:56 +0900)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git tags/perf-urgent-for-mingo

for you to fetch changes up to 082f96a93eb5ba9bf771518a0dda590624568e8e:

  perf probe: Fix perf probe to find correct variable DIE (2014-06-04 14:49:20 +0200)

----------------------------------------------------------------
perf/urgent fixes:

. Fix perf probe to find correct variable DIE (Masami Hiramatsu)

. Fix a segfault in perf probe if asked for variable it doesn't find (Masami Hiramatsu)

Signed-off-by: Jiri Olsa <jolsa@kernel.org>

----------------------------------------------------------------
Masami Hiramatsu (2):
      perf probe: Fix a segfault if asked for variable it doesn't find
      perf probe: Fix perf probe to find correct variable DIE

 tools/perf/util/dwarf-aux.c    | 7 +++++--
 tools/perf/util/probe-finder.c | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)

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

* [PATCH 1/2] perf probe: Fix a segfault if asked for variable it doesn't find
  2014-06-04 13:26 [GIT PULL 0/2] perf/urgent fixes Jiri Olsa
@ 2014-06-04 13:26 ` Jiri Olsa
  2014-06-04 13:27 ` [PATCH 2/2] perf probe: Fix perf probe to find correct variable DIE Jiri Olsa
  2014-06-05  7:53 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2014-06-04 13:26 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Masami Hiramatsu, Peter Zijlstra, Paul Mackerras,
	Ingo Molnar, Namhyung Kim, Jiri Olsa

From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Fix a segfault bug by asking for variable it doesn't find.
Since the convert_variable() didn't handle error code returned
from convert_variable_location(), it just passed an incomplete
variable field and then a segfault was occurred when formatting
the field.

This fixes that bug by handling success code correctly in
convert_variable(). Other callers of convert_variable_location()
are correctly checking the return code.

This bug was introduced by following commit. But another hidden
erroneous error handling has been there previously (-ENOMEM case).

 commit 3d918a12a1b3088ac16ff37fa52760639d6e2403

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20140529105232.28251.30447.stgit@ltc230.yrl.intra.hitachi.co.jp
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/probe-finder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 5627621..9d8eb26 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -511,12 +511,12 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
 
 	ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops,
 					&pf->sp_die, pf->tvar);
-	if (ret == -ENOENT)
+	if (ret == -ENOENT || ret == -EINVAL)
 		pr_err("Failed to find the location of %s at this address.\n"
 		       " Perhaps, it has been optimized out.\n", pf->pvar->var);
 	else if (ret == -ENOTSUP)
 		pr_err("Sorry, we don't support this variable location yet.\n");
-	else if (pf->pvar->field) {
+	else if (ret == 0 && pf->pvar->field) {
 		ret = convert_variable_fields(vr_die, pf->pvar->var,
 					      pf->pvar->field, &pf->tvar->ref,
 					      &die_mem);
-- 
1.8.3.1


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

* [PATCH 2/2] perf probe: Fix perf probe to find correct variable DIE
  2014-06-04 13:26 [GIT PULL 0/2] perf/urgent fixes Jiri Olsa
  2014-06-04 13:26 ` [PATCH 1/2] perf probe: Fix a segfault if asked for variable it doesn't find Jiri Olsa
@ 2014-06-04 13:27 ` Jiri Olsa
  2014-06-05  7:53 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2014-06-04 13:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Masami Hiramatsu, Arnaldo Carvalho de Melo,
	Peter Zijlstra, Paul Mackerras, Ingo Molnar, Namhyung Kim,
	Jiri Olsa

From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Fix perf probe to find correct variable DIE which has location or
external instance by tracking down the lexical blocks.

Current die_find_variable() expects that the all variable DIEs
which has DW_TAG_variable have a location. However, since recent
dwarf information may have declaration variable DIEs at the
entry of function (subprogram), die_find_variable() returns it.

To solve this problem, it must track down the DIE tree to find
a DIE which has an actual location or a reference for external
instance.

e.g. finding a DIE which origin is <0xdc73>;

 <1><11496>: Abbrev Number: 95 (DW_TAG_subprogram)
    <11497>   DW_AT_abstract_origin: <0xdc42>
    <1149b>   DW_AT_low_pc      : 0x1850
[...]
 <2><114cc>: Abbrev Number: 119 (DW_TAG_variable) <- this is a declaration
    <114cd>   DW_AT_abstract_origin: <0xdc73>
 <2><114d1>: Abbrev Number: 119 (DW_TAG_variable)
[...]
 <3><115a7>: Abbrev Number: 105 (DW_TAG_lexical_block)
    <115a8>   DW_AT_ranges      : 0xaa0
 <4><115ac>: Abbrev Number: 96 (DW_TAG_variable) <- this has a location
    <115ad>   DW_AT_abstract_origin: <0xdc73>
    <115b1>   DW_AT_location    : 0x486c        (location list)

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Acked-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20140529121930.30879.87092.stgit@ltc230.yrl.intra.hitachi.co.jp
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/dwarf-aux.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 7defd77..cc66c40 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -747,14 +747,17 @@ struct __find_variable_param {
 static int __die_find_variable_cb(Dwarf_Die *die_mem, void *data)
 {
 	struct __find_variable_param *fvp = data;
+	Dwarf_Attribute attr;
 	int tag;
 
 	tag = dwarf_tag(die_mem);
 	if ((tag == DW_TAG_formal_parameter ||
 	     tag == DW_TAG_variable) &&
-	    die_compare_name(die_mem, fvp->name))
+	    die_compare_name(die_mem, fvp->name) &&
+	/* Does the DIE have location information or external instance? */
+	    (dwarf_attr(die_mem, DW_AT_external, &attr) ||
+	     dwarf_attr(die_mem, DW_AT_location, &attr)))
 		return DIE_FIND_CB_END;
-
 	if (dwarf_haspc(die_mem, fvp->addr))
 		return DIE_FIND_CB_CONTINUE;
 	else
-- 
1.8.3.1


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

* Re: [GIT PULL 0/2] perf/urgent fixes
  2014-06-04 13:26 [GIT PULL 0/2] perf/urgent fixes Jiri Olsa
  2014-06-04 13:26 ` [PATCH 1/2] perf probe: Fix a segfault if asked for variable it doesn't find Jiri Olsa
  2014-06-04 13:27 ` [PATCH 2/2] perf probe: Fix perf probe to find correct variable DIE Jiri Olsa
@ 2014-06-05  7:53 ` Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2014-06-05  7:53 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Masami Hiramatsu,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra


* Jiri Olsa <jolsa@kernel.org> wrote:

> hi Ingo,
> please consider pulling
> 
> thanks,
> jirka
> 
> 
> The following changes since commit b69cf53640da2b86439596118cfa95233154ee76:
> 
>   perf: Fix a race between ring_buffer_detach() and ring_buffer_attach() (2014-05-19 21:44:56 +0900)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git tags/perf-urgent-for-mingo
> 
> for you to fetch changes up to 082f96a93eb5ba9bf771518a0dda590624568e8e:
> 
>   perf probe: Fix perf probe to find correct variable DIE (2014-06-04 14:49:20 +0200)
> 
> ----------------------------------------------------------------
> perf/urgent fixes:
> 
> . Fix perf probe to find correct variable DIE (Masami Hiramatsu)
> 
> . Fix a segfault in perf probe if asked for variable it doesn't find (Masami Hiramatsu)
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> 
> ----------------------------------------------------------------
> Masami Hiramatsu (2):
>       perf probe: Fix a segfault if asked for variable it doesn't find
>       perf probe: Fix perf probe to find correct variable DIE
> 
>  tools/perf/util/dwarf-aux.c    | 7 +++++--
>  tools/perf/util/probe-finder.c | 4 ++--
>  2 files changed, 7 insertions(+), 4 deletions(-)

Pulled, thanks a lot Jiri!

	Ingo

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

end of thread, other threads:[~2014-06-05  7:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04 13:26 [GIT PULL 0/2] perf/urgent fixes Jiri Olsa
2014-06-04 13:26 ` [PATCH 1/2] perf probe: Fix a segfault if asked for variable it doesn't find Jiri Olsa
2014-06-04 13:27 ` [PATCH 2/2] perf probe: Fix perf probe to find correct variable DIE Jiri Olsa
2014-06-05  7:53 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar

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