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 BD91937CD4F for ; Mon, 18 May 2026 22:22:32 +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=1779142954; cv=none; b=Tv6jSrZkRHb9G3bl1JUQblRY+3lpiMSPsbWeiX27gLM0GK3ZKlB+mL9z/YWlYmcD7OZfa1JsG5P/WLHz/AOy3Ad7az0dyjNTgN7Ct1Gj/RkqWi1SP5MnrERizaftpQ/jWM1OMWtIvOVgmdo7dC8tEJOQvNvdt7gGBcmnRPA99Xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779142954; c=relaxed/simple; bh=TlJhgWkKhiqXDaZxRkMYQd6DC2vKjX1atE0tHNZtVZw=; h=Date:Mime-Version:Message-ID:Subject:From:To:Content-Type; b=NM0fndBJRMs5I/dJhK23wLO26AFqWuKrCip6Pb7bSJo5rEzow5GvKE0kp9m2l94xzewmMSVlUMeEi0A7nuH6Evw5gdoFCbJoGbKI/noRAJRHPF+LkQV4MoBP3EziXujU3dYPsjG9/mbpe3UxHkvoT+sS2LISaaK843G2+BpcrjE= 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=FDhLidd7; 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="FDhLidd7" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1329791f18fso4993109c88.1 for ; Mon, 18 May 2026 15:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779142952; x=1779747752; darn=vger.kernel.org; h=to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=grlNvYptnUgZVyXoTDj3zK3P1b5S8xvbprevPloPEWg=; b=FDhLidd7gv8jSFUgjBcK/hPwF8EpL7+fATY3jmBTGlr4WGmA+m+e+YpdJYeDtdlSGN VsI5YyK4T2Zp6kVPsD8WyGZKLgIJD+qdAPB1stRavMXZf8SXHCX5QkRYKXZdT4tLwI+l vAIB/u6N0DQ2XIOB/G3y/BT+CCaWCSJ1Xrpjv8CSU7rRsasaBWvm5t3oBuLN1vuYIYaA BOW0nnX/7MHoirPjgVZzNjyeKzptr8wk2H1OrFrVf7Aup8epjm6owVnmYT6xvGIQhn2x wD6tgFkLsUPmzPHvM1OARer5eoO4VfIcIQ/VJsz4+ge/YNXVWyul4uKNswajuJd4q0nr AdUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779142952; x=1779747752; h=to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=grlNvYptnUgZVyXoTDj3zK3P1b5S8xvbprevPloPEWg=; b=RKWF1ZyiJIyO7M3lqQyHDGutBn2D6dn/eExryXf/hutbrYGmjhAP4DwcQnN0CyqB03 Udai2VJtxoJPJtfeLapxsFaGPpPy5Jtzr9ugD4OZY5n4jIQPrhBNvPMSmK0IfxAfCVKD acXRwt33WFwUtx0gsrFw3PM8IlPkAbxkOc/ah3A2zUBlVuSggVGSTzj+0EnhBkFNWr0J w7cw1lnDiugE894G4TuYJTYVG2rDJ2J8jJBawgDgJDakJ5EPto4tadKs29WTIo2egq5/ 8gvqHphLE2c1CZyjgs/WsaE7Ktz4RKYVy0BaYt1/C3FC3lv/7n/M4V4Z2k61nx8ZknkD itOw== X-Forwarded-Encrypted: i=1; AFNElJ+IqUSTp3Kj+3eJIkunYwEDP4zjNXKqgJe+qaJsG5PTAJ7myHn1FZV41301NucYYlKUAuiLucDVVwOLab8=@vger.kernel.org X-Gm-Message-State: AOJu0YwcarU/tD2RErMqLGqU/RlMQxgHUjkJbOUGlzypNo1c2cGJ6Y0l XYDvsHiHeMzcT4dkzus16tDvjq4FrksYCV8+4bwb1MxggQ2ctg46bvW0SHz0TkMJ5fgGBdhpVZZ 4vrC2iEHenw== X-Received: from dlbvt1.prod.google.com ([2002:a05:7022:3f81:b0:135:296f:c477]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:ea26:b0:12c:8b9:71d9 with SMTP id a92af1059eb24-1350483ccf4mr7712564c88.27.1779142951553; Mon, 18 May 2026 15:22:31 -0700 (PDT) Date: Mon, 18 May 2026 15:22:26 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.631.ge1b05301d1-goog Message-ID: <20260518222228.3027004-1-irogers@google.com> Subject: [PATCH v1 0/2] Fix cgroup metric association with BPF counters 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" This series fixes an issue where cgroup metrics were not being correctly associated and reported (showing `nan %`) when using BPF counters (i.e., with `--bpf-counters`). The root cause is that cgroup BPF counters only open the "leader" events (for the first cgroup) and leave "follower" events unopened. Unopened events have their `supported` flag set to `false` by default. During metric calculation, `prepare_metric` checks `evsel->supported` and discards the value (setting it to `NAN`) if it is `false`, leading to `nan %` in the output. The first patch fixes this by propagating the `supported` flag from the leader events to the follower events in `bperf_load_program`. The second patch adds a new shell test (`stat_metrics_cgrp.sh`) to permanently cover this scenario (testing both with and without BPF counters) and prevent regressions. Reported-by: Svilen Kanev Ian Rogers (2): perf stat: Propagate supported flag to follower cgroup BPF events perf test: Add stat metrics --for-each-cgroup test tools/perf/tests/shell/stat_metrics_cgrp.sh | 123 ++++++++++++++++++++ tools/perf/util/bpf_counter_cgroup.c | 15 +++ 2 files changed, 138 insertions(+) create mode 100755 tools/perf/tests/shell/stat_metrics_cgrp.sh -- 2.54.0.631.ge1b05301d1-goog