diff options
author | Akihiko Odaki <akihiko.odaki@daynix.com> | 2025-03-15 12:12:11 +0300 |
---|---|---|
committer | Oliver Upton <oliver.upton@linux.dev> | 2025-03-17 20:42:22 +0300 |
commit | be5ccac3f15ea6f0e9086a98dc3ee4f15e873ccb (patch) | |
tree | 6c66113e8ad2b43c55c0b97b3b4f56acf34fd6a9 /tools/perf/scripts/python/gecko.py | |
parent | f2aeb7bbd5745fbcf7f0769e29a184e24924b9a9 (diff) | |
download | linux-be5ccac3f15ea6f0e9086a98dc3ee4f15e873ccb.tar.xz |
KVM: arm64: PMU: Assume PMU presence in pmu-emul.c
Many functions in pmu-emul.c checks kvm_vcpu_has_pmu(vcpu). A favorable
interpretation is defensive programming, but it also has downsides:
- It is confusing as it implies these functions are called without PMU
although most of them are called only when a PMU is present.
- It makes semantics of functions fuzzy. For example, calling
kvm_pmu_disable_counter_mask() without PMU may result in no-op as
there are no enabled counters, but it's unclear what
kvm_pmu_get_counter_value() returns when there is no PMU.
- It allows callers without checking kvm_vcpu_has_pmu(vcpu), but it is
often wrong to call these functions without PMU.
- It is error-prone to duplicate kvm_vcpu_has_pmu(vcpu) checks into
multiple functions. Many functions are called for system registers,
and the system register infrastructure already employs less
error-prone, comprehensive checks.
Check kvm_vcpu_has_pmu(vcpu) in callers of these functions instead,
and remove the obsolete checks from pmu-emul.c. The only exceptions are
the functions that implement ioctls as they have definitive semantics
even when the PMU is not present.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20250315-pmc-v5-2-ecee87dab216@daynix.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'tools/perf/scripts/python/gecko.py')
0 files changed, 0 insertions, 0 deletions