[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4EEE9077.8090006@oss.ntt.co.jp>
Date: Mon, 19 Dec 2011 10:16:39 +0900
From: Takuya Yoshikawa <yoshikawa.takuya@....ntt.co.jp>
To: Liu ping fan <kernelfans@...il.com>
CC: kvm@...r.kernel.org, linux-kernel@...r.kernel.org, avi@...hat.com,
aliguori@...ibm.com, gleb@...hat.com, mtosatti@...hat.com,
jan.kiszka@....de
Subject: Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance
Liu ping fan wrote:
> Suppose the following scene,
> Firstly, creating 10 kvm_vcpu for guest to take the advantage of
> multi-core. Now, reclaiming some of the kvm_vcpu, so we can limit the
> guest's usage of cpu. Then what about the kvm_vcpu unused? Currently
> they are just idle in kernel, but with this patch, we can remove them.
Then why not write it in the changelog?
>>> +void kvm_arch_vcpu_zap(struct work_struct *work)
>>> +{
>>> + struct kvm_vcpu *vcpu = container_of(work, struct kvm_vcpu,
>>> + zap_work);
>>> + struct kvm *kvm = vcpu->kvm;
>>>
>>> - atomic_set(&kvm->online_vcpus, 0);
>>> - mutex_unlock(&kvm->lock);
>>> + kvm_clear_async_pf_completion_queue(vcpu);
>>> + kvm_unload_vcpu_mmu(vcpu);
>>> + kvm_arch_vcpu_free(vcpu);
>>> + kvm_put_kvm(kvm);
>>> }
>>
>> zap is really a good name for this?
>>
> zap = destroy, so I think it is OK.
Stronger than that.
My dictionary says "to destroy sth suddenly and with force."
In the case of shadow pages, I see what the author wanted to mean by "zap".
In your case, the host really destroy a VCPU suddenly?
The guest have to unplug it before, I guess.
If you just mean "destroy", why not use it?
>>> +#define kvm_for_each_vcpu(vcpu, kvm) \
>>> + list_for_each_entry_rcu(vcpu,&kvm->vcpus, list)
>>
>> Is this macro really worth it?
>> _rcu shows readers important information, I think.
>>
> I guest kvm_for_each_vcpu is designed for hiding the details of
> internal implement, and currently it is implemented by array, and my
> patch will change it to linked-list,
> so IMO, we can still hide the details.
Then why are you doing
list_add_rcu(&vcpu->list, &kvm->vcpus);
without introducing kvm_add_vcpu()?
You are just hiding part of the interface.
I believe this kind of incomplete abstraction should not be added.
The original code was complex enough to introduce a macro, but
list_for_each_entry_rcu(vcpu, &kvm->vcpus, list)
is simple and shows clear meaning by itself.
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