mbox series

[v3,0/4] KVM: x86: Use static calls to reduce kvm_pmu_ops overhead

Message ID 20220307115920.51099-1-likexu@tencent.com (mailing list archive)
Headers show
Series KVM: x86: Use static calls to reduce kvm_pmu_ops overhead | expand

Message

Like Xu March 7, 2022, 11:59 a.m. UTC
Hi,

This is a successor to the previous patch set [1] from Jason Baron, which
converts kvm_pmu_ops to use static_call. A typical perf use case [2] for
an Intel guest shows good performance gains (results are in patch 0004).

V2 -> V3 Changelog:
- Refine commit messages for __initdata; (Sean)
- Merge the logic of _defining_ and _update_; (Sean)
- Drop EXPORT_SYMBOL_GPL(kvm_pmu_ops); (Sean)
- Drop the _NULL() variant in the kvm-x86-*-ops.h; (Thanks to Paolo and Sean)
- Drop to export kvm_pmu_is_valid_msr() for nVMX; (Thanks to Sean)
- Based on the kvm/queue;

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

Please note checkpatch.pl complains a lot about KVM_X86_*_OP macros:
- WARNING: macros should not use a trailing semicolon
- ERROR: Macros with multiple statements should be enclosed in a do - while loop
which could be addressed as a one-time follow-up if needed.

Previous:
https://lore.kernel.org/kvm/20211108111032.24457-1-likexu@tencent.com/

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

Thanks,

Like Xu (4):
  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 tag as __initdata
  KVM: x86: Use static calls to reduce kvm_pmu_ops overhead

 arch/x86/include/asm/kvm-x86-pmu-ops.h | 31 +++++++++++++++++
 arch/x86/include/asm/kvm_host.h        | 17 +--------
 arch/x86/kvm/pmu.c                     | 48 +++++++++++++++-----------
 arch/x86/kvm/pmu.h                     |  9 ++++-
 arch/x86/kvm/svm/pmu.c                 |  2 +-
 arch/x86/kvm/svm/svm.c                 |  2 +-
 arch/x86/kvm/vmx/pmu_intel.c           |  2 +-
 arch/x86/kvm/vmx/vmx.c                 |  2 +-
 arch/x86/kvm/x86.c                     | 23 ++++++++++++
 9 files changed, 94 insertions(+), 42 deletions(-)
 create mode 100644 arch/x86/include/asm/kvm-x86-pmu-ops.h

Comments

Like Xu March 21, 2022, 1:55 p.m. UTC | #1
Knock knock, do we have any more comments on this patch set ?

On 7/3/2022 7:59 pm, Like Xu wrote:
> Hi,
> 
> This is a successor to the previous patch set [1] from Jason Baron, which
> converts kvm_pmu_ops to use static_call. A typical perf use case [2] for
> an Intel guest shows good performance gains (results are in patch 0004).
> 
> V2 -> V3 Changelog:
> - Refine commit messages for __initdata; (Sean)
> - Merge the logic of _defining_ and _update_; (Sean)
> - Drop EXPORT_SYMBOL_GPL(kvm_pmu_ops); (Sean)
> - Drop the _NULL() variant in the kvm-x86-*-ops.h; (Thanks to Paolo and Sean)
> - Drop to export kvm_pmu_is_valid_msr() for nVMX; (Thanks to Sean)
> - Based on the kvm/queue;
> 
> 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
> 
> Please note checkpatch.pl complains a lot about KVM_X86_*_OP macros:
> - WARNING: macros should not use a trailing semicolon
> - ERROR: Macros with multiple statements should be enclosed in a do - while loop
> which could be addressed as a one-time follow-up if needed.
> 
> Previous:
> https://lore.kernel.org/kvm/20211108111032.24457-1-likexu@tencent.com/
> 
> [1] https://lore.kernel.org/lkml/cover.1610680941.git.jbaron@akamai.com/
> [2] perf record -e branch-instructions -e branch-misses \
> -e cache-misses -e cache-references -e cpu-cycles \
> -e instructions ./workload
> 
> Thanks,
> 
> Like Xu (4):
>    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 tag as __initdata
>    KVM: x86: Use static calls to reduce kvm_pmu_ops overhead
> 
>   arch/x86/include/asm/kvm-x86-pmu-ops.h | 31 +++++++++++++++++
>   arch/x86/include/asm/kvm_host.h        | 17 +--------
>   arch/x86/kvm/pmu.c                     | 48 +++++++++++++++-----------
>   arch/x86/kvm/pmu.h                     |  9 ++++-
>   arch/x86/kvm/svm/pmu.c                 |  2 +-
>   arch/x86/kvm/svm/svm.c                 |  2 +-
>   arch/x86/kvm/vmx/pmu_intel.c           |  2 +-
>   arch/x86/kvm/vmx/vmx.c                 |  2 +-
>   arch/x86/kvm/x86.c                     | 23 ++++++++++++
>   9 files changed, 94 insertions(+), 42 deletions(-)
>   create mode 100644 arch/x86/include/asm/kvm-x86-pmu-ops.h
>