mbox series

[v4,0/3] KVM/x86: Enhancements to static calls

Message ID 20240507133103.15052-1-wei.w.wang@intel.com (mailing list archive)
Headers show
Series KVM/x86: Enhancements to static calls | expand

Message

Wang, Wei W May 7, 2024, 1:31 p.m. UTC
This patchset introduces the kvm_x86_call() and kvm_pmu_call() macros to
streamline the usage of static calls of kvm_x86_ops and kvm_pmu_ops. The
current static_call() usage is a bit verbose and can lead to code
alignment challenges, and the addition of kvm_x86_ prefix to hooks at the
static_call() sites hinders code readability and navigation. The use of
static_call_cond() is essentially the same as static_call() on x86, so it
is replaced by static_call() to simplify the code. The changes have gone
through my tests (guest launch, a few vPMU tests, live migration tests)
without an issue.

v3->v4 change:
- Rename KVM_X86_CALL() to kvm_x86_call() and KVM_PMU_CALL() to
  kvm_pmu_call() as they resemble functions, so the lower-case style
  looks more readable.

v2->v3 changes:
- Change the KVM_X86_CALL() definition to have the parameters in their
  owen paratheses.
- Update the .get_cpl() hook in pmu.c to use KVM_X86_CALL().
  (it was omitted in v2)

v1->v2 changes:
- Replace static_call_cond() with static_call()
- Rename KVM_X86_SC to KVM_X86_CALL, and updated all the call sites
- Add KVM_PMU_CALL() 
- Add patch 4 and 5 to review the idea of removing KVM_X86_OP_OPTIONAL

Wei Wang (3):
  KVM: x86: Replace static_call_cond() with static_call()
  KVM: x86: Introduce kvm_x86_call() to simplify static calls of
    kvm_x86_ops
  KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of
    kvm_pmu_ops

 arch/x86/include/asm/kvm_host.h |  11 +-
 arch/x86/kvm/cpuid.c            |   2 +-
 arch/x86/kvm/hyperv.c           |   6 +-
 arch/x86/kvm/irq.c              |   2 +-
 arch/x86/kvm/kvm_cache_regs.h   |  10 +-
 arch/x86/kvm/lapic.c            |  42 +++--
 arch/x86/kvm/lapic.h            |   2 +-
 arch/x86/kvm/mmu.h              |   6 +-
 arch/x86/kvm/mmu/mmu.c          |   4 +-
 arch/x86/kvm/mmu/spte.c         |   4 +-
 arch/x86/kvm/pmu.c              |  29 +--
 arch/x86/kvm/smm.c              |  44 ++---
 arch/x86/kvm/trace.h            |  15 +-
 arch/x86/kvm/x86.c              | 322 ++++++++++++++++----------------
 arch/x86/kvm/x86.h              |   2 +-
 arch/x86/kvm/xen.c              |   4 +-
 16 files changed, 259 insertions(+), 246 deletions(-)


base-commit: aec147c18856fa7115e14b9ad6a91c3ed2cf2e19

Comments

Sean Christopherson June 12, 2024, 1:18 a.m. UTC | #1
On Tue, 07 May 2024 21:31:00 +0800, Wei Wang wrote:
> This patchset introduces the kvm_x86_call() and kvm_pmu_call() macros to
> streamline the usage of static calls of kvm_x86_ops and kvm_pmu_ops. The
> current static_call() usage is a bit verbose and can lead to code
> alignment challenges, and the addition of kvm_x86_ prefix to hooks at the
> static_call() sites hinders code readability and navigation. The use of
> static_call_cond() is essentially the same as static_call() on x86, so it
> is replaced by static_call() to simplify the code. The changes have gone
> through my tests (guest launch, a few vPMU tests, live migration tests)
> without an issue.
> 
> [...]

Applied to kvm-x86 static_calls.  I may or may not rebase these commits
depending on what all gets queued for 6.10.  There are already three conflicts
that I know of, but they aren't _that_ annoying.  Yet.  :-)

Thanks!

[1/3] KVM: x86: Replace static_call_cond() with static_call()
      https://github.com/kvm-x86/linux/commit/161827082760
[2/3] KVM: x86: Introduce kvm_x86_call() to simplify static calls of kvm_x86_ops
      https://github.com/kvm-x86/linux/commit/aebed32e4985
[3/3] KVM: x86/pmu: Add kvm_pmu_call() to simplify static calls of kvm_pmu_ops
      https://github.com/kvm-x86/linux/commit/4dbd1f66c5bf

--
https://github.com/kvm-x86/linux/tree/next
Wang, Wei W June 12, 2024, 1:55 a.m. UTC | #2
On Wednesday, June 12, 2024 9:19 AM, Sean Christopherson wrote:
> On Tue, 07 May 2024 21:31:00 +0800, Wei Wang wrote:
> > This patchset introduces the kvm_x86_call() and kvm_pmu_call() macros
> > to streamline the usage of static calls of kvm_x86_ops and
> > kvm_pmu_ops. The current static_call() usage is a bit verbose and can
> > lead to code alignment challenges, and the addition of kvm_x86_ prefix
> > to hooks at the
> > static_call() sites hinders code readability and navigation. The use
> > of
> > static_call_cond() is essentially the same as static_call() on x86, so
> > it is replaced by static_call() to simplify the code. The changes have
> > gone through my tests (guest launch, a few vPMU tests, live migration
> > tests) without an issue.
> >
> > [...]
> 
> Applied to kvm-x86 static_calls.  I may or may not rebase these commits
> depending on what all gets queued for 6.10.  There are already three conflicts
> that I know of, but they aren't _that_ annoying.  Yet.  :-)
> 

OK, thanks. Just let me know whenever you need help with rebasing.
Paolo Bonzini June 12, 2024, 10:19 a.m. UTC | #3
On Wed, Jun 12, 2024 at 3:23 AM Sean Christopherson <seanjc@google.com> wrote:
>
> On Tue, 07 May 2024 21:31:00 +0800, Wei Wang wrote:
> > This patchset introduces the kvm_x86_call() and kvm_pmu_call() macros to
> > streamline the usage of static calls of kvm_x86_ops and kvm_pmu_ops. The
> > current static_call() usage is a bit verbose and can lead to code
> > alignment challenges, and the addition of kvm_x86_ prefix to hooks at the
> > static_call() sites hinders code readability and navigation. The use of
> > static_call_cond() is essentially the same as static_call() on x86, so it
> > is replaced by static_call() to simplify the code. The changes have gone
> > through my tests (guest launch, a few vPMU tests, live migration tests)
> > without an issue.
> >
> > [...]
>
> Applied to kvm-x86 static_calls.  I may or may not rebase these commits
> depending on what all gets queued for 6.10.  There are already three conflicts
> that I know of, but they aren't _that_ annoying.  Yet.  :-)

I think it's best if we apply them directly (i.e. not through a pull
request), on top of everything else in 6.11.

Paolo
Sean Christopherson June 18, 2024, 2:37 p.m. UTC | #4
On Wed, Jun 12, 2024, Paolo Bonzini wrote:
> On Wed, Jun 12, 2024 at 3:23 AM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Tue, 07 May 2024 21:31:00 +0800, Wei Wang wrote:
> > > This patchset introduces the kvm_x86_call() and kvm_pmu_call() macros to
> > > streamline the usage of static calls of kvm_x86_ops and kvm_pmu_ops. The
> > > current static_call() usage is a bit verbose and can lead to code
> > > alignment challenges, and the addition of kvm_x86_ prefix to hooks at the
> > > static_call() sites hinders code readability and navigation. The use of
> > > static_call_cond() is essentially the same as static_call() on x86, so it
> > > is replaced by static_call() to simplify the code. The changes have gone
> > > through my tests (guest launch, a few vPMU tests, live migration tests)
> > > without an issue.
> > >
> > > [...]
> >
> > Applied to kvm-x86 static_calls.  I may or may not rebase these commits
> > depending on what all gets queued for 6.10.  There are already three conflicts
> > that I know of, but they aren't _that_ annoying.  Yet.  :-)
> 
> I think it's best if we apply them directly (i.e. not through a pull
> request), on top of everything else in 6.11.

Works for me.  I'll maintain the branch so that the code stays in -next, and so
that patches that are destined for 6.12+ are built on the new world, and then
post the rebased patches when the time comes.