public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Xu Yilun <yilun.xu@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Yan Zhao <yan.y.zhao@intel.com>,
	Friedrich Weber <f.weber@proxmox.com>,
	 Kai Huang <kai.huang@intel.com>,
	Yuan Yao <yuan.yao@linux.intel.com>,
	 Yu Zhang <yu.c.zhang@linux.intel.com>,
	Chao Peng <chao.p.peng@linux.intel.com>,
	 Fuad Tabba <tabba@google.com>,
	Michael Roth <michael.roth@amd.com>,
	 Isaku Yamahata <isaku.yamahata@intel.com>,
	David Matlack <dmatlack@google.com>
Subject: Re: [PATCH v4 1/4] KVM: x86/mmu: Retry fault before acquiring mmu_lock if mapping is changing
Date: Mon, 19 Feb 2024 08:18:12 -0800	[thread overview]
Message-ID: <ZdN_RM2awyNyKiZu@google.com> (raw)
In-Reply-To: <ZdDGooxx/a+sAzmq@yilunxu-OptiPlex-7050>

On Sat, Feb 17, 2024, Xu Yilun wrote:
> >  static int kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
> >  			   unsigned int access)
> >  {
> > +	struct kvm_memory_slot *slot = fault->slot;
> >  	int ret;
> >  
> >  	fault->mmu_seq = vcpu->kvm->mmu_invalidate_seq;
> >  	smp_rmb();
> >  
> > +	/*
> > +	 * Check for a relevant mmu_notifier invalidation event before getting
> > +	 * the pfn from the primary MMU, and before acquiring mmu_lock.
> > +	 *
> > +	 * For mmu_lock, if there is an in-progress invalidation and the kernel
> > +	 * allows preemption, the invalidation task may drop mmu_lock and yield
> > +	 * in response to mmu_lock being contended, which is *very* counter-
> > +	 * productive as this vCPU can't actually make forward progress until
> > +	 * the invalidation completes.
> > +	 *
> > +	 * Retrying now can also avoid unnessary lock contention in the primary
> > +	 * MMU, as the primary MMU doesn't necessarily hold a single lock for
> > +	 * the duration of the invalidation, i.e. faulting in a conflicting pfn
> > +	 * can cause the invalidation to take longer by holding locks that are
> > +	 * needed to complete the invalidation.
> > +	 *
> > +	 * Do the pre-check even for non-preemtible kernels, i.e. even if KVM
> > +	 * will never yield mmu_lock in response to contention, as this vCPU is
> > +	 * *guaranteed* to need to retry, i.e. waiting until mmu_lock is held
> > +	 * to detect retry guarantees the worst case latency for the vCPU.
> > +	 */
> > +	if (!slot &&
> 
> typo?   if (slot &&

Ugh, and bad testing on my end.

  reply	other threads:[~2024-02-19 16:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 22:28 [PATCH v4 0/4] KVM: x86/mmu: Pre-check for mmu_notifier retry Sean Christopherson
2024-02-09 22:28 ` [PATCH v4 1/4] KVM: x86/mmu: Retry fault before acquiring mmu_lock if mapping is changing Sean Christopherson
2024-02-17 14:45   ` Xu Yilun
2024-02-19 16:18     ` Sean Christopherson [this message]
2024-02-09 22:28 ` [PATCH v4 2/4] KVM: x86/mmu: Move private vs. shared check above slot validity checks Sean Christopherson
2024-02-09 22:28 ` [PATCH v4 3/4] KVM: x86/mmu: Move slot checks from __kvm_faultin_pfn() to kvm_faultin_pfn() Sean Christopherson
2024-02-19  3:44   ` Yan Zhao
2024-02-19  9:12     ` Huang, Kai
2024-02-19 19:44     ` Sean Christopherson
2024-02-20  6:54       ` Yan Zhao
2024-02-21  2:10         ` Sean Christopherson
2024-02-09 22:28 ` [PATCH v4 4/4] KVM: x86/mmu: Handle no-slot faults at the beginning of kvm_faultin_pfn() Sean Christopherson
2024-02-14 13:17 ` [PATCH v4 0/4] KVM: x86/mmu: Pre-check for mmu_notifier retry Friedrich Weber

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=ZdN_RM2awyNyKiZu@google.com \
    --to=seanjc@google.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dmatlack@google.com \
    --cc=f.weber@proxmox.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=tabba@google.com \
    --cc=yan.y.zhao@intel.com \
    --cc=yilun.xu@linux.intel.com \
    --cc=yu.c.zhang@linux.intel.com \
    --cc=yuan.yao@linux.intel.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