kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Chao Gao <chao.gao@intel.com>
Cc: Kenta Ishiguro <kentaishiguro@sslab.ics.keio.ac.jp>,
	pbonzini@redhat.com,  kvm@vger.kernel.org, vkuznets@redhat.com
Subject: Re: [RFC] Para-virtualized TLB flush for PV-waiting vCPUs
Date: Tue, 21 Jan 2025 12:59:54 -0800	[thread overview]
Message-ID: <Z5AKygcUcmnEtm0d@google.com> (raw)
In-Reply-To: <Z43n5J+a3BPqTBsP@intel.com>

On Mon, Jan 20, 2025, Chao Gao wrote:
> On Tue, Jan 07, 2025 at 12:56:52AM +0900, Kenta Ishiguro wrote:
> >In oversubscribed environments, the latency of flushing the remote TLB can
> >become significant when the destination virtual CPU (vCPU) is the waiter
> >of a para-virtualized queued spinlock that halts with interrupts disabled.
> >This occurs because the waiter does not respond to remote function call
> >requests until it releases the spinlock. As a result, the source vCPU
> >wastes CPU time performing busy-waiting for a response from the
> >destination vCPU.
> >
> >To mitigate this issue, this patch extends the target of the PV TLB flush
> >to include vCPUs that are halting to wait on the PV qspinlock. Since the
> >PV qspinlock waiters voluntarily yield before being preempted by KVM,
> >their state does not get preempted, and the current PV TLB flush overlooks
> >them. This change allows vCPUs to bypass waiting for PV qspinlock waiters
> >during TLB shootdowns.
> 
> This doesn't seem to be a KVM-specific problem; other hypervisors should
> have the same problem. So, I think we can implement a more generic solution
> w/o involving the hypervisor. e.g., the guest can track which vCPUs are
> waiting on PV qspinlock, delay TLB flush on them and have those vCPUs
> perform TLB flush after they complete their wait (e.g., right after the
> halt() in kvm_wait()).

I don't think that works though.  E.g. what if the vCPU takes an NMI (guest NMI)
while waiting on the spinlock, and the NMI handler accesses the virtual address
that was supposed to be flushed?

The PV approach works because the hypervisor can guarantee the flush will occur
before the vCPU can run *any* code.

      reply	other threads:[~2025-01-21 20:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06 15:56 [RFC] Para-virtualized TLB flush for PV-waiting vCPUs Kenta Ishiguro
2025-01-17 21:34 ` Sean Christopherson
2025-01-19 16:27   ` Kenta Ishiguro
2025-01-21 21:35     ` Sean Christopherson
2025-01-20  6:06 ` Chao Gao
2025-01-21 20:59   ` Sean Christopherson [this message]

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=Z5AKygcUcmnEtm0d@google.com \
    --to=seanjc@google.com \
    --cc=chao.gao@intel.com \
    --cc=kentaishiguro@sslab.ics.keio.ac.jp \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).