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

Commit e13798c7 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf thread_map: Don't access the array entries directly



Instead provide a method to set the array entries, and another to access
the contents.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1435012588-9007-2-git-send-email-jolsa@kernel.org


[ Split providing the set/get accessors from transforming the entries structs ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7c31bb8c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2325,7 +2325,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
	 */
	if (trace->filter_pids.nr > 0)
		err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries);
	else if (evlist->threads->map[0] == -1)
	else if (thread_map__pid(evlist->threads, 0) == -1)
		err = perf_evlist__set_filter_pid(evlist, getpid());

	if (err < 0) {
@@ -2343,7 +2343,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
	if (forks)
		perf_evlist__start_workload(evlist);

	trace->multiple_threads = evlist->threads->map[0] == -1 ||
	trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 ||
				  evlist->threads->nr > 1 ||
				  perf_evlist__first(evlist)->attr.inherit;
again:
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ int test__syscall_openat_tp_fields(void)

	perf_evsel__config(evsel, &opts);

	evlist->threads->map[0] = getpid();
	thread_map__set_pid(evlist->threads, 0, getpid());

	err = perf_evlist__open(evlist);
	if (err < 0) {
+2 −2
Original line number Diff line number Diff line
@@ -119,12 +119,12 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
	if (per_cpu) {
		mp->cpu = evlist->cpus->map[idx];
		if (evlist->threads)
			mp->tid = evlist->threads->map[0];
			mp->tid = thread_map__pid(evlist->threads, 0);
		else
			mp->tid = -1;
	} else {
		mp->cpu = -1;
		mp->tid = evlist->threads->map[idx];
		mp->tid = thread_map__pid(evlist->threads, idx);
	}
}

+3 −3
Original line number Diff line number Diff line
@@ -504,7 +504,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
	for (thread = 0; thread < threads->nr; ++thread) {
		if (__event__synthesize_thread(comm_event, mmap_event,
					       fork_event,
					       threads->map[thread], 0,
					       thread_map__pid(threads, thread), 0,
					       process, tool, machine,
					       mmap_data, proc_map_timeout)) {
			err = -1;
@@ -515,12 +515,12 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
		 * comm.pid is set to thread group id by
		 * perf_event__synthesize_comm
		 */
		if ((int) comm_event->comm.pid != threads->map[thread]) {
		if ((int) comm_event->comm.pid != thread_map__pid(threads, thread)) {
			bool need_leader = true;

			/* is thread group leader in thread_map? */
			for (j = 0; j < threads->nr; ++j) {
				if ((int) comm_event->comm.pid == threads->map[j]) {
				if ((int) comm_event->comm.pid == thread_map__pid(threads, j)) {
					need_leader = false;
					break;
				}
+2 −2
Original line number Diff line number Diff line
@@ -548,7 +548,7 @@ static void perf_evlist__set_sid_idx(struct perf_evlist *evlist,
	else
		sid->cpu = -1;
	if (!evsel->system_wide && evlist->threads && thread >= 0)
		sid->tid = evlist->threads->map[thread];
		sid->tid = thread_map__pid(evlist->threads, thread);
	else
		sid->tid = -1;
}
@@ -1475,7 +1475,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
				__func__, __LINE__);
			goto out_close_pipes;
		}
		evlist->threads->map[0] = evlist->workload.pid;
		thread_map__set_pid(evlist->threads, 0, evlist->workload.pid);
	}

	close(child_ready_pipe[1]);
Loading