public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: Re: [PATCH 4/4] KVM: MMU: Don't touch unsync sp in kvm_mmu_pte_write()
Date: Sun, 26 Sep 2010 15:09:07 +0200	[thread overview]
Message-ID: <4C9F45F3.7000405@redhat.com> (raw)
In-Reply-To: <4C9AC283.3000307@cn.fujitsu.com>

  On 09/23/2010 04:59 AM, Xiao Guangrong wrote:
> On 09/20/2010 11:24 PM, Avi Kivity wrote:
> >   On 09/20/2010 04:21 PM, Xiao Guangrong wrote:
> >>  Gfn may have many shadow pages, when one sp need be synced, we write
> >>  protected sp->gfn and sync this sp but we keep other shadow pages
> >>  asynchronous
> >>
> >>  So, while gfn happen page fault, let it not touches unsync page, the
> >>  unsync
> >>  page only updated at invlpg/flush TLB time
> >>
> >>  @@ -3157,6 +3164,9 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu,
> >>  gpa_t gpa,
> >>
> >>        mask.cr0_wp = mask.cr4_pae = mask.nxe = 1;
> >>        for_each_gfn_indirect_valid_sp(vcpu->kvm, sp, gfn, node) {
> >>  +        if (sp->unsync)
> >>  +            continue;
> >>  +
> >>
> >
> >  Not sure this is a win.  If a gpte is updated from having p=0 to p=1 (or
> >  permissions upgraded), we may not have an invlpg to sync the spte, since
> >  the hardware doesn't require it.  With this change, we may get an extra
> >  #PF.
> >
>
> Avi,
>
> Thanks for your review, i think this case is not too bad since:
>
> 1: This case only impacts local vcpu since if permissions is increased, it's
>     no need send IPT to flush remote vcpu's tlb, so even if we update unsync
>     spte in kvm_mmu_pte_write() path, the #PF still occur on other vcpus.

IIRC, the cpu will re-validate the tlb entry from the page tables before 
issuing a fault, so we won't see a spurious fault.  Not 100% sure.

For !P -> P, there won't be a tlb entry, so 100% there won't be a 
spurious fault.

> 2: If the unsync sp which is updated in kvm_mmu_pte_write() is not using by the
>     vcpu, it will sync automatically after it's loaded.

True, and this is a likely case.

> 3: If the sp is using, update this sp in kvm_mmu_pte_write() will avoid extra #PF,
>     in this case, two(or more) sps have the same gfn, there are mapped in the same
>     page table and with different kinds(unsync/sync), i thinks this case is infrequency.
>     And even we updated it, we can not sure it can be accessed latter,

If it's infrequent, the why do we optimize it?

> So, i think it's better lazily update unsync sp until it's used or the flush time,
> your opinion? :-)
>

Any performance numbers?

To me it seems saving a possible exit is worth extra computation.

-- 
error compiling committee.c: too many arguments to function


      reply	other threads:[~2010-09-26 13:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 14:18 [PATCH 1/4] KVM: MMU: rename 'sp->root_count' to 'sp->active_count' Xiao Guangrong
2010-09-20 14:19 ` [PATCH 2/4] KVM: MMU: support unsync sp out of the protection of 'mmu_lock' Xiao Guangrong
2010-09-20 15:19   ` Avi Kivity
2010-09-23  3:05     ` Xiao Guangrong
2010-09-26 13:02       ` Avi Kivity
2010-09-20 14:20 ` [PATCH 3/4] KVM: MMU: move reserved bits check to FNAME(update_pte) Xiao Guangrong
2010-09-20 14:21 ` [PATCH 4/4] KVM: MMU: Don't touch unsync sp in kvm_mmu_pte_write() Xiao Guangrong
2010-09-20 15:24   ` Avi Kivity
2010-09-23  2:59     ` Xiao Guangrong
2010-09-26 13:09       ` Avi Kivity [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=4C9F45F3.7000405@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=xiaoguangrong@cn.fujitsu.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