Re: [PATCH v5 09/13] perf evsel: Support opening on a specific CPU
From: Andi Kleen
Date: Mon Nov 11 2019 - 19:41:03 EST
On Mon, Nov 11, 2019 at 02:30:33PM +0100, Jiri Olsa wrote:
> 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++) {
Yes you're right. The problem was the splitting of the patches.
With the two patches combined it works. So the end result is good,
just a bad intermediate step.
I will merge them again.
It seems better than creating something complicated here that
will just be undone next patch again.
-Andi