Re: [PATCH v7 10/12] perf stat: Use affinity for reading

Jiri Olsa
2019-11-20T15:12:33Z

On Fri, Nov 15, 2019 at 09:52:27PM -0800, Andi Kleen wrote:

SNIP

> + perf_evsel__name(counter),
> + cpu,
> + count->val, count->ena, count->run);
> + }
> }
>
> return 0;
> @@ -325,15 +318,36 @@ static int read_counter(struct evsel *counter, struct timespec *rs)
> static void read_counters(struct timespec *rs)
> {
> struct evsel *counter;
> - int ret;
> + struct affinity affinity;
> + int i, ncpus, cpu;
> +
> + if (affinity__setup(&affinity) < 0)
> + return;
> +
> + ncpus = evsel_list->core.all_cpus->nr;

please use perf_cpu_map__nr

> + if (!target__has_cpu(&target) || target__has_per_thread(&target))
> + ncpus = 1;
> + evlist__for_each_cpu (evsel_list, i, cpu) {
> + if (i >= ncpus)
> + break;
> + affinity__set(&affinity, cpu);
> +
> + evlist__for_each_entry(evsel_list, counter) {
> + if (evsel__cpu_iter_skip(counter, cpu))
> + continue;
> + if (!counter->err)
> + counter->err = read_counter_cpu(counter, rs,
> + counter->cpu_iter - 1);

please use { } to enclose multiline if legs

thanks,
jirka