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

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

perf tools: Use perf_cpu_map__nr instead of cpu_map__nr

Switch the rest of the perf code to use libperf's perf_cpu_map__nr(),
which is the same as current cpu_map__nr() and remove the cpu_map__nr()
function.

Link: http://lkml.kernel.org/n/tip-6e0guy75clis7nm0xpuz9fga@git.kernel.org


Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@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/20190822111141.25823-3-jolsa@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent db9a5fd0
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -653,7 +653,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
		cpu_map = online_cpus;
		cpu_map = online_cpus;
	} else {
	} else {
		/* Make sure all specified CPUs are online */
		/* Make sure all specified CPUs are online */
		for (i = 0; i < cpu_map__nr(event_cpus); i++) {
		for (i = 0; i < perf_cpu_map__nr(event_cpus); i++) {
			if (cpu_map__has(event_cpus, i) &&
			if (cpu_map__has(event_cpus, i) &&
			    !cpu_map__has(online_cpus, i))
			    !cpu_map__has(online_cpus, i))
				return -EINVAL;
				return -EINVAL;
@@ -662,7 +662,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
		cpu_map = event_cpus;
		cpu_map = event_cpus;
	}
	}


	nr_cpu = cpu_map__nr(cpu_map);
	nr_cpu = perf_cpu_map__nr(cpu_map);
	/* Get PMU type as dynamically assigned by the core */
	/* Get PMU type as dynamically assigned by the core */
	type = cs_etm_pmu->type;
	type = cs_etm_pmu->type;


+0 −5
Original line number Original line Diff line number Diff line
@@ -49,11 +49,6 @@ static inline int cpu_map__id_to_cpu(int id)
	return id & 0xffff;
	return id & 0xffff;
}
}


static inline int cpu_map__nr(const struct perf_cpu_map *map)
{
	return map ? map->nr : 1;
}

static inline bool cpu_map__empty(const struct perf_cpu_map *map)
static inline bool cpu_map__empty(const struct perf_cpu_map *map)
{
{
	return map ? map->map[0] == -1 : true;
	return map ? map->map[0] == -1 : true;
+5 −5
Original line number Original line Diff line number Diff line
@@ -370,7 +370,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,
					    int thread)
					    int thread)
{
{
	int cpu;
	int cpu;
	int nr_cpus = cpu_map__nr(evlist->core.cpus);
	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);


	if (!evsel->core.fd)
	if (!evsel->core.fd)
		return -EINVAL;
		return -EINVAL;
@@ -396,7 +396,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,


int perf_evlist__alloc_pollfd(struct evlist *evlist)
int perf_evlist__alloc_pollfd(struct evlist *evlist)
{
{
	int nr_cpus = cpu_map__nr(evlist->core.cpus);
	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
	int nr_threads = thread_map__nr(evlist->core.threads);
	int nr_threads = thread_map__nr(evlist->core.threads);
	int nfds = 0;
	int nfds = 0;
	struct evsel *evsel;
	struct evsel *evsel;
@@ -692,7 +692,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,
	int i;
	int i;
	struct perf_mmap *map;
	struct perf_mmap *map;


	evlist->nr_mmaps = cpu_map__nr(evlist->core.cpus);
	evlist->nr_mmaps = perf_cpu_map__nr(evlist->core.cpus);
	if (cpu_map__empty(evlist->core.cpus))
	if (cpu_map__empty(evlist->core.cpus))
		evlist->nr_mmaps = thread_map__nr(evlist->core.threads);
		evlist->nr_mmaps = thread_map__nr(evlist->core.threads);
	map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
	map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
@@ -807,7 +807,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist,
				     struct mmap_params *mp)
				     struct mmap_params *mp)
{
{
	int cpu, thread;
	int cpu, thread;
	int nr_cpus = cpu_map__nr(evlist->core.cpus);
	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
	int nr_threads = thread_map__nr(evlist->core.threads);
	int nr_threads = thread_map__nr(evlist->core.threads);


	pr_debug2("perf event ring buffer mmapped per cpu\n");
	pr_debug2("perf event ring buffer mmapped per cpu\n");
@@ -1014,7 +1014,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
	evlist__for_each_entry(evlist, evsel) {
	evlist__for_each_entry(evlist, evsel) {
		if ((evsel->core.attr.read_format & PERF_FORMAT_ID) &&
		if ((evsel->core.attr.read_format & PERF_FORMAT_ID) &&
		    evsel->sample_id == NULL &&
		    evsel->sample_id == NULL &&
		    perf_evsel__alloc_id(evsel, cpu_map__nr(cpus), threads->nr) < 0)
		    perf_evsel__alloc_id(evsel, perf_cpu_map__nr(cpus), threads->nr) < 0)
			return -ENOMEM;
			return -ENOMEM;
	}
	}


+1 −1
Original line number Original line Diff line number Diff line
@@ -331,7 +331,7 @@ static void build_node_mask(int node, cpu_set_t *mask)
	if (!cpu_map)
	if (!cpu_map)
		return;
		return;


	nr_cpus = cpu_map__nr(cpu_map);
	nr_cpus = perf_cpu_map__nr(cpu_map);
	for (c = 0; c < nr_cpus; c++) {
	for (c = 0; c < nr_cpus; c++) {
		cpu = cpu_map->map[c]; /* map c index to online cpu index */
		cpu = cpu_map->map[c]; /* map c index to online cpu index */
		if (cpu__get_node(cpu) == node)
		if (cpu__get_node(cpu) == node)
+1 −1
Original line number Original line Diff line number Diff line
@@ -745,7 +745,7 @@ static void print_aggr_thread(struct perf_stat_config *config,
{
{
	FILE *output = config->output;
	FILE *output = config->output;
	int nthreads = thread_map__nr(counter->core.threads);
	int nthreads = thread_map__nr(counter->core.threads);
	int ncpus = cpu_map__nr(counter->core.cpus);
	int ncpus = perf_cpu_map__nr(counter->core.cpus);
	int thread, sorted_threads, id;
	int thread, sorted_threads, id;
	struct perf_aggr_thread_value *buf;
	struct perf_aggr_thread_value *buf;