From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Like Xu <like.xu.linux@gmail.com>
Subject: [PATCH 4/4] KVM: Add a comment explaining the directed yield pending interrupt logic
Date: Tue, 9 Jan 2024 16:39:38 -0800 [thread overview]
Message-ID: <20240110003938.490206-5-seanjc@google.com> (raw)
In-Reply-To: <20240110003938.490206-1-seanjc@google.com>
Add a comment to explain why KVM treats vCPUs with pending interrupts as
in-kernel when a vCPU wants to yield to a vCPU that was preempted while
running in kernel mode.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
virt/kvm/kvm_main.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6326852bfb3d..4a9e7513c585 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4089,6 +4089,13 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me, bool yield_to_kernel_mode)
continue;
if (kvm_vcpu_is_blocking(vcpu) && !vcpu_dy_runnable(vcpu))
continue;
+
+ /*
+ * Treat the target vCPU as being in-kernel if it has a
+ * pending interrupt, as the vCPU trying to yield may
+ * be spinning waiting on IPI delivery, i.e. the target
+ * vCPU is in-kernel for the purposes of directed yield.
+ */
if (READ_ONCE(vcpu->preempted) && yield_to_kernel_mode &&
!kvm_arch_dy_has_pending_interrupt(vcpu) &&
!kvm_arch_vcpu_preempted_in_kernel(vcpu))
--
2.43.0.472.g3155946c3a-goog
next prev parent reply other threads:[~2024-01-10 0:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Sean Christopherson [this message]
2024-02-23 1:35 ` [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240110003938.490206-5-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.