All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v3 0/8] PMU partitioning driver support
@ 2025-02-13 18:03 Colton Lewis
  2025-02-13 18:03 ` [RFC PATCH v3 1/8] arm64: cpufeature: Add cap for HPMN0 Colton Lewis
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Colton Lewis @ 2025-02-13 18:03 UTC (permalink / raw)
  To: kvm
  Cc: Russell King, Catalin Marinas, Will Deacon, Marc Zyngier,
	Oliver Upton, Joey Gouly, Suzuki K Poulose, Zenghui Yu,
	Mark Rutland, Paolo Bonzini, Shuah Khan, linux-arm-kernel,
	linux-kernel, kvmarm, linux-perf-users, linux-kselftest,
	Colton Lewis

This series introduces support in the KVM and ARM PMUv3 driver for
partitioning PMU counters into two separate ranges by taking advantage
of the MDCR_EL2.HPMN register field.

The advantage of a partitioned PMU would be to allow KVM guests direct
access to a subset of PMU functionality, greatly reducing the overhead
of performance monitoring in guests.

While this feature could be accepted on its own merits, practically
there is a lot more to be done before it will be fully useful, so I'm
sending as an RFC for now.

v3:
* Include cpucap definition for FEAT_HPMN0 to allow for setting HPMN
  to 0

* Include PMU header cleanup provided by Marc [1] with some minor
  changes so compilation works

* Pull functions out of pmu-emul.c that aren't specific to the
  emulated PMU. This and the previous item aren't strictly
  needed but they provide a nicer starting point.

* As suggested by Oliver, start a file for partitioned PMU functions
  and move the reserved_host_counters parameter and MDCR handling into
  KVM so the driver does not have to know about it and we need fewer
  hacks to keep the driver working on 32-bit ARM. This was not a
  complete separation because the driver still needs to start and stop
  the host counters all at once and needs to toggle MDCR_EL2.HPME to
  do that. Introduce kvm_pmu_host_counters_{enable,disable}()
  functions to handle this and define them as no ops on 32-bit ARM.

* As suggested by Oliver, don't limit PMCR.N on emulated PMU. This
  value will be read correctly when the right traps are disabled to
  use the partitioned PMU

v2:
https://lore.kernel.org/kvm/20250208020111.2068239-1-coltonlewis@google.com/

v1:
https://lore.kernel.org/kvm/20250127222031.3078945-1-coltonlewis@google.com/

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/pmu-includes

Colton Lewis (7):
  arm64: cpufeature: Add cap for HPMN0
  arm64: Generate sign macro for sysreg Enums
  KVM: arm64: Reorganize PMU functions
  KVM: arm64: Introduce module param to partition the PMU
  perf: arm_pmuv3: Generalize counter bitmasks
  perf: arm_pmuv3: Keep out of guest counter partition
  KVM: arm64: selftests: Reword selftests error

Marc Zyngier (1):
  KVM: arm64: Cleanup PMU includes

 arch/arm/include/asm/arm_pmuv3.h              |   2 +
 arch/arm64/include/asm/arm_pmuv3.h            |   2 +-
 arch/arm64/include/asm/kvm_host.h             | 199 +++++++-
 arch/arm64/include/asm/kvm_pmu.h              |  47 ++
 arch/arm64/kernel/cpufeature.c                |   8 +
 arch/arm64/kvm/Makefile                       |   2 +-
 arch/arm64/kvm/arm.c                          |   1 -
 arch/arm64/kvm/debug.c                        |  10 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h       |   1 +
 arch/arm64/kvm/pmu-emul.c                     | 464 +-----------------
 arch/arm64/kvm/pmu-part.c                     |  63 +++
 arch/arm64/kvm/pmu.c                          | 454 +++++++++++++++++
 arch/arm64/kvm/sys_regs.c                     |   2 +
 arch/arm64/tools/cpucaps                      |   1 +
 arch/arm64/tools/gen-sysreg.awk               |   1 +
 arch/arm64/tools/sysreg                       |   6 +-
 drivers/perf/arm_pmuv3.c                      |  73 ++-
 include/kvm/arm_pmu.h                         | 204 --------
 include/linux/perf/arm_pmu.h                  |  16 +-
 include/linux/perf/arm_pmuv3.h                |  27 +-
 .../selftests/kvm/arm64/vpmu_counter_access.c |   2 +-
 virt/kvm/kvm_main.c                           |   1 +
 22 files changed, 882 insertions(+), 704 deletions(-)
 create mode 100644 arch/arm64/include/asm/kvm_pmu.h
 create mode 100644 arch/arm64/kvm/pmu-part.c
 delete mode 100644 include/kvm/arm_pmu.h


base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
--
2.48.1.601.g30ceb7b040-goog

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-03-27  9:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 18:03 [RFC PATCH v3 0/8] PMU partitioning driver support Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 1/8] arm64: cpufeature: Add cap for HPMN0 Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 2/8] arm64: Generate sign macro for sysreg Enums Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 3/8] KVM: arm64: Cleanup PMU includes Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 4/8] KVM: arm64: Reorganize PMU functions Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 5/8] KVM: arm64: Introduce module param to partition the PMU Colton Lewis
2025-02-13 18:26   ` Colton Lewis
2025-03-24 14:53   ` James Clark
2025-03-25 18:32     ` Colton Lewis
2025-03-26 17:38       ` James Clark
2025-03-26 20:40         ` Oliver Upton
2025-03-27  9:18           ` James Clark
2025-02-13 18:03 ` [RFC PATCH v3 6/8] perf: arm_pmuv3: Generalize counter bitmasks Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 7/8] perf: arm_pmuv3: Keep out of guest counter partition Colton Lewis
2025-03-24 14:52   ` James Clark
2025-03-25 18:52     ` Colton Lewis
2025-02-13 18:03 ` [RFC PATCH v3 8/8] KVM: arm64: selftests: Reword selftests error Colton Lewis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.