Re: [PATCH v1 0/2] Fix RAPL PMU access from non-lead CPUs
From: srinivas pandruvada
Date: Tue Feb 10 2026 - 12:53:31 EST
On Mon, 2026-02-09 at 15:43 -0800, Kuppuswamy Sathyanarayanan wrote:
> This series fixes issues with RAPL PMU event access when using CPUs
> other than the package lead_cpu.
>
> The problem was discovered when turbostat reported zero power values
> when run on a non-lead CPU in the package.
>
> Investigation revealed two issues:
>
> 1. The RAPL MSR driver incorrectly validated that the current CPU
> must
> match the lead CPU of the package when reading from PMU context,
> even
> though package-scoped MSRs are readable from any CPU in the
> package.
>
> 2. The RAPL PMU cpumask only exposed one CPU per package (the
> lead_cpu)
> for both MSR and TPMI interfaces, forcing tools to use that
> specific
> CPU even though package-scoped registers are readable from any CPU
> in the package.
>
> The perf tool avoided issue #1 by checking the cpumask before opening
> events, but turbostat does not perform this validation. The
> restrictive
> cpumask in issue #2 was unnecessary since both MSR and TPMI
> interfaces
> support reads from any CPU in the package for package-scoped
> registers.
>
> These patches:
> - Remove the incorrect CPU validation check in PMU context
> - Expand the PMU cpumask to include all CPUs in each package for both
> MSR and TPMI RAPL interfaces
> - Rename 'atomic' parameter to 'pmu_ctx' for clarity
>
> After these changes, tools can successfully read RAPL events from any
> CPU in the package, matching the architectural capability of the
> hardware for both MSR and TPMI based RAPL implementations.
>
> Testing (PTL & GNR platform):
> - Verified turbostat --no-msr --show power works on all CPUs
> - Verified perf stat -e power/energy-pkg/ works on all CPUs
> - Confirmed /sys/bus/event_source/devices/power/cpumask shows all
> package CPUs instead of just lead_cpu
> - Tested on both MSR-based (PTL) and TPMI-based (GNR) RAPL system
>
> Kuppuswamy Sathyanarayanan (2):
> powercap: intel_rapl: Remove incorrect CPU check in PMU context
> powercap: intel_rapl: Expose all package CPUs in PMU cpumask
>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
> drivers/powercap/intel_rapl_common.c | 21 ++++++++-------------
> drivers/powercap/intel_rapl_msr.c | 12 +++++-------
> include/linux/intel_rapl.h | 2 +-
> 3 files changed, 14 insertions(+), 21 deletions(-)