All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf probe: Fix failure to add multiple probes without debuginfo
@ 2015-03-19  9:23 He Kuang
  2015-03-19 10:02 ` He Kuang
  0 siblings, 1 reply; 9+ messages in thread
From: He Kuang @ 2015-03-19  9:23 UTC (permalink / raw)
  To: acme, masami.hiramatsu.pt, a.p.zijlstra, mingo, namhyung
  Cc: wangnan0, linux-kernel

From: hekuang <hekuang@zoho.com>

Perf tries to find probe function addresses from map when debuginfo
could not be found.

To the first added function, the value of ref_reloc_sym was set in
maps__set_kallsyms_ref_reloc_sym() and can be obtained from
host_machine->kmaps->maps. After that, new maps are added to
host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
do not have a valid ref_reloc_sym.

When adding a second function, get_target_map() may get a map without
valid ref_reloc_sym, and raise the error "Relocated base symbol is not
found".

Fix this by getting ref_reloc_sym from machine->vmlinux_maps.

This problem can be reproduced as following:

  $ perf probe --add='sys_write' --add='sys_open'
  Relocated base symbol is not found!
    Error: Failed to add events.

After this patch:

  $ perf probe --add='sys_write' --add='sys_open'
  Added new event:
    probe:sys_write      (on sys_write)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_write -aR sleep 1

  Added new event:
    probe:sys_open       (on sys_open)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_open -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/probe-event.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index c5e1338..75d41ee 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2540,7 +2540,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	}
 
 	if (!pev->uprobes && !pp->retprobe) {
-		kmap = map__kmap(map);
+		struct machine *machine;
+		struct map *vmlinux_map = NULL;
+
+		if (map->groups && map->groups->machine) {
+			machine = map->groups->machine;
+			vmlinux_map = machine->vmlinux_maps[MAP__FUNCTION];
+		}
+
+		if (vmlinux_map)
+			kmap = map__kmap(vmlinux_map);
+		else
+			kmap = map__kmap(map);
+
 		reloc_sym = kmap->ref_reloc_sym;
 		if (!reloc_sym) {
 			pr_warning("Relocated base symbol is not found!\n");
-- 
2.3.3.220.g9ab698f


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

* [PATCH] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-19  9:23 [PATCH] perf probe: Fix failure to add multiple probes without debuginfo He Kuang
@ 2015-03-19 10:02 ` He Kuang
  2015-03-19 13:59   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 9+ messages in thread
From: He Kuang @ 2015-03-19 10:02 UTC (permalink / raw)
  To: acme, masami.hiramatsu.pt, a.p.zijlstra, mingo, namhyung
  Cc: wangnan0, linux-kernel

Perf tries to find probe function addresses from map when debuginfo
could not be found.

To the first added function, the value of ref_reloc_sym was set in
maps__set_kallsyms_ref_reloc_sym() and can be obtained from
host_machine->kmaps->maps. After that, new maps are added to
host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
do not have a valid ref_reloc_sym.

When adding a second function, get_target_map() may get a map without
valid ref_reloc_sym, and raise the error "Relocated base symbol is not
found".

Fix this by getting ref_reloc_sym from machine->vmlinux_maps.

This problem can be reproduced as following:

  $ perf probe --add='sys_write' --add='sys_open'
  Relocated base symbol is not found!
    Error: Failed to add events.

