Re: [PATCH v5 5/5] perf-stat: introduce bpf_counter_ops->disable()

From: Jiri Olsa
Date: Mon Apr 26 2021 - 17:27:47 EST


On Sun, Apr 25, 2021 at 02:43:33PM -0700, Song Liu wrote:

SNIP

> +static inline int bpf_counter__disable(struct evsel *evsel __maybe_unused)
> +{
> + return 0;
> +}
> +
> static inline int bpf_counter__read(struct evsel *evsel __maybe_unused)
> {
> return -EAGAIN;
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index d29a8a118973c..e71041c890102 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -17,6 +17,7 @@
> #include "evsel.h"
> #include "debug.h"
> #include "units.h"
> +#include "bpf_counter.h"
> #include <internal/lib.h> // page_size
> #include "affinity.h"
> #include "../perf.h"
> @@ -421,6 +422,9 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name)
> if (affinity__setup(&affinity) < 0)
> return;
>
> + evlist__for_each_entry(evlist, pos)
> + bpf_counter__disable(pos);

I was wondering why you don't check evsel__is_bpf like
for the enable case.. and realized that we don't skip
bpf evsels in __evlist__enable and __evlist__disable
like we do in read_affinity_counters

so I guess there's extra affinity setup and bunch of
wrong ioctls being called?

jirka


> +
> /* Disable 'immediate' events last */
> for (imm = 0; imm <= 1; imm++) {
> evlist__for_each_cpu(evlist, i, cpu) {
> --
> 2.30.2
>