From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751149AbdALI3a (ORCPT ); Thu, 12 Jan 2017 03:29:30 -0500 Received: from terminus.zytor.com ([198.137.202.10]:34712 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777AbdALI32 (ORCPT ); Thu, 12 Jan 2017 03:29:28 -0500 Date: Thu, 12 Jan 2017 00:29:11 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: linux-kernel@vger.kernel.org, jolsa@kernel.org, mhiramat@kernel.org, namhyung@kernel.org, dsahern@gmail.com, mingo@kernel.org, acme@redhat.com, adrian.hunter@intel.com, hpa@zytor.com, wangnan0@huawei.com, tglx@linutronix.de Reply-To: acme@redhat.com, adrian.hunter@intel.com, hpa@zytor.com, wangnan0@huawei.com, tglx@linutronix.de, dsahern@gmail.com, mingo@kernel.org, jolsa@kernel.org, mhiramat@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf machine: Add a kallsyms loading constructor Git-Commit-ID: 7d132caaf9392853ad637c8e6e53333cbeb99aa5 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: 7d132caaf9392853ad637c8e6e53333cbeb99aa5 Gitweb: http://git.kernel.org/tip/7d132caaf9392853ad637c8e6e53333cbeb99aa5 Author: Arnaldo Carvalho de Melo AuthorDate: Thu, 5 Jan 2017 15:31:48 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 11 Jan 2017 16:48:00 -0300 perf machine: Add a kallsyms loading constructor To reduce the boilerplate for searching for functions in the running kernel and modules. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-93iqzayafpaxaguoiwjqezgz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 19 +++++++++++++++++++ tools/perf/util/machine.h | 1 + 2 files changed, 20 insertions(+) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 9b33bef..747a034 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -87,6 +87,25 @@ out_delete: return NULL; } +struct machine *machine__new_kallsyms(void) +{ + struct machine *machine = machine__new_host(); + /* + * FIXME: + * 1) MAP__FUNCTION will go away when we stop loading separate maps for + * functions and data objects. + * 2) We should switch to machine__load_kallsyms(), i.e. not explicitely + * ask for not using the kcore parsing code, once this one is fixed + * to create a map per module. + */ + if (machine && __machine__load_kallsyms(machine, "/proc/kallsyms", MAP__FUNCTION, true) <= 0) { + machine__delete(machine); + machine = NULL; + } + + return machine; +} + static void dsos__purge(struct dsos *dsos) { struct dso *pos, *n; diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 354de6e..a283050 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -129,6 +129,7 @@ char *machine__mmap_name(struct machine *machine, char *bf, size_t size); void machines__set_comm_exec(struct machines *machines, bool comm_exec); struct machine *machine__new_host(void); +struct machine *machine__new_kallsyms(void); int machine__init(struct machine *machine, const char *root_dir, pid_t pid); void machine__exit(struct machine *machine); void machine__delete_threads(struct machine *machine);