All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: imammedo@redhat.com
Subject: Re: [PATCH 2/3] kvm: commonize allocation of the new memory slots
Date: Mon, 17 Nov 2014 10:49:44 +0900	[thread overview]
Message-ID: <54695438.2060408@lab.ntt.co.jp> (raw)
In-Reply-To: <1415963522-5255-3-git-send-email-pbonzini@redhat.com>

On 2014/11/14 20:12, Paolo Bonzini wrote:
> The two kmemdup invocations can be unified.  I find that the new
> placement of the comment makes it easier to see what happens.

A lot easier to follow the logic.

Reviewed-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>

> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   virt/kvm/kvm_main.c | 28 +++++++++++-----------------
>   1 file changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index c8ff99cc0ccb..7bfc842b96d7 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -865,11 +865,12 @@ int __kvm_set_memory_region(struct kvm *kvm,
>   			goto out_free;
>   	}
>   
> +	slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
> +			GFP_KERNEL);
> +	if (!slots)
> +		goto out_free;
> +
>   	if ((change == KVM_MR_DELETE) || (change == KVM_MR_MOVE)) {
> -		slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
> -				GFP_KERNEL);
> -		if (!slots)
> -			goto out_free;
>   		slot = id_to_memslot(slots, mem->slot);
>   		slot->flags |= KVM_MEMSLOT_INVALID;
>   
> @@ -885,6 +886,12 @@ int __kvm_set_memory_region(struct kvm *kvm,
>   		 * 	- kvm_is_visible_gfn (mmu_check_roots)
>   		 */
>   		kvm_arch_flush_shadow_memslot(kvm, slot);
> +
> +		/*
> +		 * We can re-use the old_memslots from above, the only difference
> +		 * from the currently installed memslots is the invalid flag.  This
> +		 * will get overwritten by update_memslots anyway.
> +		 */
>   		slots = old_memslots;
>   	}
>   
> @@ -892,19 +899,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
>   	if (r)
>   		goto out_slots;
>   
> -	r = -ENOMEM;
> -	/*
> -	 * We can re-use the old_memslots from above, the only difference
> -	 * from the currently installed memslots is the invalid flag.  This
> -	 * will get overwritten by update_memslots anyway.
> -	 */
> -	if (!slots) {
> -		slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
> -				GFP_KERNEL);
> -		if (!slots)
> -			goto out_free;
> -	}
> -
>   	/* actual memory is freed via old in kvm_free_physmem_slot below */
>   	if (change == KVM_MR_DELETE) {
>   		new.dirty_bitmap = NULL;
> 

  parent reply	other threads:[~2014-11-17  1:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14 11:11 [PATCH 0/3] KVM: simplification to the memslots code Paolo Bonzini
2014-11-14 11:12 ` [PATCH 1/3] kvm: memslots: track id_to_index changes during the insertion sort Paolo Bonzini
2014-11-14 13:34   ` Igor Mammedov
2014-11-14 13:35   ` Radim Krčmář
2014-11-14 14:17     ` Igor Mammedov
2014-11-14 14:41       ` Radim Krčmář
2014-11-14 14:44         ` Paolo Bonzini
2014-11-14 14:29     ` Paolo Bonzini
2014-11-14 14:44       ` Radim Krčmář
2014-11-14 11:12 ` [PATCH 2/3] kvm: commonize allocation of the new memory slots Paolo Bonzini
2014-11-14 14:21   ` Igor Mammedov
2014-11-17  1:49   ` Takuya Yoshikawa [this message]
2014-11-14 11:12 ` [PATCH 3/3] kvm: simplify update_memslots invocation Paolo Bonzini
2014-11-14 14:24   ` Igor Mammedov
2014-11-17  1:56 ` [PATCH 0/3] KVM: simplification to the memslots code Takuya Yoshikawa
2014-11-17  9:23   ` Paolo Bonzini
2014-11-17  9:30     ` Takuya Yoshikawa

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=54695438.2060408@lab.ntt.co.jp \
    --to=yoshikawa_takuya_b1@lab.ntt.co.jp \
    --cc=imammedo@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@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.