From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH 4/5] KVM: cpu hotplug support Date: Tue, 30 Jan 2007 16:48:29 -0800 Message-ID: <20070130164829.ce7f2f90.akpm@osdl.org> References: <45BF5B96.1070007@qumranet.com> <20070130145616.EFD52A0014@il.qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Avi Kivity Return-path: In-Reply-To: <20070130145616.EFD52A0014-LjA0eNSCdXrQnzwC+xcbyw@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org On Tue, 30 Jan 2007 14:56:16 -0000 Avi Kivity wrote: > +static void decache_vcpus_on_cpu(int cpu) > +{ > + struct kvm *vm; > + struct kvm_vcpu *vcpu; > + int i; > + > + spin_lock(&kvm_lock); > + list_for_each_entry(vm, &vm_list, vm_list) > + for (i = 0; i < KVM_MAX_VCPUS; ++i) { > + vcpu = &vm->vcpus[i]; > + /* > + * If the vcpu is locked, then it is running on some > + * other cpu and therefore it is not cached on the > + * cpu in question. > + * > + * If it's not locked, check the last cpu it executed > + * on. > + */ > + if (mutex_trylock(&vcpu->mutex)) { > + if (vcpu->cpu == cpu) { > + kvm_arch_ops->vcpu_decache(vcpu); > + vcpu->cpu = -1; > + } > + mutex_unlock(&vcpu->mutex); > + } > + } > + spin_unlock(&kvm_lock); > +} The trylock is unpleasing. Perhaps kvm_lock should be a mutex or something? ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV