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

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

libperf: Add own_cpus to struct perf_evsel



Move own_cpus from tools/perf's evsel to libbpf's perf_evsel.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-52-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d400bd3a
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@ struct perf_evsel {
	struct list_head	 node;
	struct list_head	 node;
	struct perf_event_attr	 attr;
	struct perf_event_attr	 attr;
	struct perf_cpu_map	*cpus;
	struct perf_cpu_map	*cpus;
	struct perf_cpu_map	*own_cpus;
};
};


#endif /* __LIBPERF_INTERNAL_EVSEL_H */
#endif /* __LIBPERF_INTERNAL_EVSEL_H */
+2 −2
Original line number Original line Diff line number Diff line
@@ -109,11 +109,11 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
	TEST_ASSERT_VAL("failed to synthesize attr update name",
	TEST_ASSERT_VAL("failed to synthesize attr update name",
			!perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name));
			!perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name));


	evsel->own_cpus = perf_cpu_map__new("1,2,3");
	evsel->core.own_cpus = perf_cpu_map__new("1,2,3");


	TEST_ASSERT_VAL("failed to synthesize attr update cpus",
	TEST_ASSERT_VAL("failed to synthesize attr update cpus",
			!perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));
			!perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));


	perf_cpu_map__put(evsel->own_cpus);
	perf_cpu_map__put(evsel->core.own_cpus);
	return 0;
	return 0;
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -159,12 +159,12 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
	 * We already have cpus for evsel (via PMU sysfs) so
	 * We already have cpus for evsel (via PMU sysfs) so
	 * keep it, if there's no target cpu list defined.
	 * keep it, if there's no target cpu list defined.
	 */
	 */
	if (!evsel->own_cpus || evlist->has_user_cpus) {
	if (!evsel->core.own_cpus || evlist->has_user_cpus) {
		perf_cpu_map__put(evsel->core.cpus);
		perf_cpu_map__put(evsel->core.cpus);
		evsel->core.cpus = perf_cpu_map__get(evlist->cpus);
		evsel->core.cpus = perf_cpu_map__get(evlist->cpus);
	} else if (evsel->core.cpus != evsel->own_cpus) {
	} else if (evsel->core.cpus != evsel->core.own_cpus) {
		perf_cpu_map__put(evsel->core.cpus);
		perf_cpu_map__put(evsel->core.cpus);
		evsel->core.cpus = perf_cpu_map__get(evsel->own_cpus);
		evsel->core.cpus = perf_cpu_map__get(evsel->core.own_cpus);
	}
	}


	perf_thread_map__put(evsel->threads);
	perf_thread_map__put(evsel->threads);
+2 −2
Original line number Original line Diff line number Diff line
@@ -1125,7 +1125,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,
		attr->exclude_user   = 1;
		attr->exclude_user   = 1;
	}
	}


	if (evsel->own_cpus || evsel->unit)
	if (evsel->core.own_cpus || evsel->unit)
		evsel->core.attr.read_format |= PERF_FORMAT_ID;
		evsel->core.attr.read_format |= PERF_FORMAT_ID;


	/*
	/*
@@ -1326,7 +1326,7 @@ void perf_evsel__exit(struct evsel *evsel)
	perf_evsel__free_config_terms(evsel);
	perf_evsel__free_config_terms(evsel);
	cgroup__put(evsel->cgrp);
	cgroup__put(evsel->cgrp);
	perf_cpu_map__put(evsel->core.cpus);
	perf_cpu_map__put(evsel->core.cpus);
	perf_cpu_map__put(evsel->own_cpus);
	perf_cpu_map__put(evsel->core.own_cpus);
	perf_thread_map__put(evsel->threads);
	perf_thread_map__put(evsel->threads);
	zfree(&evsel->group_name);
	zfree(&evsel->group_name);
	zfree(&evsel->name);
	zfree(&evsel->name);
+0 −1
Original line number Original line Diff line number Diff line
@@ -123,7 +123,6 @@ struct evsel {
	u64			db_id;
	u64			db_id;
	struct cgroup		*cgrp;
	struct cgroup		*cgrp;
	void			*handler;
	void			*handler;
	struct perf_cpu_map	*own_cpus;
	struct perf_thread_map *threads;
	struct perf_thread_map *threads;
	unsigned int		sample_size;
	unsigned int		sample_size;
	int			id_pos;
	int			id_pos;
Loading