From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbbIZGWO (ORCPT ); Sat, 26 Sep 2015 02:22:14 -0400 Received: from terminus.zytor.com ([198.137.202.10]:49590 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbbIZGWK (ORCPT ); Sat, 26 Sep 2015 02:22:10 -0400 Date: Fri, 25 Sep 2015 23:21:34 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: jolsa@redhat.com, acme@redhat.com, bp@suse.de, eranian@google.com, fweisbec@gmail.com, mingo@kernel.org, masami.hiramatsu.pt@hitachi.com, dsahern@gmail.com, tglx@linutronix.de, adrian.hunter@intel.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, hpa@zytor.com, namhyung@kernel.org Reply-To: jolsa@redhat.com, eranian@google.com, bp@suse.de, acme@redhat.com, fweisbec@gmail.com, mingo@kernel.org, dsahern@gmail.com, masami.hiramatsu.pt@hitachi.com, adrian.hunter@intel.com, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, wangnan0@huawei.com, namhyung@kernel.org In-Reply-To: <20150924015008.GE1897@kernel.org> References: <20150924015008.GE1897@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf probe: Use existing routine to look for a kernel module by dso->short_name Git-Commit-ID: 266fa2b22294909ddf6e7d2f8acfe07adf9fd978 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 266fa2b22294909ddf6e7d2f8acfe07adf9fd978 Gitweb: http://git.kernel.org/tip/266fa2b22294909ddf6e7d2f8acfe07adf9fd978 Author: Arnaldo Carvalho de Melo AuthorDate: Thu, 24 Sep 2015 11:24:18 -0300 Committer: Arnaldo Carvalho de Melo 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 Acked-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Borislav Petkov Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian 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 --- 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;