public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Kai Huang <kai.huang@intel.com>,
	Yuan Yao <yuan.yao@linux.intel.com>,
	 Xu Yilun <yilun.xu@linux.intel.com>
Subject: Re: [PATCH v3] KVM: x86/mmu: Retry fault before acquiring mmu_lock if mapping is changing
Date: Mon, 5 Feb 2024 19:35:15 -0800	[thread overview]
Message-ID: <ZcGo8yr5oYV6Cf2K@google.com> (raw)
In-Reply-To: <ZcGbjstPnwVpR3Jw@yzhao56-desk.sh.intel.com>

On Tue, Feb 06, 2024, Yan Zhao wrote:
> > Just to be super claer, by "repeated faulting", you mean repeated faulting in the
> > primary MMU, correct?
> >
> Yes. Faulting in the primary MMU.
> (Please ignore my typo in return type above :))
> 
> BTW, will you also send the optmization in v1 as below?

No, mainly because I'm not entirely confident that it's safe/correct to loop
there, at least not that "tightly".  At the very least, there would need to be
resched checks, and then probably signal checks, etc.

I'm not opposed to something of this nature if it provides a measurable benefit
to the guest, but it's firmly an "on top" sort of change.

> iff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 1e340098d034..c7617991e290 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -5725,11 +5725,13 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err
>         }
>  
>         if (r == RET_PF_INVALID) {
> -               r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa,
> -                                         lower_32_bits(error_code), false,
> -                                         &emulation_type);
> -               if (KVM_BUG_ON(r == RET_PF_INVALID, vcpu->kvm))
> -                       return -EIO;
> +               do {
> +                       r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa,
> +                                                 lower_32_bits(error_code),
> +                                                 false, &emulation_type);
> +                       if (KVM_BUG_ON(r == RET_PF_INVALID, vcpu->kvm))
> +                               return -EIO;
> +               while (r == RET_PF_RETRY);
>         }
>  
>         if (r < 0)

  reply	other threads:[~2024-02-06  3:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-03  0:35 [PATCH v3] KVM: x86/mmu: Retry fault before acquiring mmu_lock if mapping is changing Sean Christopherson
2024-02-05  0:14 ` Yan Zhao
2024-02-05 18:27   ` Sean Christopherson
2024-02-06  2:38     ` Yan Zhao
2024-02-06  3:35       ` Sean Christopherson [this message]
2024-02-06 13:52 ` 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=ZcGo8yr5oYV6Cf2K@google.com \
    --to=seanjc@google.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yan.y.zhao@intel.com \
    --cc=yilun.xu@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