Re: [PATCH v5 10/13] perf stat: Use affinity for opening events

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


On Thu, Nov 07, 2019 at 10:16:43AM -0800, Andi Kleen wrote:

SNIP

> + * Don't close here because we're in the wrong affinity.
> + */
> + if ((errno == EINVAL || errno == EBADF) &&
> + counter->leader != counter &&
> + counter->weak_group) {
> + perf_evlist__reset_weak_group(evsel_list, counter, false);
> + assert(counter->reset_group);
> + second_pass = true;
> + continue;
> + }
> +
> + switch (stat_handle_error(counter)) {
> + case COUNTER_FATAL:
> + return -1;
> + case COUNTER_RETRY:
> + goto try_again;
> + case COUNTER_SKIP:
> + continue;
> + default:
> + break;
> + }
> +
> }
> + counter->supported = true;
> + }
> + }
>
> - switch (stat_handle_error(counter)) {
> - case COUNTER_FATAL:
> - return -1;
> - case COUNTER_RETRY:
> - goto try_again;
> - case COUNTER_SKIP:
> - continue;
> - default:
> - break;
> + if (second_pass) {
> + /*
> + * Now redo all the weak group after closing them,
> + * and also close errored counters.
> + */
> +
> + evlist__cpu_iter_start(evsel_list);
> + evlist__for_each_cpu (evsel_list, i, cpu) {

no need for evlist__cpu_iter_start call in here?

jirka

> + affinity__set(&affinity, cpu);
> + /* First close errored or weak retry */
> + evlist__for_each_entry(evsel_list, counter) {
> + if (!counter->reset_group && !counter->errored)
> + continue;
> + if (evsel__cpu_iter_skip_no_inc(counter, cpu))
> + continue;
> + perf_evsel__close_cpu(&counter->core, counter->cpu_iter);
> }
> + /* Now reopen weak */
> + evlist__for_each_entry(evsel_list, counter) {
> + if (!counter->reset_group && !counter->errored)

SNIP