mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	kvm@vger.kernel.org, yoshikawa_takuya_b1@lab.ntt.co.jp,
	mtosatti@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: Fix memory slot generation updates
Date: Sun, 23 Dec 2012 22:26:45 +0900	[thread overview]
Message-ID: <20121223222645.6dd4519d4d27557d432d0424@gmail.com> (raw)
In-Reply-To: <20121223085506.GM17584@redhat.com>

On Sun, 23 Dec 2012 10:55:06 +0200
Gleb Natapov <gleb@redhat.com> wrote:

> Applied, thanks. What about this small cleanup on to of the patch:

Looks nice!  Hope to see this applied as well.

Thanks,
	Takuya

> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 14cbae8..e45c20c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -702,6 +702,17 @@ static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
>  	return 0;
>  }
>  
> +static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
> +		struct kvm_memslots *slots, struct kvm_memory_slot *new)
> +{
> +	struct kvm_memslots *old_memslots = kvm->memslots;
> +
> +	update_memslots(slots, new, kvm->memslots->generation);
> +	rcu_assign_pointer(kvm->memslots, slots);
> +	synchronize_srcu_expedited(&kvm->srcu);
> +	return old_memslots; 
> +}
> +
>  /*
>   * Allocate some memory and give it an address in the guest physical address
>   * space.
> @@ -820,11 +831,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  		slot = id_to_memslot(slots, mem->slot);
>  		slot->flags |= KVM_MEMSLOT_INVALID;
>  
> -		update_memslots(slots, NULL, kvm->memslots->generation);
> +		old_memslots = install_new_memslots(kvm, slots, NULL);
>  
> -		old_memslots = kvm->memslots;
> -		rcu_assign_pointer(kvm->memslots, slots);
> -		synchronize_srcu_expedited(&kvm->srcu);
>  		/* slot was deleted or moved, clear iommu mapping */
>  		kvm_iommu_unmap_pages(kvm, &old);
>  		/* From this point no new shadow pages pointing to a deleted,
> @@ -868,10 +876,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  		memset(&new.arch, 0, sizeof(new.arch));
>  	}
>  
> -	update_memslots(slots, &new, kvm->memslots->generation);
> -	old_memslots = kvm->memslots;
> -	rcu_assign_pointer(kvm->memslots, slots);
> -	synchronize_srcu_expedited(&kvm->srcu);
> +	old_memslots = install_new_memslots(kvm, slots, &new);
>  
>  	kvm_arch_commit_memory_region(kvm, mem, old, user_alloc);
>  
> --
> 			Gleb.


-- 
Takuya Yoshikawa <takuya.yoshikawa@gmail.com>

  reply	other threads:[~2012-12-23 13:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 15:20 Alex Williamson
2012-12-23  8:55 ` Gleb Natapov
2012-12-23 13:26   ` Takuya Yoshikawa [this message]
2012-12-24 15:31   ` Alex Williamson

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=20121223222645.6dd4519d4d27557d432d0424@gmail.com \
    --to=takuya.yoshikawa@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=yoshikawa_takuya_b1@lab.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome