Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753562AbdIETB5 (ORCPT ); Tue, 5 Sep 2017 15:01:57 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:47295 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752653AbdIETBJ (ORCPT ); Tue, 5 Sep 2017 15:01:09 -0400 From: Davidlohr Bueso To: mingo@redhat.com, peterz@infradead.org, pbonzini@redhat.com Cc: npiggin@gmail.com, paulmck@linux.vnet.ibm.com, dave@stgolabs.net, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 5/6] kvm: Serialize wq active checks in kvm_vcpu_wake_up() Date: Tue, 5 Sep 2017 12:00:21 -0700 Message-Id: <20170905190022.1474-6-dave@stgolabs.net> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170905190022.1474-1-dave@stgolabs.net> References: <20170905190022.1474-1-dave@stgolabs.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 729 Lines: 25 This is a generic call and can be suceptible to races in reading the wq task_list while another task is adding itself to the list. Add a full barrier by using the swq_has_sleeper() helper. Signed-off-by: Davidlohr Bueso --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 4d81f6ded88e..4e76e6d15ce0 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2185,7 +2185,7 @@ bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu) struct swait_queue_head *wqp; wqp = kvm_arch_vcpu_wq(vcpu); - if (swait_active(wqp)) { + if (swq_has_sleeper(wqp)) { swake_up(wqp); ++vcpu->stat.halt_wakeup; return true; -- 2.12.0