Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-18 Thread Takuya Yoshikawa
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

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-16 Thread Marcelo Tosatti
On Thu, Dec 15, 2011 at 03:48:38PM +0900, Takuya Yoshikawa wrote: (2011/12/15 13:28), Liu Ping Fan wrote: From: Liu Ping Fanpingf...@linux.vnet.ibm.com Currently, vcpu can be destructed only when kvm instance destroyed. Change this to vcpu's destruction before kvm instance, so vcpu MUST

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-16 Thread Liu ping fan
2011/12/15 Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp: (2011/12/15 13:28), Liu Ping Fan wrote: From: Liu Ping Fanpingf...@linux.vnet.ibm.com Currently, vcpu can be destructed only when kvm instance destroyed. Change this to vcpu's destruction before kvm instance, so vcpu MUST and CAN be

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-15 Thread Xiao Guangrong
On 12/15/2011 02:53 PM, Liu ping fan wrote: +struct kvm_vcpu *kvm_vcpu_get(struct kvm_vcpu *vcpu) +{ + if (vcpu == NULL) + return NULL; + if (atomic_add_unless(vcpu-refcount, 1, 0)) Why do not use atomic_inc()? Also, i think a memory barrier is needed after

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-15 Thread Xiao Guangrong
On 12/15/2011 04:25 PM, Xiao Guangrong wrote: On 12/15/2011 02:53 PM, Liu ping fan wrote: +struct kvm_vcpu *kvm_vcpu_get(struct kvm_vcpu *vcpu) +{ + if (vcpu == NULL) + return NULL; + if (atomic_add_unless(vcpu-refcount, 1, 0)) Why do not use atomic_inc()? Also,

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-15 Thread Gleb Natapov
On Thu, Dec 15, 2011 at 12:28:48PM +0800, Liu Ping Fan wrote: From: Liu Ping Fan pingf...@linux.vnet.ibm.com Currently, vcpu can be destructed only when kvm instance destroyed. Change this to vcpu's destruction before kvm instance, so vcpu MUST and CAN be destroyed before kvm's destroy. I

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-15 Thread Liu ping fan
On Thu, Dec 15, 2011 at 5:10 PM, Gleb Natapov g...@redhat.com wrote: On Thu, Dec 15, 2011 at 12:28:48PM +0800, Liu Ping Fan wrote: From: Liu Ping Fan pingf...@linux.vnet.ibm.com Currently, vcpu can be destructed only when kvm instance destroyed. Change this to vcpu's destruction before kvm

[PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-14 Thread Liu Ping Fan
From: Liu Ping Fan pingf...@linux.vnet.ibm.com Currently, vcpu can be destructed only when kvm instance destroyed. Change this to vcpu's destruction before kvm instance, so vcpu MUST and CAN be destroyed before kvm's destroy. Signed-off-by: Liu Ping Fan pingf...@linux.vnet.ibm.com ---

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-14 Thread Xiao Guangrong
On 12/15/2011 12:28 PM, Liu Ping Fan wrote: --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1833,11 +1833,12 @@ static void kvm_mmu_put_page(struct kvm_mmu_page *sp, u64 *parent_pte) static void kvm_mmu_reset_last_pte_updated(struct kvm *kvm) { - int i; struct

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-14 Thread Takuya Yoshikawa
(2011/12/15 13:28), Liu Ping Fan wrote: From: Liu Ping Fanpingf...@linux.vnet.ibm.com Currently, vcpu can be destructed only when kvm instance destroyed. Change this to vcpu's destruction before kvm instance, so vcpu MUST and CAN be destroyed before kvm's destroy. Could you explain why this

Re: [PATCH v4] kvm: make vcpu life cycle separated from kvm instance

2011-12-14 Thread Liu ping fan
On Thu, Dec 15, 2011 at 1:33 PM, Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com wrote: On 12/15/2011 12:28 PM, Liu Ping Fan wrote: --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1833,11 +1833,12 @@ static void kvm_mmu_put_page(struct kvm_mmu_page *sp, u64 *parent_pte)  static