From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753013AbbIOHFR (ORCPT ); Tue, 15 Sep 2015 03:05:17 -0400 Received: from terminus.zytor.com ([198.137.202.10]:50240 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751964AbbIOHFJ (ORCPT ); Tue, 15 Sep 2015 03:05:09 -0400 Date: Tue, 15 Sep 2015 00:04:53 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: jolsa@redhat.com, tglx@linutronix.de, fweisbec@gmail.com, mingo@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, acme@redhat.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, dsahern@gmail.com, hpa@zytor.com, wangnan0@huawei.com, eranian@google.com, bp@suse.de Reply-To: fweisbec@gmail.com, tglx@linutronix.de, jolsa@redhat.com, adrian.hunter@intel.com, namhyung@kernel.org, mingo@kernel.org, kan.liang@intel.com, linux-kernel@vger.kernel.org, acme@redhat.com, eranian@google.com, wangnan0@huawei.com, dsahern@gmail.com, hpa@zytor.com, bp@suse.de To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf machine: Add pointer to sample's environment Git-Commit-ID: 4cde998d205894705b534878122631142a3eefe4 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: 4cde998d205894705b534878122631142a3eefe4 Gitweb: http://git.kernel.org/tip/4cde998d205894705b534878122631142a3eefe4 Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 9 Sep 2015 12:25:00 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 14 Sep 2015 12:50:29 -0300 perf machine: Add pointer to sample's environment The 'struct machine' represents the machine where the samples were/are being collected, and we also have a 'struct perf_env' with extra details about such machine, that we were collecting at 'perf.data' creation time but we also needed when no perf.data file is being used, such as in 'perf top'. So, get those structs closer together, as they provide a bigger picture of the sample's environment. In 'perf session', when the file argument is NULL, we can assume that the tool is sampling the running machine, so point machine->env to the global put in place in previous patches, while set it to the perf_header.env one when reading from a file. This paves the way for machine->env to be used in perf_event__preprocess_sample to populate addr_location.socket. Tested-by: Wang Nan Cc: Adrian Hunter Cc: Borislav Petkov Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Kan Liang Cc: Namhyung Kim Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-2ajotl0khscutm68exictoy9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/header.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/machine.h | 1 + tools/perf/util/session.c | 2 ++ 4 files changed, 5 insertions(+) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 46ec6c5..6d8fa54 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2564,6 +2564,7 @@ int perf_session__read_header(struct perf_session *session) return -ENOMEM; session->evlist->env = &header->env; + session->machines.host.env = &header->env; if (perf_data_file__is_pipe(file)) return perf_header__read_pipe(session); diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 6309f7c..fd1efea 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -35,6 +35,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) machine->last_match = NULL; machine->vdso_info = NULL; + machine->env = NULL; machine->pid = pid; diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index ea5cb4a..9dfc428 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -34,6 +34,7 @@ struct machine { struct list_head dead_threads; struct thread *last_match; struct vdso_info *vdso_info; + struct perf_env *env; struct dsos dsos; struct map_groups kmaps; struct map *vmlinux_maps[MAP__NR_TYPES]; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 728cb11..d1a43a3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -138,6 +138,8 @@ struct perf_session *perf_session__new(struct perf_data_file *file, perf_session__set_id_hdr_size(session); perf_session__set_comm_exec(session); } + } else { + session->machines.host.env = &perf_env; } if (!file || perf_data_file__is_write(file)) {