From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8757E311C2D for ; Tue, 19 May 2026 05:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779166933; cv=none; b=bY9adBJY0j8/H8ZpQ3PRmdIGNGyR0rLgzajaUE9MaVAfQrzZaLTHvDD6I0BHwhMa/xep1lGNn4c4FNaDm0fyTq9+i3oBmpU2K5X9wp2AbEVMxaSvxT6kMuUMU5qsUDI2SjbtXvYoTmQVimibvb5RTpS2Sa6clNvGA7i0xlrGhTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779166933; c=relaxed/simple; bh=Dm1dRXMcj8LHggSUomlhbdBytPSZTwFogeXZK3/CgVE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gEGnYtt78XXfkkfS2yO+JHz8+FGHsZKMAIHFZUIXtGBnAt/aVdnFDqKgSBzKj5OfEeDKtvJ9FnFk0o4O935l5UacoekK8kYIN/Kym8eIRr/D2byxq6rZxvu0aqbXX+UM7N3U0bKqhksnn58nsiyBNmmKwwR5KvhmIBsCm2GDqjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BgdugCJh; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BgdugCJh" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-12dba1e866dso2175372c88.1 for ; Mon, 18 May 2026 22:02:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779166932; x=1779771732; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rpNAlzgW5SSa1ZsBC1HKHkIDD3KLaNZAgkWCJbzVU4w=; b=BgdugCJhpvIOA867XUU95b14UnKvWvo7prRnNNR4sO2jIxEU366vqp9ds+Sayg7u6T ovIKMNfaB/UU0PaqEjhahm+s8y6chsWmfr1iRJrrYOpjONAK8Xq7W02+Pobraz0z5cN5 WXEjLUACldl1PSO9Att16jCyxLeTBoFm3XfcuhuA7spqU1b3bl6fqJkfDIJ1LAK8pccO glMADBToNT5LSIMISVZVpgclUB6Qd4vF8vqmM9mOyjFYU7I6V8tnDljWzyB8cpH9dSaA PbrgRkUeJUVuQpup6bgjzSfEgpmAixIzcBdjzQ42vKr36z4pavzU3r4EDM9RHe784RpY rKQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779166932; x=1779771732; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rpNAlzgW5SSa1ZsBC1HKHkIDD3KLaNZAgkWCJbzVU4w=; b=Y8mljfIrTOC1+zUHLd9dBBE6muKajKFTEBLdg0r3fC43dhQiFLaLmaRNvTImb9M5sT BeGvzKOnJDdbwIh+wQW245rIqci+5FfLymOADVeAvKEe/UHFHuogCKeP+qvz0PwXV0X+ qpEhDU5/Q6xg7Y4NrC28ONKo7fw45o3qnyhG6p+Zhnx65AtkhpnyOisFVI6PYEvPFxfA m/8t3+MXdnHm9hFIO+HrmvtczGC59OLfSFwk/CMvnfmWtAdlq9LqEuIm/Qmu3gpUJn7K U86/rIjegBYOCWXmUbV4whzvCnQoHh12ziA7V4rOtUGEcdmYPvhNyWNnpTJ12sgKLfAR 3Bkw== X-Forwarded-Encrypted: i=1; AFNElJ9/f/MylVk2IQWPQAjtPFV6wejT3UsvpifYoBE5NSeEK0VzDf+ulcAt3vR6EtlaTWJqNXV1yUSFA0B6FPc=@vger.kernel.org X-Gm-Message-State: AOJu0Yxytr+WufHPQvxat1kRAHwO3p1DnNX1vmQcAGCbZkrKvppSP+NR dgvU+398rUDjVHf4QLOjaPn6HYlrhtDBZSQxv+zSkCJg4gDhS+CyhEtuBCHncT7jFe7xw8mCyzF +NQlzXJcknw== X-Received: from dlbrh6.prod.google.com ([2002:a05:7022:f306:b0:12c:1f83:7b4c]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:6b8f:b0:135:3983:2131 with SMTP id a92af1059eb24-135398321e5mr4565827c88.21.1779166931554; Mon, 18 May 2026 22:02:11 -0700 (PDT) Date: Mon, 18 May 2026 22:01:49 -0700 In-Reply-To: <20260519050150.3144907-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260519015108.3094513-1-irogers@google.com> <20260519050150.3144907-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.631.ge1b05301d1-goog Message-ID: <20260519050150.3144907-2-irogers@google.com> Subject: [PATCH v3 1/2] perf stat: Propagate supported flag to follower cgroup BPF events From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: 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 Content-Type: text/plain; charset="UTF-8" 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 Assisted-by: Antigravity:gemini-3-flash Signed-off-by: Ian Rogers --- 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