All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [patch 1/3] KVM: MMU: collapse remote TLB flushes on root sync
Date: Sun, 26 Oct 2008 13:17:14 +0200	[thread overview]
Message-ID: <490451BA.8040800@redhat.com> (raw)
In-Reply-To: <20081025223243.782692567@localhost.localdomain>

Marcelo Tosatti wrote:
> Instead of flushing remote TLB's at every page resync, do an initial
> pass to write protect the sptes, collapsing the flushes on a single
> remote TLB invalidation.
>
> kernbench is 2.3% faster on 4-way guest. Improvements have been seen
> with other loads such as AIM7.
>
> Avi: feel free to change this if you dislike the style (I do, but can't
> think of anything nicer).
>
>  static void mmu_sync_children(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
>  {
>  	struct sync_walker walker = {
> -		.walker = { .entry = mmu_sync_fn, },
> +		.walker = { .entry = mmu_wprotect_fn,
> +			    .clear_unsync = false, },
>  		.vcpu = vcpu,
> +		.write_protected = false
>  	};
>  
> +	/* collapse the TLB flushes as an optimization */
> +	mmu_unsync_walk(sp, &walker.walker);
> +	if (walker.write_protected)
> +		kvm_flush_remote_tlbs(vcpu->kvm);
> +
> +	walker.walker.entry = mmu_sync_fn;
> +	walker.walker.clear_unsync = true;
> +
>  	while (mmu_unsync_walk(sp, &walker.walker))
>  		cond_resched_lock(&vcpu->kvm->mmu_lock);
>   

We're always doing two passes here, which is a bit sad.  How about 
having a single pass which:

- collects unsync pages into an array
- exits on no more unsync pages or max array size reached

Then, iterate over the array:

- write protect all pages
- flush tlb
- sync pages

Loop until the root is synced.

If the number of pages to sync is typically small, and the array is 
sized to be larger than this, then we only walk the pagetables once.

btw, our walkers are a bit awkward (though still better than what we had 
before).  If we rewrite them into for_each style iterators, the code 
could become cleaner and shorter.

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


  reply	other threads:[~2008-10-26 11:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-25 22:31 [patch 0/3] oos shadow optimizations Marcelo Tosatti
2008-10-25 22:31 ` [patch 1/3] KVM: MMU: collapse remote TLB flushes on root sync Marcelo Tosatti
2008-10-26 11:17   ` Avi Kivity [this message]
2008-10-29 23:26     ` Marcelo Tosatti
2008-10-30 10:04       ` Avi Kivity
2008-10-31 19:30         ` Marcelo Tosatti
2008-10-25 22:31 ` [patch 2/3] KVM: MMU: skip global pgtables on sync due to cr3 switch Marcelo Tosatti
2008-10-26 11:27   ` Avi Kivity
2008-10-31 19:36     ` Marcelo Tosatti
2008-10-31 19:43       ` Avi Kivity
2008-10-31 19:50         ` Marcelo Tosatti
2008-10-31 19:59           ` Avi Kivity
2008-10-25 22:31 ` [patch 3/3] KVM: MMU: prepopulate the shadow on invlpg Marcelo Tosatti
2008-10-26 11:48   ` Avi Kivity
2008-10-31 19:47     ` Marcelo Tosatti
2008-10-31 19:58       ` Avi Kivity
2008-10-31 22:33         ` Marcelo Tosatti
2008-11-02  8:39           ` Avi Kivity
2008-11-02 16:08             ` Marcelo Tosatti
2008-11-02 16:14               ` Avi Kivity

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=490451BA.8040800@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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 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.