Re: [PATCH 4/5] KVM: cpu hotplug support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 30 Jan 2007 14:56:16 -0000
Avi Kivity <[email protected]> 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?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux