lkml.org 
[lkml]   [2023]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 07/12] KVM: x86/cpuid: Use fast return for cpuid "0xa" leaf when !enable_pmu
    Date
    From: Like Xu <likexu@tencent.com>

    Add an explicit !enable_pmu check as relying on kvm_pmu_cap to be
    zeroed isn't obvious. Although when !enable_pmu, KVM will have
    zero-padded kvm_pmu_cap to do subsequent cpuid leaf assignments,
    one extra branch instruction saves a few subsequent zero-assignment
    instructions, speeding things up a bit.

    Suggested-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Like Xu <likexu@tencent.com>
    ---
    arch/x86/kvm/cpuid.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
    index 2a9f1e200dbc..b0bb5f9f5307 100644
    --- a/arch/x86/kvm/cpuid.c
    +++ b/arch/x86/kvm/cpuid.c
    @@ -944,7 +944,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
    union cpuid10_eax eax;
    union cpuid10_edx edx;

    - if (!static_cpu_has(X86_FEATURE_ARCH_PERFMON)) {
    + if (!enable_pmu || !static_cpu_has(X86_FEATURE_ARCH_PERFMON)) {
    entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
    break;
    }
    --
    2.39.1
    \
     
     \ /
      Last update: 2023-03-27 00:21    [W:4.100 / U:0.544 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site