Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6112510imu; Mon, 21 Jan 2019 03:27:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN47BajET4gbR14gLdjJO8X2ePUgXUTnkbqXJkgFRAXpj4IddAOv3jEcoaj8afWzccIw663N X-Received: by 2002:a65:4946:: with SMTP id q6mr27054578pgs.201.1548070078360; Mon, 21 Jan 2019 03:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548070078; cv=none; d=google.com; s=arc-20160816; b=X7CaEhJ0lUqgvPvzunJ22Qbw6pnh4NBdDoLSWWLKAUSgjwVDex3OiCCVOVuPylABs4 ZH4o3CY9AhHMA56E0ULa/sdl81qN5f1sB5updVvQ6Y6Yp7BcF+i9ioRBYEVqnf3Zw29R 7jZq3vSAcScpGKFjzqP67otncKuFMV7QBg3XCEQtmhq9gQZhzCzSPNPsakdXn4nINqrR FxOKpx1ydTEPHYI5xTcs/UCDQqmdDgLnBygpyfKjMTO7NO7+bmWZjrEu00L0YwygrFIW 5uY5oUgp5X4sI6qSGpR7eFUutgLfGdqHC3+OSrzViqWUVVeY50spiXHgw3/SkDd/QuDJ NVGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=ZJ2arnN4Ve5e0EGF7298A2uKYgwGpyadi9yc0U9aopg=; b=GDu8i0+G6R+v9jMPa9dSinlKIDhNfvkgeTR8gH8uxcDr59fW0YIcqSOI+tEgII7FqL 2yEFDqnq9VlcKboWYELBOaj53DLWrvVaAexhJQP50D9MxPHGF71dUp4JXBiRkmc0N6bG UbBqv8tcgbj3xeilv8wu/9YBtrVHkv9LxpqqvEl9W2uvbg0HwmZCh35VcAFCPCRIi5VP nI0b6pg5McSHQD/m3kdZ3REgEV5gKKA1tMGM8VHeql5gyUYk0oI/NLYlSORl6iYIMsLF D3XB/ebOF9wYZCjgHSQ2ZN+6E8/ZdTfoSK3JRWi5z2pucNRreD5qcaqO2Df+7R6z5Ui/ U1xQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cd2si12913585plb.39.2019.01.21.03.27.43; Mon, 21 Jan 2019 03:27:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbfAULZ5 (ORCPT + 99 others); Mon, 21 Jan 2019 06:25:57 -0500 Received: from terminus.zytor.com ([198.137.202.136]:51897 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727665AbfAULZ5 (ORCPT ); Mon, 21 Jan 2019 06:25:57 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0LBPiHY2495707 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 21 Jan 2019 03:25:44 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0LBPilc2495704; Mon, 21 Jan 2019 03:25:44 -0800 Date: Mon, 21 Jan 2019 03:25:44 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Prateek Sood Message-ID: Cc: prsood@codeaurora.org, mingo@kernel.org, linux-kernel@vger.kernel.org, dbueso@suse.de, torvalds@linux-foundation.org, tglx@linutronix.de, andrea.parri@amarulasolutions.com, hpa@zytor.com, peterz@infradead.org Reply-To: prsood@codeaurora.org, mingo@kernel.org, linux-kernel@vger.kernel.org, andrea.parri@amarulasolutions.com, peterz@infradead.org, hpa@zytor.com, tglx@linutronix.de, dbueso@suse.de, torvalds@linux-foundation.org In-Reply-To: <1543590656-7157-1-git-send-email-prsood@codeaurora.org> References: <1543590656-7157-1-git-send-email-prsood@codeaurora.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] sched/wait: Fix rcuwait_wake_up() ordering Git-Commit-ID: 6dc080eeb2ba01973bfff0d79844d7a59e12542e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6dc080eeb2ba01973bfff0d79844d7a59e12542e Gitweb: https://git.kernel.org/tip/6dc080eeb2ba01973bfff0d79844d7a59e12542e Author: Prateek Sood AuthorDate: Fri, 30 Nov 2018 20:40:56 +0530 Committer: Ingo Molnar CommitDate: Mon, 21 Jan 2019 11:15:36 +0100 sched/wait: Fix rcuwait_wake_up() ordering For some peculiar reason rcuwait_wake_up() has the right barrier in the comment, but not in the code. This mistake has been observed to cause a deadlock in the following situation: P1 P2 percpu_up_read() percpu_down_write() rcu_sync_is_idle() // false rcu_sync_enter() ... __percpu_up_read() [S] ,- __this_cpu_dec(*sem->read_count) | smp_rmb(); [L] | task = rcu_dereference(w->task) // NULL | | [S] w->task = current | smp_mb(); | [L] readers_active_check() // fail `-> Where the smp_rmb() (obviously) fails to constrain the store. [ peterz: Added changelog. ] Signed-off-by: Prateek Sood Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andrea Parri Acked-by: Davidlohr Bueso Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 8f95c90ceb54 ("sched/wait, RCU: Introduce rcuwait machinery") Link: https://lkml.kernel.org/r/1543590656-7157-1-git-send-email-prsood@codeaurora.org Signed-off-by: Ingo Molnar --- kernel/exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/exit.c b/kernel/exit.c index 284f2fe9a293..3fb7be001964 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -307,7 +307,7 @@ void rcuwait_wake_up(struct rcuwait *w) * MB (A) MB (B) * [L] cond [L] tsk */ - smp_rmb(); /* (B) */ + smp_mb(); /* (B) */ /* * Avoid using task_rcu_dereference() magic as long as we are careful,