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

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

libperf: Add cpus to struct perf_evsel



Mov the 'cpus' field from tools/perf's evsel to libperf'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-51-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b9358ee9
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -739,7 +739,7 @@ static int record__open(struct record *rec)


	evlist__for_each_entry(evlist, pos) {
	evlist__for_each_entry(evlist, pos) {
try_again:
try_again:
		if (evsel__open(pos, pos->cpus, pos->threads) < 0) {
		if (evsel__open(pos, pos->core.cpus, pos->threads) < 0) {
			if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
			if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
				if (verbose > 0)
				if (verbose > 0)
					ui__warning("%s\n", msg);
					ui__warning("%s\n", msg);
+1 −1
Original line number Original line Diff line number Diff line
@@ -1920,7 +1920,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp)
			counts = perf_counts(counter->counts, cpu, thread);
			counts = perf_counts(counter->counts, cpu, thread);


			printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
			printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
				counter->cpus->map[cpu],
				counter->core.cpus->map[cpu],
				thread_map__pid(counter->threads, thread),
				thread_map__pid(counter->threads, thread),
				counts->val,
				counts->val,
				counts->ena,
				counts->ena,
+5 −2
Original line number Original line Diff line number Diff line
@@ -5,9 +5,12 @@
#include <linux/types.h>
#include <linux/types.h>
#include <linux/perf_event.h>
#include <linux/perf_event.h>


struct perf_cpu_map;

struct perf_evsel {
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;
};
};


#endif /* __LIBPERF_INTERNAL_EVSEL_H */
#endif /* __LIBPERF_INTERNAL_EVSEL_H */
+7 −7
Original line number Original line Diff line number Diff line
@@ -160,11 +160,11 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
	 * 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->own_cpus || evlist->has_user_cpus) {
		perf_cpu_map__put(evsel->cpus);
		perf_cpu_map__put(evsel->core.cpus);
		evsel->cpus = perf_cpu_map__get(evlist->cpus);
		evsel->core.cpus = perf_cpu_map__get(evlist->cpus);
	} else if (evsel->cpus != evsel->own_cpus) {
	} else if (evsel->core.cpus != evsel->own_cpus) {
		perf_cpu_map__put(evsel->cpus);
		perf_cpu_map__put(evsel->core.cpus);
		evsel->cpus = perf_cpu_map__get(evsel->own_cpus);
		evsel->core.cpus = perf_cpu_map__get(evsel->own_cpus);
	}
	}


	perf_thread_map__put(evsel->threads);
	perf_thread_map__put(evsel->threads);
@@ -786,7 +786,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx,
		if (evsel->system_wide && thread)
		if (evsel->system_wide && thread)
			continue;
			continue;


		cpu = cpu_map__idx(evsel->cpus, evlist_cpu);
		cpu = cpu_map__idx(evsel->core.cpus, evlist_cpu);
		if (cpu == -1)
		if (cpu == -1)
			continue;
			continue;


@@ -1407,7 +1407,7 @@ int evlist__open(struct evlist *evlist)
	perf_evlist__update_id_pos(evlist);
	perf_evlist__update_id_pos(evlist);


	evlist__for_each_entry(evlist, evsel) {
	evlist__for_each_entry(evlist, evsel) {
		err = evsel__open(evsel, evsel->cpus, evsel->threads);
		err = evsel__open(evsel, evsel->core.cpus, evsel->threads);
		if (err < 0)
		if (err < 0)
			goto out_err;
			goto out_err;
	}
	}
+2 −2
Original line number Original line Diff line number Diff line
@@ -1325,7 +1325,7 @@ void perf_evsel__exit(struct evsel *evsel)
	perf_evsel__free_id(evsel);
	perf_evsel__free_id(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->cpus);
	perf_cpu_map__put(evsel->core.cpus);
	perf_cpu_map__put(evsel->own_cpus);
	perf_cpu_map__put(evsel->own_cpus);
	perf_thread_map__put(evsel->threads);
	perf_thread_map__put(evsel->threads);
	zfree(&evsel->group_name);
	zfree(&evsel->group_name);
@@ -3064,7 +3064,7 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)


int perf_evsel__store_ids(struct evsel *evsel, struct evlist *evlist)
int perf_evsel__store_ids(struct evsel *evsel, struct evlist *evlist)
{
{
	struct perf_cpu_map *cpus = evsel->cpus;
	struct perf_cpu_map *cpus = evsel->core.cpus;
	struct perf_thread_map *threads = evsel->threads;
	struct perf_thread_map *threads = evsel->threads;


	if (perf_evsel__alloc_id(evsel, cpus->nr, threads->nr))
	if (perf_evsel__alloc_id(evsel, cpus->nr, threads->nr))
Loading