Re: [PATCH 2/4] KVM: document memory barriers for kvm->vcpus/kvm->online_vcpus

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

 



Am 29.07.2015 um 15:28 schrieb Paolo Bonzini:
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
>  include/linux/kvm_host.h | 4 ++++
>  virt/kvm/kvm_main.c      | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index bd1097a95704..81089cf1f0c1 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -427,6 +427,10 @@ struct kvm {
> 
>  static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
>  {
> +	/* Pairs with smp_wmb() in kvm_vm_ioctl_create_vcpu, in case
> +	 * the caller has read kvm->online_vcpus before (as is the case
> +	 * for kvm_for_each_vcpu, for example).
> +	 */
>  	smp_rmb();

Hmmm, wouldnt something like smp_mb__after_atomic

>  	return kvm->vcpus[i];
>  }
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 8dc4828f623f..093b3d10b411 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2206,6 +2206,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
>  	}
> 
>  	kvm->vcpus[atomic_read(&kvm->online_vcpus)] = vcpu;

and  smp_mb__before_atomic

be the better function?


> +
> +	/* Pairs with smp_rmb() in kvm_get_vcpu.  */
>  	smp_wmb();
>  	atomic_inc(&kvm->online_vcpus);
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux