[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <555C3A0F.4050501@lab.ntt.co.jp>
Date: Wed, 20 May 2015 16:38:55 +0900
From: Takuya Yoshikawa <yoshikawa_takuya_b1@....ntt.co.jp>
To: Paolo Bonzini <pbonzini@...hat.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
CC: Xiao Guangrong <guangrong.xiao@...ux.intel.com>, rkrcmar@...hat.com
Subject: Re: [PATCH 1/9] KVM: introduce kvm_alloc/free_memslots
On 2015/05/20 2:25, Paolo Bonzini wrote:
> +static void kvm_free_memslots(struct kvm *kvm, struct kvm_memslots *slots)
> +{
> + struct kvm_memory_slot *memslot;
> +
> + if (!slots)
> + return;
> +
> + kvm_for_each_memslot(memslot, slots)
> + kvm_free_memslot(kvm, memslot, NULL);
> +
> + kvfree(slots);
> }
>
> static struct kvm *kvm_create_vm(unsigned long type)
> @@ -472,17 +519,10 @@ static struct kvm *kvm_create_vm(unsigned long type)
> BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
>
> r = -ENOMEM;
> - kvm->memslots = kvm_kvzalloc(sizeof(struct kvm_memslots));
> + kvm->memslots = kvm_alloc_memslots();
> if (!kvm->memslots)
> goto out_err_no_srcu;
>
> - /*
> - * Init kvm generation close to the maximum to easily test the
> - * code of handling generation number wrap-around.
> - */
> - kvm->memslots->generation = -150;
> -
> - kvm_init_memslots_id(kvm);
> if (init_srcu_struct(&kvm->srcu))
> goto out_err_no_srcu;
> if (init_srcu_struct(&kvm->irq_srcu))
> @@ -523,7 +563,7 @@ out_err_no_srcu:
> out_err_no_disable:
> for (i = 0; i < KVM_NR_BUSES; i++)
> kfree(kvm->buses[i]);
> - kvfree(kvm->memslots);
> + kvm_free_memslots(kvm, kvm->memslots);
Newly added code
+ kvm_for_each_memslot(memslot, slots)
+ kvm_free_memslot(kvm, memslot, NULL);
does nothing in effect, but looks better to be here since this
corresponds to kvm_alloc_memslots() part and may be safer for
future changes.
Other changes look like trivial transitions to the new
kvm_alloc/free_memslots.
Reviewed-by: Takuya Yoshikawa <yoshikawa_takuya_b1@....ntt.co.jp>
> kvm_arch_free_vm(kvm);
> return ERR_PTR(r);
> }
Takuya
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists