From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755110AbbCXQ3W (ORCPT ); Tue, 24 Mar 2015 12:29:22 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56693 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752915AbbCXQ3O (ORCPT ); Tue, 24 Mar 2015 12:29:14 -0400 Date: Tue, 24 Mar 2015 09:28:24 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: fweisbec@gmail.com, dsahern@gmail.com, linux-kernel@vger.kernel.org, cjashfor@linux.vnet.ibm.com, jolsa@kernel.org, tglx@linutronix.de, acme@redhat.com, mingo@kernel.org, a.p.zijlstra@chello.nl, paulus@samba.org, hpa@zytor.com, adrian.hunter@intel.com, eranian@google.com, namhyung@kernel.org Reply-To: acme@redhat.com, cjashfor@linux.vnet.ibm.com, tglx@linutronix.de, jolsa@kernel.org, mingo@kernel.org, fweisbec@gmail.com, linux-kernel@vger.kernel.org, dsahern@gmail.com, eranian@google.com, namhyung@kernel.org, adrian.hunter@intel.com, a.p.zijlstra@chello.nl, paulus@samba.org, hpa@zytor.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir Git-Commit-ID: bb58a8a459c322196613ad4af8801de41469cebb 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: bb58a8a459c322196613ad4af8801de41469cebb Gitweb: http://git.kernel.org/tip/bb58a8a459c322196613ad4af8801de41469cebb Author: Jiri Olsa AuthorDate: Thu, 12 Feb 2015 22:20:01 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 23 Mar 2015 11:43:25 -0300 perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir Replacing the file name parsing with kmod_path__parse and moving the dso update into new separate function. Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-q0ed76ajcyoaofotntrg5sla@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 65 ++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index eb95b88..6ca61a3 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -851,6 +851,39 @@ static char *get_kernel_version(const char *root_dir) return strdup(name); } +static bool is_kmod_dso(struct dso *dso) +{ + return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE || + dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE; +} + +static int map_groups__set_module_path(struct map_groups *mg, const char *path, + struct kmod_path *m) +{ + struct map *map; + char *long_name; + + map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name); + if (map == NULL) + return 0; + + long_name = strdup(path); + if (long_name == NULL) + return -ENOMEM; + + dso__set_long_name(map->dso, long_name, true); + dso__kernel_module_get_build_id(map->dso, ""); + + /* + * Full name could reveal us kmod compression, so + * we need to update the symtab_type if needed. + */ + if (m->comp && is_kmod_dso(map->dso)) + map->dso->symtab_type++; + + return 0; +} + static int map_groups__set_modules_path_dir(struct map_groups *mg, const char *dir_name, int depth) { @@ -889,35 +922,19 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg, if (ret < 0) goto out; } else { - char *dot = strrchr(dent->d_name, '.'), - dso_name[PATH_MAX]; - struct map *map; - char *long_name; + struct kmod_path m; - if (dot == NULL) - continue; + ret = kmod_path__parse_name(&m, dent->d_name); + if (ret) + goto out; - /* On some system, modules are compressed like .ko.gz */ - if (is_supported_compression(dot + 1) && - is_kmodule_extension(dot - 2)) - dot -= 3; + if (m.kmod) + ret = map_groups__set_module_path(mg, path, &m); - snprintf(dso_name, sizeof(dso_name), "[%.*s]", - (int)(dot - dent->d_name), dent->d_name); + free(m.name); - strxfrchar(dso_name, '-', '_'); - map = map_groups__find_by_name(mg, MAP__FUNCTION, - dso_name); - if (map == NULL) - continue; - - long_name = strdup(path); - if (long_name == NULL) { - ret = -1; + if (ret) goto out; - } - dso__set_long_name(map->dso, long_name, true); - dso__kernel_module_get_build_id(map->dso, ""); } }