From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hapkido.dreamhost.com ([66.33.216.122]:60183 "EHLO hapkido.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129AbdHZLKf (ORCPT ); Sat, 26 Aug 2017 07:10:35 -0400 Received: from homiemail-a117.g.dreamhost.com (sub5.mail.dreamhost.com [208.113.200.129]) by hapkido.dreamhost.com (Postfix) with ESMTP id 1E66C87A87 for ; Fri, 25 Aug 2017 16:05:37 -0700 (PDT) Received: from homiemail-a117.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a117.g.dreamhost.com (Postfix) with ESMTP id A18C560001209 for ; Fri, 25 Aug 2017 16:05:36 -0700 (PDT) Received: from kmjvbox (c-174-62-91-145.hsd1.ca.comcast.net [174.62.91.145]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by homiemail-a117.g.dreamhost.com (Postfix) with ESMTPSA id 8569E60001201 for ; Fri, 25 Aug 2017 16:05:36 -0700 (PDT) Date: Fri, 25 Aug 2017 16:05:35 -0700 From: Krister Johansen To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: acme@redhat.com, mhiramat@kernel.org, namhyung@kernel.org, jolsa@redhat.com, peterz@infradead.org Subject: [PATCH 4.9] perf probe: Fix --funcs to show correct symbols for offline module Message-ID: <20170825230535.GA2615@templeofstupid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: stable-owner@vger.kernel.org List-ID: Hi Greg, There's a bit more fallout from pulling in the patches we discussed in this thread: https://lkml.org/lkml/2017/7/5/537 While those patches fixed the build, I didn't get a chance to run a full set of tests on the result. Last week, when attempting to set a kretprobe in a kernel module using 'perf probe' I hit an assertion that triggers when you attempt to delete an object that's still in a tree. It turned out that the patch below was also pushed around the same time as the others that had been pulled into 4.9, and so we'd missed a case where a refcount was not getting correctly incremented. The patch below is just a git cherry-pick of the commit from HEAD to the stable 4.9 branch. This addressed the refcount assertion failure I was seeing. Thanks, -K ------------------------------------------------- From: Masami Hiramatsu commit eebc509b20881b92d62e317b2c073e57c5f200f0 upstream. Fix --funcs (-F) option to show correct symbols for offline module. Since previous perf-probe uses machine__findnew_module_map() for offline module, even if user passes a module file (with full path) which is for other architecture, perf-probe always tries to load symbol map for current kernel module. This fix uses dso__new_map() to load the map from given binary as same as a map for user applications. Signed-off-by: Masami Hiramatsu Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/148350053478.19001.15435255244512631545.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 6c50d9f..b7c7f42 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -163,7 +163,7 @@ static struct map *kernel_get_module_map(const char *module) /* A file path -- this is an offline module */ if (module && strchr(module, '/')) - return machine__findnew_module_map(host_machine, 0, module); + return dso__new_map(module); if (!module) module = "kernel"; @@ -173,6 +173,7 @@ static struct map *kernel_get_module_map(const char *module) if (strncmp(pos->dso->short_name + 1, module, pos->dso->short_name_len - 2) == 0 && module[pos->dso->short_name_len - 2] == '\0') { + map__get(pos); return pos; } } @@ -188,15 +189,6 @@ struct map *get_target_map(const char *target, bool user) return kernel_get_module_map(target); } -static void put_target_map(struct map *map, bool user) -{ - if (map && user) { - /* Only the user map needs to be released */ - map__put(map); - } -} - - static int convert_exec_to_group(const char *exec, char **result) { char *ptr1, *ptr2, *exec_copy; @@ -412,7 +404,7 @@ static int find_alternative_probe_point(struct debuginfo *dinfo, } out: - put_target_map(map, uprobes); + map__put(map); return ret; } @@ -2944,7 +2936,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, } out: - put_target_map(map, pev->uprobes); + map__put(map); free(syms); return ret; -- 2.10.1 (Apple Git-78)