public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Wang Nan <wangnan0@huawei.com>
Cc: linux-kernel@vger.kernel.org, lizefan@huawei.com,
	pi3orama@163.com, Namhyung Kim <namhyung@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: Re: [PATCH] perf probe: Fix module probing with shortname
Date: Tue, 22 Sep 2015 10:35:04 -0300	[thread overview]
Message-ID: <20150922133504.GA2580@redhat.com> (raw)
In-Reply-To: <1442892872-33708-1-git-send-email-wangnan0@huawei.com>

Em Tue, Sep 22, 2015 at 03:34:32AM +0000, Wang Nan escreveu:
> After commit 3d39ac538629e4f00a6e1c38d46346f1b8e69505 ("perf machine:
> No need to have two DSOs lists"), perf probe with module short name doesn't
> work again. For example:
> 
>  # lsmod | grep e1000e
>  e1000e                233472  0
> 
>  # cat /proc/modules | grep e1000e
>  e1000e 233472 0 - Live 0xffffffffa0073000
> 
>  # cat /proc/kallsyms | grep '\<e1000e_up\>'
>  ffffffffa0093860 t e1000e_up[e1000e]
> 
>  # perf probe -v -m e1000e --add e1000e_up
>  probe-definition(0): e1000e_up
>  symbol:e1000e_up file:(null) line:0 offset:0 return:0 lazy:(null)
>  0 arguments
>  Failed to find module e1000e.
>  Could not open debuginfo. Try to use symbols.
>  Looking at the vmlinux_path (7 entries long)
>  Using /lib/modules/4.2.0-rc7+/build/vmlinux for symbols
>  e1000e_up is out of .text, skip it.
>    Error: Failed to add events. Reason: No such file or directory (Code: -2)
> 
> This is caused by a misunderstood of dso->kernel in kernel_get_module_dso()
> that, for kernel module, dso->kernel is DSO_TYPE_USER. dso->kernel is DSO_TYPE_KERNEL
> iff dso is vmlinux.

Kernel modules having DSO_TYPE_USER seems to be the bug, no? I'll try to
check that...

- Arnaldo

> 
> This patch fix 'perf probe -m' with an ad-hoc way.
> 
> After this patch:
> 
>  # perf probe -v -m e1000e --add e1000e_up
>  probe-definition(0): e1000e_up
>  symbol:e1000e_up file:(null) line:0 offset:0 return:0 lazy:(null)
>  0 arguments
>  Open Debuginfo file: /lib/modules/4.2.0-rc7+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
>  Try to find probe point from debuginfo.
>  Matched function: e1000e_up
>  Probe point found: e1000e_up+0
>  Found 1 probe_trace_events.
>  Opening /sys/kernel/debug/tracing//kprobe_events write=1
>  Writing event: p:probe/e1000e_up e1000e:e1000e_up+0
>  Added new event:
>    probe:e1000e_up      (on e1000e_up in e1000e)
> 
>  You can now use it in all perf tools, such as:
> 
>  	perf record -e probe:e1000e_up -aR sleep 1
> 
>  # perf probe -l
>  Failed to find debug information for address ffffffffa0093860
>    probe:e1000e_up      (on e1000e_up in e1000e)
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
> 
> I think there may be other places where dso->kernel is misused.
> machine__process_kernel_mmap_event() may be one of them. If I understand
> correctly, 'dso->kernel && is_kernel_module(dso->long_name)' should always
> false theoretically. However, I don't have enough time to check whether that
> code really cause problem.
> 
> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 2b78e8f..c7d6d3d 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -270,7 +270,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)
>  
>  	if (module) {
>  		list_for_each_entry(dso, &host_machine->dsos.head, node) {
> -			if (!dso->kernel)
> +			if (dso->kernel)
>  				continue;
>  			if (strncmp(dso->short_name + 1, module,
>  				    dso->short_name_len - 2) == 0)
> -- 
> 1.8.3.4

  reply	other threads:[~2015-09-22 13:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22  3:34 [PATCH] perf probe: Fix module probing with shortname Wang Nan
2015-09-22 13:35 ` Arnaldo Carvalho de Melo [this message]
2015-09-23  1:14   ` Wangnan (F)
2015-09-23  2:49     ` Arnaldo Carvalho de Melo
2015-09-23 16:03       ` Arnaldo Carvalho de Melo
2015-09-24  1:50         ` Arnaldo Carvalho de Melo
2015-09-24  2:05           ` Arnaldo Carvalho de Melo
2015-09-24  8:28             ` pi3orama
2015-09-24 10:10           ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-24 13:23             ` 'Arnaldo Carvalho de Melo'
2015-09-25  1:57               ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-24 10:18           ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-26  6:21           ` [tip:perf/urgent] perf probe: Use existing routine to look for a kernel module by dso->short_name tip-bot for Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150922133504.GA2580@redhat.com \
    --to=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=namhyung@kernel.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox