public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic
@ 2024-01-10  0:39 Sean Christopherson
  2024-01-10  0:39 ` [PATCH 1/4] KVM: Add dedicated arch hook for querying if vCPU was preempted in-kernel Sean Christopherson
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Sean Christopherson @ 2024-01-10  0:39 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, Like Xu

Provide a dedicated helper to query if a *different* vCPU was preempted
in-kernel.  x86's VMX is an oddball and can only check if the vCPU is in
kernel (versus userspace) if the vCPU is loaded on the current pCPU.

The existing kvm_arch_vcpu_in_kernel() "works", but it's an ugly mess as
KVM x86 is forced to check kvm_get_running_vcpu() to effectively undo the
multiplexing.

Note, I was sorely tempted to eliminate kvm_arch_dy_has_pending_interrupt()
and bury that logic in VMX code, but I ultimately decided to keep it as an
arch hook as it's entirely plausible that some other architecture can do
cross-vCPU IRQ checks, and if KVM is going to have the (somewhat dubious
IMO) logic, it's probably best to keep it in common code.

Sean Christopherson (4):
  KVM: Add dedicated arch hook for querying if vCPU was preempted
    in-kernel
  KVM: x86: Rely solely on preempted_in_kernel flag for directed yield
  KVM: x86: Clean up directed yield API for "has pending interrupt"
  KVM: Add a comment explaining the directed yield pending interrupt
    logic

 arch/x86/kvm/x86.c       | 16 +++++++---------
 include/linux/kvm_host.h |  1 +
 virt/kvm/kvm_main.c      | 22 ++++++++++++++++++++--
 3 files changed, 28 insertions(+), 11 deletions(-)


base-commit: 1c6d984f523f67ecfad1083bb04c55d91977bb15
-- 
2.43.0.472.g3155946c3a-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-23  1:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-10  0:39 [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic Sean Christopherson
2024-01-10  0:39 ` [PATCH 1/4] KVM: Add dedicated arch hook for querying if vCPU was preempted in-kernel Sean Christopherson
2024-01-11 12:48   ` Yuan Yao
2024-01-10  0:39 ` [PATCH 2/4] KVM: x86: Rely solely on preempted_in_kernel flag for directed yield Sean Christopherson
2024-01-10  7:55   ` Yuan Yao
2024-01-10 17:13     ` Sean Christopherson
2024-01-11 12:47       ` Yuan Yao
2024-01-10  0:39 ` [PATCH 3/4] KVM: x86: Clean up directed yield API for "has pending interrupt" Sean Christopherson
2024-01-11 12:49   ` Yuan Yao
2024-01-10  0:39 ` [PATCH 4/4] KVM: Add a comment explaining the directed yield pending interrupt logic Sean Christopherson
2024-02-23  1:35 ` [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox