All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Avi Kivity <avi@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	KVM list <kvm@vger.kernel.org>
Subject: Re: [PATCH 7/7] KVM: MMU: don't walk every parent pages while mark unsync
Date: Mon, 14 Jun 2010 19:07:08 -0300	[thread overview]
Message-ID: <20100614220708.GA8658@amt.cnet> (raw)
In-Reply-To: <4C123B93.7060803@cn.fujitsu.com>

On Fri, Jun 11, 2010 at 09:35:15PM +0800, Xiao Guangrong wrote:
> While we mark the parent's unsync_child_bitmap, if the parent is already
> unsynced, it no need walk it's parent, it can reduce some unnecessary
> workload
> 
> Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
> ---
>  arch/x86/kvm/mmu.c |   61 ++++++++++++++-------------------------------------
>  1 files changed, 17 insertions(+), 44 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index eb20682..a92863f 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -175,7 +175,7 @@ struct kvm_shadow_walk_iterator {
>  	     shadow_walk_okay(&(_walker));			\
>  	     shadow_walk_next(&(_walker)))
>  
> -typedef int (*mmu_parent_walk_fn) (struct kvm_mmu_page *sp);
> +typedef void (*mmu_parent_walk_fn) (struct kvm_mmu_page *sp, u64 *spte);
>  
>  static struct kmem_cache *pte_chain_cache;
>  static struct kmem_cache *rmap_desc_cache;
> @@ -1024,7 +1024,6 @@ static void mmu_page_remove_parent_pte(struct kvm_mmu_page *sp,
>  	BUG();
>  }
>  
> -
>  static void mmu_parent_walk(struct kvm_mmu_page *sp, mmu_parent_walk_fn fn)
>  {
>  	struct kvm_pte_chain *pte_chain;
> @@ -1034,63 +1033,37 @@ static void mmu_parent_walk(struct kvm_mmu_page *sp, mmu_parent_walk_fn fn)
>  
>  	if (!sp->multimapped && sp->parent_pte) {
>  		parent_sp = page_header(__pa(sp->parent_pte));
> -		fn(parent_sp);
> -		mmu_parent_walk(parent_sp, fn);
> +		fn(parent_sp, sp->parent_pte);
>  		return;
>  	}
> +
>  	hlist_for_each_entry(pte_chain, node, &sp->parent_ptes, link)
>  		for (i = 0; i < NR_PTE_CHAIN_ENTRIES; ++i) {
> -			if (!pte_chain->parent_ptes[i])
> +			u64 *spte = pte_chain->parent_ptes[i];
> +
> +			if (!spte)
>  				break;
> -			parent_sp = page_header(__pa(pte_chain->parent_ptes[i]));
> -			fn(parent_sp);
> -			mmu_parent_walk(parent_sp, fn);
> +			parent_sp = page_header(__pa(spte));
> +			fn(parent_sp, spte);
>  		}
>  }
>  
> -static void kvm_mmu_update_unsync_bitmap(u64 *spte)
> +static void mark_unsync(struct kvm_mmu_page *sp, u64 *spte);
> +static void kvm_mmu_mark_parents_unsync(struct kvm_mmu_page *sp)
>  {
> -	unsigned int index;
> -	struct kvm_mmu_page *sp = page_header(__pa(spte));
> -
> -	index = spte - sp->spt;
> -	if (!__test_and_set_bit(index, sp->unsync_child_bitmap))
> -		sp->unsync_children++;
> -	WARN_ON(!sp->unsync_children);
> +	mmu_parent_walk(sp, mark_unsync);
>  }
>  
> -static void kvm_mmu_update_parents_unsync(struct kvm_mmu_page *sp)
> +static void mark_unsync(struct kvm_mmu_page *sp, u64 *spte)
>  {
> -	struct kvm_pte_chain *pte_chain;
> -	struct hlist_node *node;
> -	int i;
> +	unsigned int index;
>  
> -	if (!sp->parent_pte)
> +	index = spte - sp->spt;
> +	if (__test_and_set_bit(index, sp->unsync_child_bitmap))
>  		return;
> -
> -	if (!sp->multimapped) {
> -		kvm_mmu_update_unsync_bitmap(sp->parent_pte);
> +	if (sp->unsync_children++)
>  		return;

This looks wrong. If the sp has an unrelated children marked as 
unsync (which increased sp->unsync_children), you stop the walk? 

Applied 1-6, thanks.


  parent reply	other threads:[~2010-06-14 22:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-11 13:28 [PATCH 1/7] KVM: MMU: rename 'page' and 'shadow_page' to 'sp' Xiao Guangrong
2010-06-11 13:29 ` [PATCH 2/7] KVM: MMU: cleanup for dirty page judgment Xiao Guangrong
2010-06-11 13:30 ` [PATCH 3/7] KVM: MMU: avoid double write protected in sync page path Xiao Guangrong
2010-06-11 13:31 ` [PATCH 4/7] KVM: MMU: don't mark pte notrap if it's just sync transient Xiao Guangrong
2010-06-11 13:32   ` [PATCH 5/7] KVM: MMU: cleanup for __mmu_unsync_walk() Xiao Guangrong
2010-06-11 13:34     ` [PATCH 6/7] KVM: MMU: clear unsync_child_bitmap completely Xiao Guangrong
2010-06-11 20:14   ` [PATCH 4/7] KVM: MMU: don't mark pte notrap if it's just sync transient Marcelo Tosatti
2010-06-12  2:38     ` Xiao Guangrong
2010-06-11 13:35 ` [PATCH 7/7] KVM: MMU: don't walk every parent pages while mark unsync Xiao Guangrong
2010-06-11 13:43   ` Xiao Guangrong
2010-06-14 22:07   ` Marcelo Tosatti [this message]
2010-06-15  1:32     ` Xiao Guangrong
2010-06-15 20:06       ` Marcelo Tosatti
2010-06-15 20:09       ` 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=20100614220708.GA8658@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.