From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753487AbbG2NaT (ORCPT ); Wed, 29 Jul 2015 09:30:19 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:36326 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbbG2N3H (ORCPT ); Wed, 29 Jul 2015 09:29:07 -0400 From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: mtosatti@redhat.com, srutherford@google.com, rkrcmar@redhat.com Subject: [PATCH 2/4] KVM: document memory barriers for kvm->vcpus/kvm->online_vcpus Date: Wed, 29 Jul 2015 15:28:56 +0200 Message-Id: <1438176538-26191-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1438176538-26191-1-git-send-email-pbonzini@redhat.com> References: <1438176538-26191-1-git-send-email-pbonzini@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Paolo Bonzini --- 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(); 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; + + /* Pairs with smp_rmb() in kvm_get_vcpu. */ smp_wmb(); atomic_inc(&kvm->online_vcpus); -- 1.8.3.1