After this patch:

  $ perf probe --add='sys_write' --add='sys_open'
  Added new event:
    probe:sys_write      (on sys_write)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_write -aR sleep 1

  Added new event:
    probe:sys_open       (on sys_open)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_open -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/probe-event.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index c5e1338..75d41ee 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2540,7 +2540,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	}
 
 	if (!pev->uprobes && !pp->retprobe) {
-		kmap = map__kmap(map);
+		struct machine *machine;
+		struct map *vmlinux_map = NULL;
+
+		if (map->groups && map->groups->machine) {
+			machine = map->groups->machine;
+			vmlinux_map = machine->vmlinux_maps[MAP__FUNCTION];
+		}
+
+		if (vmlinux_map)
+			kmap = map__kmap(vmlinux_map);
+		else
+			kmap = map__kmap(map);
+
 		reloc_sym = kmap->ref_reloc_sym;
 		if (!reloc_sym) {
 			pr_warning("Relocated base symbol is not found!\n");
-- 
2.3.3.220.g9ab698f


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

* Re: [PATCH] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-19 10:02 ` He Kuang
@ 2015-03-19 13:59   ` Arnaldo Carvalho de Melo
  2015-03-20  1:56     ` [PATCHv2] " He Kuang
  0 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-19 13:59 UTC (permalink / raw)
  To: He Kuang
  Cc: masami.hiramatsu.pt, a.p.zijlstra, mingo, namhyung, wangnan0,
	linux-kernel

Em Thu, Mar 19, 2015 at 06:02:04PM +0800, He Kuang escreveu:
> Perf tries to find probe function addresses from map when debuginfo
> could not be found.
> 
> To the first added function, the value of ref_reloc_sym was set in
> maps__set_kallsyms_ref_reloc_sym() and can be obtained from
> host_machine->kmaps->maps. After that, new maps are added to
> host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
> do not have a valid ref_reloc_sym.
> 
> When adding a second function, get_target_map() may get a map without
> valid ref_reloc_sym, and raise the error "Relocated base symbol is not
> found".
> 
> Fix this by getting ref_reloc_sym from machine->vmlinux_maps.

Can't this be solved by using the kernel_get_ref_reloc_sym(void) static
function in this same file?

- Arnaldo
 
> This problem can be reproduced as following:
> 
>   $ perf probe --add='sys_write' --add='sys_open'
>   Relocated base symbol is not found!
>     Error: Failed to add events.
> 
> After this patch:
> 
>   $ perf probe --add='sys_write' --add='sys_open'
>   Added new event:
>     probe:sys_write      (on sys_write)
> 
>   You can now use it in all perf tools, such as:
> 
>       perf record -e probe:sys_write -aR sleep 1
> 
>   Added new event:
>     probe:sys_open       (on sys_open)
> 
>   You can now use it in all perf tools, such as:
> 
>       perf record -e probe:sys_open -aR sleep 1
> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/util/probe-event.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index c5e1338..75d41ee 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2540,7 +2540,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>  	}
>  
>  	if (!pev->uprobes && !pp->retprobe) {
> -		kmap = map__kmap(map);
> +		struct machine *machine;
> +		struct map *vmlinux_map = NULL;
> +
> +		if (map->groups && map->groups->machine) {
> +			machine = map->groups->machine;
> +			vmlinux_map = machine->vmlinux_maps[MAP__FUNCTION];
> +		}
> +
> +		if (vmlinux_map)
> +			kmap = map__kmap(vmlinux_map);
> +		else
> +			kmap = map__kmap(map);
> +
>  		reloc_sym = kmap->ref_reloc_sym;
>  		if (!reloc_sym) {
>  			pr_warning("Relocated base symbol is not found!\n");
> -- 
> 2.3.3.220.g9ab698f

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

* [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-19 13:59   ` Arnaldo Carvalho de Melo
@ 2015-03-20  1:56     ` He Kuang
  2015-03-20  7:42       ` Masami Hiramatsu
  2015-03-22 10:14       ` [tip:perf/core] " tip-bot for He Kuang
  0 siblings, 2 replies; 9+ messages in thread
From: He Kuang @ 2015-03-20  1:56 UTC (permalink / raw)
  To: acme, masami.hiramatsu.pt, a.p.zijlstra, mingo, namhyung
  Cc: wangnan0, linux-kernel

Perf tries to find probe function addresses from map when debuginfo
could not be found.

To the first added function, the value of ref_reloc_sym was set in
maps__set_kallsyms_ref_reloc_sym() and can be obtained from
host_machine->kmaps->maps. After that, new maps are added to
host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
do not have a valid ref_reloc_sym.

When adding a second function, get_target_map() may get a map without
valid ref_reloc_sym, and raise the error "Relocated base symbol is not
found".

Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.

This problem can be reproduced as following:

  $ perf probe --add='sys_write' --add='sys_open'
  Relocated base symbol is not found!
    Error: Failed to add events.

After this patch:

  $ perf probe --add='sys_write' --add='sys_open'
  Added new event:
    probe:sys_write      (on sys_write)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_write -aR sleep 1

  Added new event:
    probe:sys_open       (on sys_open)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_open -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/probe-event.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index c5e1338..c1ccd6a 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 					    int max_tevs, const char *target)
 {
 	struct map *map = NULL;
-	struct kmap *kmap = NULL;
 	struct ref_reloc_sym *reloc_sym = NULL;
 	struct symbol *sym;
 	struct probe_trace_event *tev;
@@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	}
 
 	if (!pev->uprobes && !pp->retprobe) {
-		kmap = map__kmap(map);
-		reloc_sym = kmap->ref_reloc_sym;
+		reloc_sym = kernel_get_ref_reloc_sym();
 		if (!reloc_sym) {
 			pr_warning("Relocated base symbol is not found!\n");
 			ret = -EINVAL;
-- 
2.3.3.220.g9ab698f


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

* Re: [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-20  1:56     ` [PATCHv2] " He Kuang
@ 2015-03-20  7:42       ` Masami Hiramatsu
  2015-03-20 13:50         ` Arnaldo Carvalho de Melo
  2015-03-22 10:14       ` [tip:perf/core] " tip-bot for He Kuang
  1 sibling, 1 reply; 9+ messages in thread
From: Masami Hiramatsu @ 2015-03-20  7:42 UTC (permalink / raw)
  To: He Kuang; +Cc: acme, a.p.zijlstra, mingo, namhyung, wangnan0, linux-kernel

(2015/03/20 10:56), He Kuang wrote:
> Perf tries to find probe function addresses from map when debuginfo
> could not be found.
> 
> To the first added function, the value of ref_reloc_sym was set in
> maps__set_kallsyms_ref_reloc_sym() and can be obtained from
> host_machine->kmaps->maps. After that, new maps are added to
> host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
> do not have a valid ref_reloc_sym.
> 
> When adding a second function, get_target_map() may get a map without
> valid ref_reloc_sym, and raise the error "Relocated base symbol is not
> found".
> 
> Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.
> 
> This problem can be reproduced as following:
> 
>   $ perf probe --add='sys_write' --add='sys_open'
>   Relocated base symbol is not found!
>     Error: Failed to add events.
> 
> After this patch:
> 
>   $ perf probe --add='sys_write' --add='sys_open'
>   Added new event:
>     probe:sys_write      (on sys_write)
> 
>   You can now use it in all perf tools, such as:
> 
>       perf record -e probe:sys_write -aR sleep 1
> 
>   Added new event:
>     probe:sys_open       (on sys_open)
> 
>   You can now use it in all perf tools, such as:
> 
>       perf record -e probe:sys_open -aR sleep 1
> 

OK, I've checked that this solve the problem :)

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>


Thank you!

> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/util/probe-event.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index c5e1338..c1ccd6a 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>  					    int max_tevs, const char *target)
>  {
>  	struct map *map = NULL;
> -	struct kmap *kmap = NULL;
>  	struct ref_reloc_sym *reloc_sym = NULL;
>  	struct symbol *sym;
>  	struct probe_trace_event *tev;
> @@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>  	}
>  
>  	if (!pev->uprobes && !pp->retprobe) {
> -		kmap = map__kmap(map);
> -		reloc_sym = kmap->ref_reloc_sym;
> +		reloc_sym = kernel_get_ref_reloc_sym();
>  		if (!reloc_sym) {
>  			pr_warning("Relocated base symbol is not found!\n");
>  			ret = -EINVAL;
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-20  7:42       ` Masami Hiramatsu
@ 2015-03-20 13:50         ` Arnaldo Carvalho de Melo
  2015-03-21 12:19           ` Masami Hiramatsu
  0 siblings, 1 reply; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-20 13:50 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: He Kuang, a.p.zijlstra, mingo, namhyung, wangnan0, linux-kernel

Em Fri, Mar 20, 2015 at 04:42:46PM +0900, Masami Hiramatsu escreveu:
> (2015/03/20 10:56), He Kuang wrote:
> > Perf tries to find probe function addresses from map when debuginfo
> > could not be found.
> > 
> > To the first added function, the value of ref_reloc_sym was set in
> > maps__set_kallsyms_ref_reloc_sym() and can be obtained from
> > host_machine->kmaps->maps. After that, new maps are added to
> > host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
> > do not have a valid ref_reloc_sym.
> > 
> > When adding a second function, get_target_map() may get a map without
> > valid ref_reloc_sym, and raise the error "Relocated base symbol is not
> > found".
> > 
> > Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.
> > 
> > This problem can be reproduced as following:
> > 
> >   $ perf probe --add='sys_write' --add='sys_open'
> >   Relocated base symbol is not found!
> >     Error: Failed to add events.
> > 
> > After this patch:
> > 
> >   $ perf probe --add='sys_write' --add='sys_open'
> >   Added new event:
> >     probe:sys_write      (on sys_write)
> > 
> >   You can now use it in all perf tools, such as:
> > 
> >       perf record -e probe:sys_write -aR sleep 1
> > 
> >   Added new event:
> >     probe:sys_open       (on sys_open)
> > 
> >   You can now use it in all perf tools, such as:
> > 
> >       perf record -e probe:sys_open -aR sleep 1
> > 
> 
> OK, I've checked that this solve the problem :)
> 
> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Ok, next time, please consider sending a Tested-by: tag instead, if what
you did was to apply the patch, check that it fixes the problem, that
provides a stronger patch endorsement.

- Arnaldo
 
> 
> Thank you!
> 
> > Signed-off-by: He Kuang <hekuang@huawei.com>
> > ---
> >  tools/perf/util/probe-event.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index c5e1338..c1ccd6a 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
> >  					    int max_tevs, const char *target)
> >  {
> >  	struct map *map = NULL;
> > -	struct kmap *kmap = NULL;
> >  	struct ref_reloc_sym *reloc_sym = NULL;
> >  	struct symbol *sym;
> >  	struct probe_trace_event *tev;
> > @@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
> >  	}
> >  
> >  	if (!pev->uprobes && !pp->retprobe) {
> > -		kmap = map__kmap(map);
> > -		reloc_sym = kmap->ref_reloc_sym;
> > +		reloc_sym = kernel_get_ref_reloc_sym();
> >  		if (!reloc_sym) {
> >  			pr_warning("Relocated base symbol is not found!\n");
> >  			ret = -EINVAL;
> > 
> 
> 
> -- 
> Masami HIRAMATSU
> Software Platform Research Dept. Linux Technology Research Center
> Hitachi, Ltd., Yokohama Research Laboratory
> E-mail: masami.hiramatsu.pt@hitachi.com
> 

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

* Re: [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-20 13:50         ` Arnaldo Carvalho de Melo
@ 2015-03-21 12:19           ` Masami Hiramatsu
  2015-03-21 17:54             ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 9+ messages in thread
From: Masami Hiramatsu @ 2015-03-21 12:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: He Kuang, a.p.zijlstra, mingo, namhyung, wangnan0, linux-kernel

(2015/03/20 22:50), Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 20, 2015 at 04:42:46PM +0900, Masami Hiramatsu escreveu:
>> (2015/03/20 10:56), He Kuang wrote:
>>> Perf tries to find probe function addresses from map when debuginfo
>>> could not be found.
>>>
>>> To the first added function, the value of ref_reloc_sym was set in
>>> maps__set_kallsyms_ref_reloc_sym() and can be obtained from
>>> host_machine->kmaps->maps. After that, new maps are added to
>>> host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
>>> do not have a valid ref_reloc_sym.
>>>
>>> When adding a second function, get_target_map() may get a map without
>>> valid ref_reloc_sym, and raise the error "Relocated base symbol is not
>>> found".
>>>
>>> Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.
>>>
>>> This problem can be reproduced as following:
>>>
>>>   $ perf probe --add='sys_write' --add='sys_open'
>>>   Relocated base symbol is not found!
>>>     Error: Failed to add events.
>>>
>>> After this patch:
>>>
>>>   $ perf probe --add='sys_write' --add='sys_open'
>>>   Added new event:
>>>     probe:sys_write      (on sys_write)
>>>
>>>   You can now use it in all perf tools, such as:
>>>
>>>       perf record -e probe:sys_write -aR sleep 1
>>>
>>>   Added new event:
>>>     probe:sys_open       (on sys_open)
>>>
>>>   You can now use it in all perf tools, such as:
>>>
>>>       perf record -e probe:sys_open -aR sleep 1
>>>
>>
>> OK, I've checked that this solve the problem :)
>>
>> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> 
> Ok, next time, please consider sending a Tested-by: tag instead, if what
> you did was to apply the patch, check that it fixes the problem, that
> provides a stronger patch endorsement.

I see. :)

Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

BTW, I've found another bug in perf probe for these sys_XXX functions.

----
# ./perf probe -vfn --add="sys_write" --add="sys_open"
probe-definition(0): sys_write
symbol:sys_write file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
probe-definition(1): sys_open
symbol:sys_open file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
symsrc__init: cannot get elf header.
Looking at the vmlinux_path (7 entries long)
Using /usr/lib/debug/lib/modules/3.10.0-123.13.2.el7.x86_64/vmlinux for symbols
Open Debuginfo file: /usr/lib/debug/lib/modules/3.10.0-123.13.2.el7.x86_64/vmlinux
Try to find probe point from debuginfo.
Symbol sys_write address found : 3b0100
Failed to find debug information for address 3b0100
Probe point 'sys_write' not found.
  Error: Failed to add events. Reason: No such file or directory (Code: -2)
----

Something went wrong... :-( I'll check that.


Thank you,
> 
> - Arnaldo
>  
>>
>> Thank you!
>>
>>> Signed-off-by: He Kuang <hekuang@huawei.com>
>>> ---
>>>  tools/perf/util/probe-event.c | 4 +---
>>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
>>> index c5e1338..c1ccd6a 100644
>>> --- a/tools/perf/util/probe-event.c
>>> +++ b/tools/perf/util/probe-event.c
>>> @@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>>>  					    int max_tevs, const char *target)
>>>  {
>>>  	struct map *map = NULL;
>>> -	struct kmap *kmap = NULL;
>>>  	struct ref_reloc_sym *reloc_sym = NULL;
>>>  	struct symbol *sym;
>>>  	struct probe_trace_event *tev;
>>> @@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>>>  	}
>>>  
>>>  	if (!pev->uprobes && !pp->retprobe) {
>>> -		kmap = map__kmap(map);
>>> -		reloc_sym = kmap->ref_reloc_sym;
>>> +		reloc_sym = kernel_get_ref_reloc_sym();
>>>  		if (!reloc_sym) {
>>>  			pr_warning("Relocated base symbol is not found!\n");
>>>  			ret = -EINVAL;
>>>
>>
>>
>> -- 
>> Masami HIRAMATSU
>> Software Platform Research Dept. Linux Technology Research Center
>> Hitachi, Ltd., Yokohama Research Laboratory
>> E-mail: masami.hiramatsu.pt@hitachi.com
>>
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* Re: [PATCHv2] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-21 12:19           ` Masami Hiramatsu
@ 2015-03-21 17:54             ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-21 17:54 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: He Kuang, a.p.zijlstra, mingo, namhyung, wangnan0, linux-kernel

Em Sat, Mar 21, 2015 at 09:19:21PM +0900, Masami Hiramatsu escreveu:
> (2015/03/20 22:50), Arnaldo Carvalho de Melo wrote:
> > Em Fri, Mar 20, 2015 at 04:42:46PM +0900, Masami Hiramatsu escreveu:
> >> OK, I've checked that this solve the problem :)

> >> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

> > Ok, next time, please consider sending a Tested-by: tag instead, if what
> > you did was to apply the patch, check that it fixes the problem, that
> > provides a stronger patch endorsement.

> I see. :)
> 
> Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thanks!
 
> BTW, I've found another bug in perf probe for these sys_XXX functions.

Ooops, 

<SNIP>
 
> Something went wrong... :-( I'll check that.

Thanks again!

- Arnaldo

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

* [tip:perf/core] perf probe: Fix failure to add multiple probes without debuginfo
  2015-03-20  1:56     ` [PATCHv2] " He Kuang
  2015-03-20  7:42       ` Masami Hiramatsu
@ 2015-03-22 10:14       ` tip-bot for He Kuang
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for He Kuang @ 2015-03-22 10:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, masami.hiramatsu.pt, mingo, wangnan0, tglx,
	a.p.zijlstra, hekuang, namhyung, hpa, acme

Commit-ID:  0560a0c4a12a45def9700e7ec3215da102cf914b
Gitweb:     http://git.kernel.org/tip/0560a0c4a12a45def9700e7ec3215da102cf914b
Author:     He Kuang <hekuang@huawei.com>
AuthorDate: Fri, 20 Mar 2015 09:56:56 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 21 Mar 2015 14:53:21 -0300

perf probe: Fix failure to add multiple probes without debuginfo

Perf tries to find probe function addresses from map when debuginfo
could not be found.

To the first added function, the value of ref_reloc_sym was set in
maps__set_kallsyms_ref_reloc_sym() and can be obtained from
host_machine->kmaps->maps. After that, new maps are added to
host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
do not have a valid ref_reloc_sym.

When adding a second function, get_target_map() may get a map without
valid ref_reloc_sym, and raise the error "Relocated base symbol is not
found".

Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.

This problem can be reproduced as following:

  $ perf probe --add='sys_write' --add='sys_open'
  Relocated base symbol is not found!
    Error: Failed to add events.

After this patch:

  $ perf probe --add='sys_write' --add='sys_open'
  Added new event:
    probe:sys_write      (on sys_write)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_write -aR sleep 1

  Added new event:
    probe:sys_open       (on sys_open)

  You can now use it in all perf tools, such as:

      perf record -e probe:sys_open -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426816616-2394-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f272a71..6b95985 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 					    int max_tevs, const char *target)
 {
 	struct map *map = NULL;
-	struct kmap *kmap = NULL;
 	struct ref_reloc_sym *reloc_sym = NULL;
 	struct symbol *sym;
 	struct probe_trace_event *tev;
@@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	}
 
 	if (!pev->uprobes && !pp->retprobe) {
-		kmap = map__kmap(map);
-		reloc_sym = kmap->ref_reloc_sym;
+		reloc_sym = kernel_get_ref_reloc_sym();
 		if (!reloc_sym) {
 			pr_warning("Relocated base symbol is not found!\n");
 			ret = -EINVAL;

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

end of thread, other threads:[~2015-03-22 10:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-19  9:23 [PATCH] perf probe: Fix failure to add multiple probes without debuginfo He Kuang
2015-03-19 10:02 ` He Kuang
2015-03-19 13:59   ` Arnaldo Carvalho de Melo
2015-03-20  1:56     ` [PATCHv2] " He Kuang
2015-03-20  7:42       ` Masami Hiramatsu
2015-03-20 13:50         ` Arnaldo Carvalho de Melo
2015-03-21 12:19           ` Masami Hiramatsu
2015-03-21 17:54             ` Arnaldo Carvalho de Melo
2015-03-22 10:14       ` [tip:perf/core] " tip-bot for He Kuang

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.