From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: acme@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org,
jolsa@kernel.org, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, mingo@redhat.com,
peterz@infradead.org, skanev@google.com
Subject: Re: [PATCH v3 1/2] perf stat: Propagate supported flag to follower cgroup BPF events
Date: Mon, 18 May 2026 22:47:55 -0700 [thread overview]
Message-ID: <agv5i_xZCRMK4aid@z2> (raw)
In-Reply-To: <20260519050150.3144907-2-irogers@google.com>
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@google.com>
> Assisted-by: Antigravity:gemini-3-flash
> Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
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
>
next prev parent reply other threads:[~2026-05-19 5:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 22:22 [PATCH v1 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-18 22:22 ` [PATCH v1 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-18 22:22 ` [PATCH v1 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
2026-05-18 22:43 ` sashiko-bot
2026-05-19 1:51 ` [PATCH v2 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-19 1:51 ` [PATCH v2 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-19 1:51 ` [PATCH v2 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
2026-05-19 2:59 ` sashiko-bot
2026-05-19 5:01 ` [PATCH v3 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-19 5:01 ` [PATCH v3 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-19 5:39 ` sashiko-bot
2026-05-19 5:47 ` Namhyung Kim [this message]
2026-05-19 5:01 ` [PATCH v3 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
2026-05-19 5:47 ` sashiko-bot
2026-05-19 5:54 ` Namhyung Kim
2026-05-19 15:13 ` Ian Rogers
2026-05-19 17:09 ` Namhyung Kim
2026-05-19 15:27 ` [PATCH v4 0/2] Fix cgroup metric association with BPF counters Ian Rogers
2026-05-19 15:27 ` [PATCH v4 1/2] perf stat: Propagate supported flag to follower cgroup BPF events Ian Rogers
2026-05-19 15:27 ` [PATCH v4 2/2] perf test: Add stat metrics --for-each-cgroup test Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=agv5i_xZCRMK4aid@z2 \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=skanev@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox