Skip to content

Commit 4402869

Browse files
captain5050acmel
authored andcommitted
perf cpumap: Migrate to libperf cpumap api
Switch from directly accessing the perf_cpu_map to using the appropriate libperf API when possible. Using the API simplifies the job of refactoring use of perf_cpu_map. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexey Bayduraev <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andrew Morton <[email protected]> Cc: André Almeida <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Darren Hart <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Dmitriy Vyukov <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: German Gomez <[email protected]> Cc: James Clark <[email protected]> Cc: Jin Yao <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Miaoqian Lin <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Riccardo Mancini <[email protected]> Cc: Shunsuke Nakamura <[email protected]> Cc: Song Liu <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Stephen Brennan <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Thomas Richter <[email protected]> Cc: Yury Norov <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1d1d9af commit 4402869

31 files changed

+99
-87
lines changed

tools/lib/perf/evsel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
141141
}
142142

143143
if (evsel->fd == NULL &&
144-
perf_evsel__alloc_fd(evsel, cpus->nr, threads->nr) < 0)
144+
perf_evsel__alloc_fd(evsel, perf_cpu_map__nr(cpus), threads->nr) < 0)
145145
return -ENOMEM;
146146

147147
perf_cpu_map__for_each_cpu(cpu, idx, cpus) {
@@ -384,7 +384,7 @@ int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter)
384384
{
385385
int err = 0, i;
386386

387-
for (i = 0; i < evsel->cpus->nr && !err; i++)
387+
for (i = 0; i < perf_cpu_map__nr(evsel->cpus) && !err; i++)
388388
err = perf_evsel__run_ioctl(evsel,
389389
PERF_EVENT_IOC_SET_FILTER,
390390
(void *)filter, i);

tools/perf/bench/epoll-ctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ int bench_epoll_ctl(int argc, const char **argv)
333333

334334
/* default to the number of CPUs */
335335
if (!nthreads)
336-
nthreads = cpu->nr;
336+
nthreads = perf_cpu_map__nr(cpu);
337337

338338
worker = calloc(nthreads, sizeof(*worker));
339339
if (!worker)

tools/perf/bench/epoll-wait.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ int bench_epoll_wait(int argc, const char **argv)
452452

453453
/* default to the number of CPUs and leave one for the writer pthread */
454454
if (!nthreads)
455-
nthreads = cpu->nr - 1;
455+
nthreads = perf_cpu_map__nr(cpu) - 1;
456456

457457
worker = calloc(nthreads, sizeof(*worker));
458458
if (!worker) {

tools/perf/bench/evlist-open-close.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int evlist__count_evsel_fds(struct evlist *evlist)
7171
int cnt = 0;
7272

7373
evlist__for_each_entry(evlist, evsel)
74-
cnt += evsel->core.threads->nr * evsel->core.cpus->nr;
74+
cnt += evsel->core.threads->nr * perf_cpu_map__nr(evsel->core.cpus);
7575

7676
return cnt;
7777
}
@@ -151,7 +151,7 @@ static int bench_evlist_open_close__run(char *evstr)
151151

152152
init_stats(&time_stats);
153153

154-
printf(" Number of cpus:\t%d\n", evlist->core.cpus->nr);
154+
printf(" Number of cpus:\t%d\n", perf_cpu_map__nr(evlist->core.cpus));
155155
printf(" Number of threads:\t%d\n", evlist->core.threads->nr);
156156
printf(" Number of events:\t%d (%d fds)\n",
157157
evlist->core.nr_entries, evlist__count_evsel_fds(evlist));

tools/perf/bench/futex-hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int bench_futex_hash(int argc, const char **argv)
150150
}
151151

152152
if (!params.nthreads) /* default to the number of CPUs */
153-
params.nthreads = cpu->nr;
153+
params.nthreads = perf_cpu_map__nr(cpu);
154154

155155
worker = calloc(params.nthreads, sizeof(*worker));
156156
if (!worker)

tools/perf/bench/futex-lock-pi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
173173
}
174174

175175
if (!params.nthreads)
176-
params.nthreads = cpu->nr;
176+
params.nthreads = perf_cpu_map__nr(cpu);
177177

178178
worker = calloc(params.nthreads, sizeof(*worker));
179179
if (!worker)

tools/perf/bench/futex-requeue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int bench_futex_requeue(int argc, const char **argv)
175175
}
176176

177177
if (!params.nthreads)
178-
params.nthreads = cpu->nr;
178+
params.nthreads = perf_cpu_map__nr(cpu);
179179

180180
worker = calloc(params.nthreads, sizeof(*worker));
181181
if (!worker)

tools/perf/bench/futex-wake-parallel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int bench_futex_wake_parallel(int argc, const char **argv)
252252
err(EXIT_FAILURE, "calloc");
253253

254254
if (!params.nthreads)
255-
params.nthreads = cpu->nr;
255+
params.nthreads = perf_cpu_map__nr(cpu);
256256

257257
/* some sanity checks */
258258
if (params.nwakes > params.nthreads ||

tools/perf/bench/futex-wake.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int bench_futex_wake(int argc, const char **argv)
151151
}
152152

153153
if (!params.nthreads)
154-
params.nthreads = cpu->nr;
154+
params.nthreads = perf_cpu_map__nr(cpu);
155155

156156
worker = calloc(params.nthreads, sizeof(*worker));
157157
if (!worker)

tools/perf/builtin-ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int set_tracing_cpumask(struct perf_cpu_map *cpumap)
281281
int ret;
282282
int last_cpu;
283283

284-
last_cpu = perf_cpu_map__cpu(cpumap, cpumap->nr - 1).cpu;
284+
last_cpu = perf_cpu_map__cpu(cpumap, perf_cpu_map__nr(cpumap) - 1).cpu;
285285
mask_size = last_cpu / 4 + 2; /* one more byte for EOS */
286286
mask_size += last_cpu / 32; /* ',' is needed for every 32th cpus */
287287

0 commit comments

Comments
 (0)