[PATCH v2 0/7] Use static_call for kvm_pmu_ops

From: Like Xu
Date: Mon Nov 08 2021 - 06:10:47 EST


Hi,

This is a successor to a previous patch set from Jason Baron. Let's convert
kvm_pmu_ops to use static_call. Shows good performance gains for
a typical perf use case [2] in the guest (results in patch 3/3).

V1 -> V2 Changelog:
- Export kvm_pmu_is_valid_msr() for nVMX [Sean]
- Land memcpy() above kvm_ops_static_call_update() [Sean]
- Move the pmu_ops to kvm_x86_init_ops and tagged as __initdata. [Sean]
- Move the kvm_ops_static_call_update() to x86.c [Sean]
- Drop kvm_pmu_ops_static_call_update() [Sean]
- Fix WARNING that macros KVM_X86_OP should not use a trailing semicolon

Previous:
https://lore.kernel.org/kvm/20211103070310.43380-1-likexu@xxxxxxxxxxx/

[1] https://lore.kernel.org/lkml/cover.1610680941.git.jbaron@xxxxxxxxxx/
[2] perf record -e branch-instructions -e branch-misses \
-e cache-misses -e cache-references -e cpu-cycles \
-e instructions ./workload

Thanks,

Like Xu (7):
KVM: x86: Export kvm_pmu_is_valid_msr() for nVMX
KVM: x86: Fix WARNING that macros should not use a trailing semicolon
KVM: x86: Move kvm_ops_static_call_update() to x86.c
KVM: x86: Copy kvm_pmu_ops by value to eliminate layer of indirection
KVM: x86: Move .pmu_ops to kvm_x86_init_ops and tagged as __initdata
KVM: x86: Introduce definitions to support static calls for
kvm_pmu_ops
KVM: x86: Use static calls to reduce kvm_pmu_ops overhead

arch/x86/include/asm/kvm-x86-ops.h | 218 ++++++++++++-------------
arch/x86/include/asm/kvm-x86-pmu-ops.h | 32 ++++
arch/x86/include/asm/kvm_host.h | 14 +-
arch/x86/kvm/pmu.c | 46 +++---
arch/x86/kvm/pmu.h | 9 +-
arch/x86/kvm/svm/pmu.c | 2 +-
arch/x86/kvm/svm/svm.c | 2 +-
arch/x86/kvm/vmx/nested.c | 2 +-
arch/x86/kvm/vmx/pmu_intel.c | 2 +-
arch/x86/kvm/vmx/vmx.c | 2 +-
arch/x86/kvm/x86.c | 16 +-
11 files changed, 199 insertions(+), 146 deletions(-)
create mode 100644 arch/x86/include/asm/kvm-x86-pmu-ops.h

--
2.33.0