Re: [PATCH v3 3/7] perf evsel: Add iterator to iterate over events ordered by CPU

Jiri Olsa
2019-10-30T18:16:02Z

On Wed, Oct 30, 2019 at 08:51:08AM -0700, Andi Kleen wrote:
> On Wed, Oct 30, 2019 at 11:06:06AM +0100, Jiri Olsa wrote:
> > > +struct perf_cpu_map *evlist__cpu_iter_start(struct evlist *evlist)
> > > +{
> > > + struct perf_cpu_map *cpus;
> > > + struct evsel *pos;
> > > +
> > > + /*
> > > + * evlist->cpus is not necessarily a superset of all the
> > > + * event's cpus, so compute our own super set. This
> > > + * assume that there is a super set
> > > + */
> > > + cpus = evlist->core.cpus;
> > > + evlist__for_each_entry(evlist, pos) {
> > > + pos->cpu_index = 0;
> > > + if (pos->core.cpus->nr > cpus->nr)
> > > + cpus = pos->core.cpus;
> > > + }
> > > + return cpus;
> >
> > I might not understand the reason for cpu_index, but
>
> This is just so that we can iterate each event's map
> independently.
>
> > imagine something like below should be enough, no?
>
> Well it's more complicated because evlist->all_cpus doesn't exist.

yes, I suggest to create it

> The exists evlist->cpus cannot be used (I tried that)
> I also don't think we have an existing function to merge
> two maps, so that would need to be added to create it.
> Just using ->cpu_index is a much simpler change.

I dont think that would be lot of code
and it would simplify this one

jirka