From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 875083AC0E7 for ; Mon, 18 May 2026 22:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779142955; cv=none; b=l5thwH8GJwPRlbXxHWLJUqOveha8i5mp4ubXa/8FudIe60qTv6YM6zSkV6HDti7npTL3Z34zncJ1G0mRKMQDLJ5xIgJfNUHCul35r0OFzaLUsLynTVHVIbzwUfXbAltsidITbXSh9Dt6QrYKXyIy/rXSyL4o/kaEcL7Cj/5iVEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779142955; c=relaxed/simple; bh=Dm1dRXMcj8LHggSUomlhbdBytPSZTwFogeXZK3/CgVE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=AR02WLrPp3/NgeVM2FUMwosSLR1k9FmWnNRtv2HDO44Mv4knAuq3626YRUXa16OAvGT1iaAkTqLu4H3hp7MldVm4q4mLoyxRUnsW+USlbdJ16Ug3hVR5Y7SQp0j7HmxHCo+qEEJUItjiEuNPx6zN3+SsttgpRZqK6qSMH5BVKoY= 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=aLNstwaF; arc=none smtp.client-ip=74.125.82.74 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="aLNstwaF" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1353ac304f3so5143425c88.0 for ; Mon, 18 May 2026 15:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779142954; x=1779747754; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=rpNAlzgW5SSa1ZsBC1HKHkIDD3KLaNZAgkWCJbzVU4w=; b=aLNstwaF7hfN/VrUghmetjjL4iu0RB0HRppQN7ceM1wztPcn1rXHhlnJ6+6B1xz0mA zqvGUkjJm2kNn10efiacY4q/jfsaFuNX09wsHPcjm1rkVnbZDtPga84puiudWDaciDO/ 2fl6wibUSZxhnkKcAhhQgBR21kRE27svxTo78ig6k8vwWgcnfv6UvEOEvhCjyMgn5LKE ja0VUgkLEV3fEprHOOezY0x5GLBfxEXA5OVAivKaaEHsNzM1crti0PeqjU1E2HEI/Zr/ 19+hVr7zhSudbVbs0Hwm3dQpsQI18DyKrlMWgG0NPPooYk1SK/c6BCJMwqQitBVagWBq E0aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779142954; x=1779747754; h=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=oQAOVj4j+XF2A4mHzVjTzb2h6TN+rqhRy1+xxgDtfjafREBhCg5wOD8FfoMpvzZX79 ppFrSKLhmCiCvq3C6l7PRJeZJjQo4oaoBBCwnCiax0VgC2ySd1QukJtQkNXs+DmV4Rmj UXkoiQwWamSTJkM6ErbvMKqvwPlSCvoAUaCIoKGNI3g6UL3NSPFy+qbFmAWp0+MyumAU 17cONXGhsWcgM1gwfovePP8pi+X6OqsRxjxdor+gB8wHAAkFjQRIUS5gwSSs7zi7DF+3 7wW6OzDIVv/wuw/C3oMHO7okFfrDS8IcUAvEpQCyEgXZSUEK7Ys7MSwXgmxRF7L9Amqd 156Q== X-Forwarded-Encrypted: i=1; AFNElJ/zFWdas43SMe67PXS6njXyUd6T9Z1TKqIDXVyIxZrFf6TPVuKrWWSMn3GEm9ZCgLl0Vw94Qx2SZzbx+8o=@vger.kernel.org X-Gm-Message-State: AOJu0YzOchx0WRedLEhaRBWffEarUCMYeO6wCs3dRXbsW/DjQE01t+yr 1CaM5VGCG/BRPwjnzSTcUjlFPXKU9r6ycYN9P1ea6BHHupPaweauW4m4+yIkoDF672eMehiLMo2 Zi+sXdqMtAA== X-Received: from dlan21-n2.prod.google.com ([2002:a05:7022:eb55:20b0:132:8d92:4d72]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:2586:b0:12c:856:ddcc with SMTP id a92af1059eb24-1350474133dmr7772190c88.27.1779142953579; Mon, 18 May 2026 15:22:33 -0700 (PDT) Date: Mon, 18 May 2026 15:22:27 -0700 In-Reply-To: <20260518222228.3027004-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: <20260518222228.3027004-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.631.ge1b05301d1-goog Message-ID: <20260518222228.3027004-2-irogers@google.com> Subject: [PATCH v1 1/2] perf stat: Propagate supported flag to follower cgroup BPF events From: Ian Rogers To: skanev@google.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org 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