From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932266AbbJRCLy (ORCPT ); Sat, 17 Oct 2015 22:11:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41690 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429AbbJRCKV (ORCPT ); Sat, 17 Oct 2015 22:10:21 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Nan , Masami Hiramatsu , Adrian Hunter , Borislav Petkov , David Ahern , Frederic Weisbecker , Jiri Olsa , Namhyung Kim , Stephane Eranian , Arnaldo Carvalho de Melo Subject: [PATCH 4.2 034/258] perf probe: Use existing routine to look for a kernel module by dso->short_name Date: Sat, 17 Oct 2015 18:55:47 -0700 Message-Id: <20151018014731.868331131@linuxfoundation.org> X-Mailer: git-send-email 2.6.1 In-Reply-To: <20151018014729.976101177@linuxfoundation.org> References: <20151018014729.976101177@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo commit 266fa2b22294909ddf6e7d2f8acfe07adf9fd978 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/probe-event.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -274,12 +274,13 @@ static int kernel_get_module_dso(const c 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;