Skip to content

Conversation

@zhang-rui
Copy link
Contributor

Add Perf PMU support for TPMI RAPL

Test:
Tested on GNR/CWF, after the PR, the RAPL perf events become available.

1: powercap: intel_rapl_tpmi: Enable PMU support
2: powercap: intel_rapl: Introduce APIs for PMU support
3: powercap: intel_rapl: Sort header files

@zhang-rui zhang-rui force-pushed the intel-rapl-TPMI-PMU-5.15 branch 2 times, most recently from 1272fb8 to 7f6e663 Compare October 11, 2025 08:27
commit 72b8b94 upstream.

Sort header files alphabetically.

Intel-SIG: commit 72b8b94 powercap: intel_rapl: Sort header files
Add Perf PMU support for TPMI RAPL

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
commit 575024a upstream.

Introduce two new APIs rapl_package_add_pmu()/rapl_package_remove_pmu().

RAPL driver can invoke these APIs to expose its supported energy
counters via perf PMU. The new RAPL PMU is fully compatible with current
MSR RAPL PMU, including using the same PMU name and events
name/id/unit/scale, etc.

For example, use below command
 perf stat -e power/energy-pkg/ -e power/energy-ram/ FOO
to get the energy consumption if power/energy-pkg/ and power/energy-ram/
events are available in the "perf list" output.

This does not introduce any conflict because TPMI RAPL is the only user
of these APIs currently, and it never co-exists with MSR RAPL.

Note that RAPL Packages can be probed/removed dynamically, and the
events supported by each TPMI RAPL device can be different. Thus the
RAPL PMU support is done on demand, which means
1. PMU is registered only if it is needed by a RAPL Package. PMU events
   for unsupported counters are not exposed.
2. PMU is unregistered and registered when a new RAPL Package is probed
   and supports new counters that are not supported by current PMU.
   For example, on a dual-package system using TPMI RAPL, it is possible
   that Package 1 behaves as TPMI domain root and supports Psys domain.
   In this case, register PMU without Psys event when probing Package 0,
   and re-register the PMU with Psys event when probing Package 1.
3. PMU is unregistered when all registered RAPL Packages don't need PMU.

Intel-SIG: commit 575024a powercap: intel_rapl: Introduce APIs for PMU support
Add Perf PMU support for TPMI RAPL

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ Zhang Rui: replace unavailable APIs (guard()/local64_try_cmpxchg()) and amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
commit 963a9ad upstream.

Enable RAPL PMU support for TPMI RAPL driver.

Intel-SIG: commit 963a9ad powercap: intel_rapl_tpmi: Enable PMU support
Add Perf PMU support for TPMI RAPL

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant