Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cde998d authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

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: default avatarWang Nan <wangnan0@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-2ajotl0khscutm68exictoy9@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent aa36ddd7
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -2564,6 +2564,7 @@ int perf_session__read_header(struct perf_session *session)
		return -ENOMEM;
		return -ENOMEM;


	session->evlist->env = &header->env;
	session->evlist->env = &header->env;
	session->machines.host.env = &header->env;
	if (perf_data_file__is_pipe(file))
	if (perf_data_file__is_pipe(file))
		return perf_header__read_pipe(session);
		return perf_header__read_pipe(session);


+1 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
	machine->last_match = NULL;
	machine->last_match = NULL;


	machine->vdso_info = NULL;
	machine->vdso_info = NULL;
	machine->env = NULL;


	machine->pid = pid;
	machine->pid = pid;


+1 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ struct machine {
	struct list_head  dead_threads;
	struct list_head  dead_threads;
	struct thread	  *last_match;
	struct thread	  *last_match;
	struct vdso_info  *vdso_info;
	struct vdso_info  *vdso_info;
	struct perf_env   *env;
	struct dsos	  dsos;
	struct dsos	  dsos;
	struct map_groups kmaps;
	struct map_groups kmaps;
	struct map	  *vmlinux_maps[MAP__NR_TYPES];
	struct map	  *vmlinux_maps[MAP__NR_TYPES];
+2 −0
Original line number Original line Diff line number Diff line
@@ -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_id_hdr_size(session);
			perf_session__set_comm_exec(session);
			perf_session__set_comm_exec(session);
		}
		}
	} else  {
		session->machines.host.env = &perf_env;
	}
	}


	if (!file || perf_data_file__is_write(file)) {
	if (!file || perf_data_file__is_write(file)) {