Re: [PATCH v5 09/13] perf evsel: Support opening on a specific CPU

From: Jiri Olsa
Date: Mon Nov 11 2019 - 08:30:47 EST


On Thu, Nov 07, 2019 at 10:16:42AM -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

SNIP

> int perf_evsel__open_per_thread(struct evsel *evsel,
> diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
> index b10d5ba21966..54513d70c109 100644
> --- a/tools/perf/util/evsel.h
> +++ b/tools/perf/util/evsel.h
> @@ -223,7 +223,8 @@ int evsel__enable(struct evsel *evsel);
> int evsel__disable(struct evsel *evsel);
>
> int perf_evsel__open_per_cpu(struct evsel *evsel,
> - struct perf_cpu_map *cpus);
> + struct perf_cpu_map *cpus,
> + int cpu);
> int perf_evsel__open_per_thread(struct evsel *evsel,
> struct perf_thread_map *threads);
> int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index 6822e4ffe224..36dc95032e4c 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -517,7 +517,7 @@ int create_perf_stat_counter(struct evsel *evsel,
> }
>
> if (target__has_cpu(target) && !target__has_per_thread(target))
> - return perf_evsel__open_per_cpu(evsel, evsel__cpus(evsel));
> + return perf_evsel__open_per_cpu(evsel, evsel__cpus(evsel), -1);

how will -1 owrk in here? it will end up as:

perf_evsel__open_per_cpu
evsel__open_cpu( ...., start_cpu = -1, end_cpu = -1 + 1)
for (cpu = start_cpu; cpu < end_cpu; cpu++) {

?

jirka