Re: [PATCH v3 1/2] perf stat: Propagate supported flag to follower cgroup BPF events
From: Namhyung Kim
Date: Tue May 19 2026 - 01:53:51 EST
Hi Ian,
On Mon, May 18, 2026 at 10:01:49PM -0700, Ian Rogers wrote:
> When using BPF counters with cgroups, follower events (for cgroups
> other than the first one) are not opened. Because they are not opened,
> their `supported` flag was left as `false`.
>
> During metric calculation, `prepare_metric` checks if the event is
> supported. If it is not supported (like the follower events), it
> explicitly sets the value to `NAN`, which eventually causes the metric
> to be reported as `nan %`.
>
> Fix this by propagating the `supported` flag from the "leader" events
> (the ones opened for the first cgroup) to the "follower" events.
>
> Reported-by: Svilen Kanev <skanev@xxxxxxxxxx>
> Assisted-by: Antigravity:gemini-3-flash
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Thanks,
Namhyung
> ---
> tools/perf/util/bpf_counter_cgroup.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/perf/util/bpf_counter_cgroup.c b/tools/perf/util/bpf_counter_cgroup.c
> index 519fee3dc3d0..dd1851634087 100644
> --- a/tools/perf/util/bpf_counter_cgroup.c
> +++ b/tools/perf/util/bpf_counter_cgroup.c
> @@ -186,6 +186,21 @@ static int bperf_load_program(struct evlist *evlist)
> i++;
> }
>
> + /*
> + * Propagate supported flag from leaders to followers. Follower events
> + * are not opened, so their supported flag remains false.
> + */
> + {
> + struct evsel *leader;
> + int num_events = evlist->core.nr_entries / nr_cgroups;
> +
> + evlist__for_each_entry(evlist, evsel) {
> + leader = evlist__find_evsel(evlist, evsel->core.idx % num_events);
> + if (leader)
> + evsel->supported = leader->supported;
> + }
> + }
> +
> /*
> * bperf uses BPF_PROG_TEST_RUN to get accurate reading. Check
> * whether the kernel support it
> --
> 2.54.0.631.ge1b05301d1-goog
>