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


Groups > linux.kernel > #1233157

[tip:perf/urgent] perf probe: Use existing routine to look for a kernel module by dso->short_name

From tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/urgent] perf probe: Use existing routine to look for a kernel module by dso->short_name
Date 2015-09-26 08:30 +0200
Message-ID <qcR9E-d5-11@gated-at.bofh.it> (permalink)
References <qc3Zf-5tJ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  266fa2b22294909ddf6e7d2f8acfe07adf9fd978
Gitweb:     http://git.kernel.org/tip/266fa2b22294909ddf6e7d2f8acfe07adf9fd978
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Thu, 24 Sep 2015 11:24:18 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 25 Sep 2015 10:41:31 -0300

perf probe: Use existing routine to look for a kernel module by dso->short_name

We have map_groups__find_by_name() to look at the list of modules that
are in place for a given machine, so use it instead of traversing the
machine dso list, which also includes DSOs for userspace.

When merging the user and kernel DSO lists a bug was introduced where
'perf probe' stopped being able to add probes to modules using its short
name:

  # perf probe -m usbnet --add usbnet_start_xmit
  usbnet_start_xmit is out of .text, skip it.
    Error: Failed to add events.
  #

With this fix it works again:

  # perf probe -m usbnet --add usbnet_start_xmit
  Added new event:
    probe:usbnet_start_xmit (on usbnet_start_xmit in usbnet)

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

  	perf record -e probe:usbnet_start_xmit -aR sleep 1
  #

Reported-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Fixes: 3d39ac538629 ("perf machine: No need to have two DSOs lists")
Link: http://lkml.kernel.org/r/20150924015008.GE1897@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index eb5f18b..c6f9af7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -270,12 +270,13 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)
 	int ret = 0;
 
 	if (module) {
-		list_for_each_entry(dso, &host_machine->dsos.head, node) {
-			if (!dso->kernel)
-				continue;
-			if (strncmp(dso->short_name + 1, module,
-				    dso->short_name_len - 2) == 0)
-				goto found;
+		char module_name[128];
+
+		snprintf(module_name, sizeof(module_name), "[%s]", module);
+		map = map_groups__find_by_name(&host_machine->kmaps, MAP__FUNCTION, module_name);
+		if (map) {
+			dso = map->dso;
+			goto found;
 		}
 		pr_debug("Failed to find module %s.\n", module);
 		return -ENOENT;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH] perf probe: Fix module probing with shortname Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-09-22 15:40 +0200
  Re: [PATCH] perf probe: Fix module probing with shortname "Wangnan (F)" <wangnan0@huawei.com> - 2015-09-23 03:20 +0200
    Re: [PATCH] perf probe: Fix module probing with shortname Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-09-23 04:50 +0200
      Re: [PATCH] perf probe: Fix module probing with shortname Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-09-23 18:10 +0200
        Re: [PATCH] perf probe: Fix module probing with shortname Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-24 04:00 +0200
          Re: [PATCH] perf probe: Fix module probing with shortname Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-24 04:10 +0200
            Re: [PATCH] perf probe: Fix module probing with shortname pi3orama <pi3orama@163.com> - 2015-09-24 10:30 +0200
          RE: [PATCH] perf probe: Fix module probing with shortname 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-09-24 12:20 +0200
          RE: [PATCH] perf probe: Fix module probing with shortname 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-09-24 12:20 +0200
            Re: [PATCH] perf probe: Fix module probing with shortname 'Arnaldo Carvalho de Melo' <acme@kernel.org> - 2015-09-24 15:30 +0200
              RE: [PATCH] perf probe: Fix module probing with shortname 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-09-25 04:00 +0200
          [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 <tipbot@zytor.com> - 2015-09-26 08:30 +0200

csiph-web