Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386221 > unrolled thread

[RFC] perf probe: Fix module probe issue if no dwarf support

Started byRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
First post2016-04-25 12:40 +0200
Last post2016-04-26 11:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC] perf probe: Fix module probe issue if no dwarf support Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-04-25 12:40 +0200
    Re: [RFC] perf probe: Fix module probe issue if no dwarf support Masami Hiramatsu <mhiramat@kernel.org> - 2016-04-25 23:30 +0200
      Re: [RFC] perf probe: Fix module probe issue if no dwarf support Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-04-26 11:10 +0200

#1386221 — [RFC] perf probe: Fix module probe issue if no dwarf support

FromRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Date2016-04-25 12:40 +0200
Subject[RFC] perf probe: Fix module probe issue if no dwarf support
Message-ID<rrM5Q-4ay-3@gated-at.bofh.it>
Perf is not able to register probe in kernel module when dwarf supprt
is not there(and so it goes for symtab). Perf passes full path of
module where only module name is required which is causing the problem.
This patch fixes this issue.

Before applying patch:

  $ dpkg -s libdw-dev
    dpkg-query: package 'libdw-dev' is not installed ...

  $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
    Added new event:
      probe:foo_show (on foo_show in /linux/samples/kobject/kobject-example.ko)

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

  perf record -e probe:foo_show -aR sleep 1

  $ cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/foo_show /linux/samples/kobject/kobject-example.ko:foo_show

After applying patch:

  $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
    Added new event:
      probe:foo_show (on foo_show in kobject_example)

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

  perf record -e probe:foo_show -aR sleep 1

  $ cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/foo_show kobject_example:foo_show

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
 tools/perf/util/probe-event.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 05d0905..54e6a5a 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2566,6 +2566,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	struct probe_trace_point *tp;
 	int num_matched_functions;
 	int ret, i, j, skipped = 0;
+	char *mod_name;
 
 	map = get_target_map(pev->target, pev->uprobes);
 	if (!map) {
@@ -2650,9 +2651,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 		tp->realname = strdup_or_goto(sym->name, nomem_out);
 
 		tp->retprobe = pp->retprobe;
-		if (pev->target)
-			tev->point.module = strdup_or_goto(pev->target,
-							   nomem_out);
+		if (pev->target) {
+			if (pev->uprobes) {
+				tev->point.module = strdup_or_goto(pev->target,
+								   nomem_out);
+			} else {
+				mod_name = find_module_name(pev->target);
+				tev->point.module =
+					strdup(mod_name ? mod_name : pev->target);
+				free(mod_name);
+				if (!tev->point.module)
+					goto nomem_out;
+			}
+		}
 		tev->uprobes = pev->uprobes;
 		tev->nargs = pev->nargs;
 		if (tev->nargs) {
-- 
2.1.4

[toc] | [next] | [standalone]


#1386908

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-04-25 23:30 +0200
Message-ID<rrWeR-49v-9@gated-at.bofh.it>
In reply to#1386221
On Mon, 25 Apr 2016 16:08:28 +0530
Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> wrote:

> Perf is not able to register probe in kernel module when dwarf supprt
> is not there(and so it goes for symtab). Perf passes full path of
> module where only module name is required which is causing the problem.
> This patch fixes this issue.
> 
> Before applying patch:
> 
>   $ dpkg -s libdw-dev
>     dpkg-query: package 'libdw-dev' is not installed ...
> 
>   $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
>     Added new event:
>       probe:foo_show (on foo_show in /linux/samples/kobject/kobject-example.ko)
> 
>     You can now use it in all perf tools, such as:
> 
>   perf record -e probe:foo_show -aR sleep 1
> 
>   $ cat /sys/kernel/debug/tracing/kprobe_events
>     p:probe/foo_show /linux/samples/kobject/kobject-example.ko:foo_show
> 
> After applying patch:
> 
>   $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
>     Added new event:
>       probe:foo_show (on foo_show in kobject_example)
> 
>     You can now use it in all perf tools, such as:
> 
>   perf record -e probe:foo_show -aR sleep 1
> 
>   $ cat /sys/kernel/debug/tracing/kprobe_events
>     p:probe/foo_show kobject_example:foo_show
> 

Looks good to me :)
However, it seems that this patch depends on your previous patch
("perf probe: Fix offline module name missmatch issue")
In that case, could you make these a series of patches?

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks,

> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
>  tools/perf/util/probe-event.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 05d0905..54e6a5a 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2566,6 +2566,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>  	struct probe_trace_point *tp;
>  	int num_matched_functions;
>  	int ret, i, j, skipped = 0;
> +	char *mod_name;
>  
>  	map = get_target_map(pev->target, pev->uprobes);
>  	if (!map) {
> @@ -2650,9 +2651,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
>  		tp->realname = strdup_or_goto(sym->name, nomem_out);
>  
>  		tp->retprobe = pp->retprobe;
> -		if (pev->target)
> -			tev->point.module = strdup_or_goto(pev->target,
> -							   nomem_out);
> +		if (pev->target) {
> +			if (pev->uprobes) {
> +				tev->point.module = strdup_or_goto(pev->target,
> +								   nomem_out);
> +			} else {
> +				mod_name = find_module_name(pev->target);
> +				tev->point.module =
> +					strdup(mod_name ? mod_name : pev->target);
> +				free(mod_name);
> +				if (!tev->point.module)
> +					goto nomem_out;
> +			}
> +		}
>  		tev->uprobes = pev->uprobes;
>  		tev->nargs = pev->nargs;
>  		if (tev->nargs) {
> -- 
> 2.1.4
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

[toc] | [prev] | [next] | [standalone]


#1387245

FromRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Date2016-04-26 11:10 +0200
Message-ID<rs7aj-4SP-17@gated-at.bofh.it>
In reply to#1386908

On Tuesday 26 April 2016 02:59 AM, Masami Hiramatsu wrote:
> On Mon, 25 Apr 2016 16:08:28 +0530
> Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> wrote:
>
>> Perf is not able to register probe in kernel module when dwarf supprt
>> is not there(and so it goes for symtab). Perf passes full path of
>> module where only module name is required which is causing the problem.
>> This patch fixes this issue.
>>
>> Before applying patch:
>>
>>    $ dpkg -s libdw-dev
>>      dpkg-query: package 'libdw-dev' is not installed ...
>>
>>    $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
>>      Added new event:
>>        probe:foo_show (on foo_show in /linux/samples/kobject/kobject-example.ko)
>>
>>      You can now use it in all perf tools, such as:
>>
>>    perf record -e probe:foo_show -aR sleep 1
>>
>>    $ cat /sys/kernel/debug/tracing/kprobe_events
>>      p:probe/foo_show /linux/samples/kobject/kobject-example.ko:foo_show
>>
>> After applying patch:
>>
>>    $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
>>      Added new event:
>>        probe:foo_show (on foo_show in kobject_example)
>>
>>      You can now use it in all perf tools, such as:
>>
>>    perf record -e probe:foo_show -aR sleep 1
>>
>>    $ cat /sys/kernel/debug/tracing/kprobe_events
>>      p:probe/foo_show kobject_example:foo_show
>>
> Looks good to me :)
> However, it seems that this patch depends on your previous patch
> ("perf probe: Fix offline module name missmatch issue")
> In that case, could you make these a series of patches?
>
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thanks Masami,

I've sent v2 with changes you suggested. Please review it.

Regards,
Ravi

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web