mbox series

[V4,0/2] powercap: Introduce TPMI RAPL PMU support

Message ID 20240428092427.24959-1-rui.zhang@intel.com (mailing list archive)
Headers show
Series powercap: Introduce TPMI RAPL PMU support | expand

Message

Zhang, Rui April 28, 2024, 9:24 a.m. UTC
RAPL energy counter MSRs are exposed via perf PMU. But this is done by
separate code which is not part of RAPL framework, and it cannot be
reused by other RAPL Interface drivers like TPMI RAPL.

Introduce two new APIs for PMU support in RAPL framework. This allows
TPMI RAPL PMU support and also makes it possible for future cleanups of
MSR RAPL PMU code.

Changes since V3:
- Fix is_rp_pmu_cpu() return value. (Rafael)
- Following the conversion in other PMU drivers to use
  local64_try_cmpxchg() instead of local64_cmpxchg(). E.g. bcc6ec3d954b
  ("perf/x86/rapl: Use local64_try_cmpxchg in rapl_event_update()"), and
  update with a comment.

Changes since V2:
- drop patch 1/3 and rebase on PM tree bleeding-edge branch.
- fix a regression introduced in patch V2 that RAPL PMU is not
  successfully unregisted when unbinding the device. This causes kernel
  calltrace about duplicate PMU name in sysfs when reloading the module.
  Our unit test cases reproduced this but the test framework failed to
  catch it, and now that problem is also fixed.
- add comment for RAPL PMU implementation details.
- add comment/document for struct rapl_pmu and rapl_package_pmu_data.
- remove unneeded global RAPL PMU cpumask.
- use an array to map RAPL PMU events to RAPL Domains.
- Other minor improvements.

Changes since V1:
- remove the MSR RAPL PMU conversion because it is a separate work that
  can be done later.
- instead of using a flag to indicate the need of PMU support, introduce
  two APIs for the RAPL Interface driver to invoke explicitly.
- minor code/comments/changelog improvements.

thanks,
rui

----------------------------------------------------------------
Zhang Rui (2):
      powercap: intel_rapl: Introduce APIs for PMU support
      powercap: intel_rapl_tpmi: Enable PMU support

 drivers/powercap/intel_rapl_common.c | 582 +++++++++++++++++++++++++++++++++++
 drivers/powercap/intel_rapl_tpmi.c   |   3 +
 include/linux/intel_rapl.h           |  32 ++
 3 files changed, 617 insertions(+)

Comments

Rafael J. Wysocki April 30, 2024, 7:13 p.m. UTC | #1
On Sun, Apr 28, 2024 at 11:24 AM Zhang Rui <rui.zhang@intel.com> wrote:
>
> RAPL energy counter MSRs are exposed via perf PMU. But this is done by
> separate code which is not part of RAPL framework, and it cannot be
> reused by other RAPL Interface drivers like TPMI RAPL.
>
> Introduce two new APIs for PMU support in RAPL framework. This allows
> TPMI RAPL PMU support and also makes it possible for future cleanups of
> MSR RAPL PMU code.
>
> Changes since V3:
> - Fix is_rp_pmu_cpu() return value. (Rafael)
> - Following the conversion in other PMU drivers to use
>   local64_try_cmpxchg() instead of local64_cmpxchg(). E.g. bcc6ec3d954b
>   ("perf/x86/rapl: Use local64_try_cmpxchg in rapl_event_update()"), and
>   update with a comment.
>
> Changes since V2:
> - drop patch 1/3 and rebase on PM tree bleeding-edge branch.
> - fix a regression introduced in patch V2 that RAPL PMU is not
>   successfully unregisted when unbinding the device. This causes kernel
>   calltrace about duplicate PMU name in sysfs when reloading the module.
>   Our unit test cases reproduced this but the test framework failed to
>   catch it, and now that problem is also fixed.
> - add comment for RAPL PMU implementation details.
> - add comment/document for struct rapl_pmu and rapl_package_pmu_data.
> - remove unneeded global RAPL PMU cpumask.
> - use an array to map RAPL PMU events to RAPL Domains.
> - Other minor improvements.
>
> Changes since V1:
> - remove the MSR RAPL PMU conversion because it is a separate work that
>   can be done later.
> - instead of using a flag to indicate the need of PMU support, introduce
>   two APIs for the RAPL Interface driver to invoke explicitly.
> - minor code/comments/changelog improvements.
>
> thanks,
> rui
>
> ----------------------------------------------------------------
> Zhang Rui (2):
>       powercap: intel_rapl: Introduce APIs for PMU support
>       powercap: intel_rapl_tpmi: Enable PMU support
>
>  drivers/powercap/intel_rapl_common.c | 582 +++++++++++++++++++++++++++++++++++
>  drivers/powercap/intel_rapl_tpmi.c   |   3 +
>  include/linux/intel_rapl.h           |  32 ++
>  3 files changed, 617 insertions(+)

Both patches applied as 6.10 material, thanks!