Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753854AbdIETBG (ORCPT ); Tue, 5 Sep 2017 15:01:06 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:46719 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753331AbdIETA5 (ORCPT ); Tue, 5 Sep 2017 15:00:57 -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 Subject: [PATCH 0/6] swait: Introduce and use swq_has_sleepers Date: Tue, 5 Sep 2017 12:00:16 -0700 Message-Id: <20170905190022.1474-1-dave@stgolabs.net> X-Mailer: git-send-email 2.12.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1360 Lines: 43 Hi. Recently[1] Nick mentioned that a lot of swait_active() callers look fishy. This is because it inherited bad habits from regular waitqueues. Other than rcu, kvm is one of the main callers, which I audited. The following patches fix and/or justify (in baby steps) some of the callers. Note that s390 and mips are other offenders, but I have no idea if it can actually occur -- ie: CPU0 CPU1 kvm_vcpu_block kvm_mips_comparecount_func [S] prepare_to_swait(&vcpu->wq) [L] swait_active(&vcpu->wq) [S] queue_timer_int(vcpu) [L] if (!kvm_vcpu_has_pending_timer(vcpu)) schedule() [1] swait: add missing barrier to swake_up: https://lkml.org/lkml/2017/9/1/165 Thanks! Davidlohr Bueso (6): sched/wait: Add swq_has_sleepers() kvm,async_pf: Use swq_has_sleepers() kvm,lapic: Justify use of swait_activate() x86,kvm: Fix apf_task_wake_one() serialization kvm: Serialize wq active checks in kvm_vcpu_wake_up() kvm,powerpc: Serialize wq active checks in ops->vcpu_kick arch/powerpc/kvm/book3s_hv.c | 2 +- arch/x86/kernel/kvm.c | 2 +- arch/x86/kvm/lapic.c | 6 +++++ include/linux/swait.h | 57 ++++++++++++++++++++++++++++++++++++++++++-- virt/kvm/async_pf.c | 6 +---- virt/kvm/kvm_main.c | 2 +- 6 files changed, 65 insertions(+), 10 deletions(-) -- 2.12.0