From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: MMU: optimize set_spte for page sync
Date: Mon, 24 Nov 2008 13:04:23 +0100 [thread overview]
Message-ID: <20081124120423.GB4379@dmt.cnet> (raw)
In-Reply-To: <4929322D.7050503@redhat.com>
On Sun, Nov 23, 2008 at 12:36:29PM +0200, Avi Kivity wrote:
> Marcelo Tosatti wrote:
>
>> The cost of hash table and memslot lookups are quite significant if the
>> workload is pagetable write intensive resulting in increased mmu_lock
>> contention.
>>
>> @@ -1593,7 +1593,16 @@ static int set_spte(struct kvm_vcpu *vcp
>> spte |= PT_WRITABLE_MASK;
>> - if (mmu_need_write_protect(vcpu, gfn, can_unsync)) {
>> + /*
>> + * Optimization: for pte sync, if spte was writable the hash
>> + * lookup is unnecessary (and expensive). Write protection
>> + * is responsibility of mmu_get_page / kvm_sync_page.
>> + * Same reasoning can be applied to dirty page accounting.
>> + */
>> + if (sync_page && is_writeble_pte(*shadow_pte))
>> + goto set_pte;
>>
>
> What if *shadow_pte points at a different page? Is that possible?
To a different gfn? Then sync_page will have nuked the spte:
if (gpte_to_gfn(gpte) != gfn || !is_present_pte(gpte) ||
!(gpte & PT_ACCESSED_MASK)) {
u64 nonpresent;
..
set_shadow_pte(&sp->spt[i], nonpresent);
}
Otherwise:
/*
* Using the cached information from sp->gfns is safe because:
* - The spte has a reference to the struct page, so the pfn for a given
* gfn can't change unless all sptes pointing to it are nuked first.
next prev parent reply other threads:[~2008-11-24 15:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-21 18:49 KVM: MMU: optimize set_spte for page sync Marcelo Tosatti
2008-11-23 10:36 ` Avi Kivity
2008-11-24 12:04 ` Marcelo Tosatti [this message]
2008-11-24 13:23 ` Marcelo Tosatti
2008-11-25 14:38 ` Avi Kivity
2008-11-25 14:58 ` Marcelo Tosatti
2008-11-26 11:12 ` Avi Kivity
2008-12-09 15:52 ` Marcelo Tosatti
2008-12-10 9:14 ` Avi Kivity
2008-12-10 12:54 ` Marcelo Tosatti
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=20081124120423.GB4379@dmt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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.