-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM: x86: Use static calls to reduce kvm_pmu_ops overhead
Use static calls to improve kvm_pmu_ops performance, following the same pattern and naming scheme used by kvm-x86-ops.h. Here are the worst fenced_rdtsc() cycles numbers for the kvm_pmu_ops functions that is most often called (up to 7 digits of calls) when running a single perf test case in a guest on an ICX 2.70GHz host (mitigations=on): | legacy | static call ------------------------------------------------------------ .pmc_idx_to_pmc | 1304840 | 994872 (+23%) .pmc_is_enabled | 978670 | 1011750 (-3%) .msr_idx_to_pmc | 47828 | 41690 (+12%) .is_valid_msr | 28786 | 30108 (-4%) Signed-off-by: Like Xu <likexu@tencent.com> [sean: Handle static call updates in pmu.c, tweak changelog] Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20220329235054.3534728-5-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
- Loading branch information
Like Xu
authored and
Paolo Bonzini
committed
Apr 13, 2022
1 parent
34886e7
commit 1921f3a
Showing
2 changed files
with
65 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#if !defined(KVM_X86_PMU_OP) || !defined(KVM_X86_PMU_OP_OPTIONAL) | ||
BUILD_BUG_ON(1) | ||
#endif | ||
|
||
/* | ||
* KVM_X86_PMU_OP() and KVM_X86_PMU_OP_OPTIONAL() are used to help generate | ||
* both DECLARE/DEFINE_STATIC_CALL() invocations and | ||
* "static_call_update()" calls. | ||
* | ||
* KVM_X86_PMU_OP_OPTIONAL() can be used for those functions that can have | ||
* a NULL definition, for example if "static_call_cond()" will be used | ||
* at the call sites. | ||
*/ | ||
KVM_X86_PMU_OP(pmc_perf_hw_id) | ||
KVM_X86_PMU_OP(pmc_is_enabled) | ||
KVM_X86_PMU_OP(pmc_idx_to_pmc) | ||
KVM_X86_PMU_OP(rdpmc_ecx_to_pmc) | ||
KVM_X86_PMU_OP(msr_idx_to_pmc) | ||
KVM_X86_PMU_OP(is_valid_rdpmc_ecx) | ||
KVM_X86_PMU_OP(is_valid_msr) | ||
KVM_X86_PMU_OP(get_msr) | ||
KVM_X86_PMU_OP(set_msr) | ||
KVM_X86_PMU_OP(refresh) | ||
KVM_X86_PMU_OP(init) | ||
KVM_X86_PMU_OP(reset) | ||
KVM_X86_PMU_OP_OPTIONAL(deliver_pmi) | ||
KVM_X86_PMU_OP_OPTIONAL(cleanup) | ||
|
||
#undef KVM_X86_PMU_OP | ||
#undef KVM_X86_PMU_OP_OPTIONAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters