All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org,
	yoshikawa.takuya@oss.ntt.co.jp
Subject: Re: [PATCH v2] KVM: Avoid zapping unrelated shadows in __kvm_set_memory_region()
Date: Wed, 11 Apr 2012 11:11:07 +0800	[thread overview]
Message-ID: <4F84F64B.4090704@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120410220503.36efa6bfb776e741ba076115@gmail.com>

On 04/10/2012 09:05 PM, Takuya Yoshikawa wrote:

 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 29ad6f9..a50f7ba 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -3930,16 +3930,30 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
>  	kvm_flush_remote_tlbs(kvm);
>  }
> 
> -void kvm_mmu_zap_all(struct kvm *kvm)
> +/**
> + * kvm_mmu_zap_all - zap all shadows which have mappings into a given slot
> + * @kvm: the kvm instance
> + * @slot: id of the target slot
> + *
> + * If @slot is -1, zap all shadow pages.
> + */
> +void kvm_mmu_zap_all(struct kvm *kvm, int slot)
>  {
>  	struct kvm_mmu_page *sp, *node;
>  	LIST_HEAD(invalid_list);
> +	int zapped;
> 
>  	spin_lock(&kvm->mmu_lock);
>  restart:
> -	list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link)
> -		if (kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list))
> -			goto restart;
> +	zapped = 0;
> +	list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) {
> +		if ((slot >= 0) && !test_bit(slot, sp->slot_bitmap))
> +			continue;
> +
> +		zapped |= kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);


You should "goto restart" here like the origin code, also, "safe" version of
list_for_each is not needed.


  reply	other threads:[~2012-04-11  3:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 13:05 [PATCH v2] KVM: Avoid zapping unrelated shadows in __kvm_set_memory_region() Takuya Yoshikawa
2012-04-11  3:11 ` Xiao Guangrong [this message]
2012-04-14  1:12   ` Takuya Yoshikawa
2012-04-16  3:53     ` Xiao Guangrong
2012-04-13 21:33 ` Marcelo Tosatti
2012-04-14  1:01   ` Takuya Yoshikawa
2012-04-16 12:35   ` 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=4F84F64B.4090704@linux.vnet.ibm.com \
    --to=xiaoguangrong@linux.vnet.ibm.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=takuya.yoshikawa@gmail.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /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.