Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp207127imj; Thu, 14 Feb 2019 18:41:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IYA7MoK4Psc5Owkq2cKF+s8flMrK1pRqo5PJzt9BjElQ2LRbATy3wTHdMzh4sNvmimck66k X-Received: by 2002:a17:902:8303:: with SMTP id bd3mr7899250plb.10.1550198518713; Thu, 14 Feb 2019 18:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198518; cv=none; d=google.com; s=arc-20160816; b=Nvb3BOAoAy/5P54MLvzW+FBPOleyxuSQDhj618JBB1nC/PhiReOtRo2gUiPRUCfvlR o+XnNfOsCdldx0/tlusRMNxmxXJa615dPc9d3eZEmWxFzvBR67VJswFiIM3H72FvRbRE RD0xOStQ8jNMzNWaorUuuMcym9sxOOJJvZJ+V3gQ5A8D+to93uHsVbgkZbdzO0xTnI3H 6VIsSrMEOyaC3SWJfkLm9R0QqteSWxKH33DZcOzp2uIE3SSd45IhGDV7ZA5WI7tnYLe5 /BW3vXU4MtHYTbf4Ak84SlnYAu5sTuxjXd114jOM7A9bPMAPSlS+58QQeZ282ZqMVtur ogKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UDGQG1H+DsZHAXlds0g7KHJxzQ2SRI6di1IJj/Hg3Ko=; b=JBpSgiu5RYO/MWIGe0Qw1yknKcs15XqPBAypQeiETdIWGuy8KjyEJf7ggC/5/aPx2c gN0DlXyPUXAXtbROCdiE5pVWUsoTAfrTsOSaYu3rTvdZFdvm0iWz0wFxC3GEGJe7jQuy HzGPayLZii3c/FAGpHIKtY1YchRcQ6hUnVJxxhsCpzRDO40VLN3r3n+wq8csD1NWJodo PTM+5IaDkir4wrrcW3kf+T4ND+uI9QD8CQaeDn5AhMe4dHChBw35nc0mjC8Urj1Uf8Kp e8kXE3OE4ksj6ecyM/o8qR2+nWmekwXWjevA7c3HtinEK83X7+CoPZJdrBgdlAiALRXJ RXIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fWA/Wyw/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22si3986850pfe.207.2019.02.14.18.41.43; Thu, 14 Feb 2019 18:41: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; dkim=pass header.i=@kernel.org header.s=default header.b="fWA/Wyw/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730613AbfBOCkV (ORCPT + 99 others); Thu, 14 Feb 2019 21:40:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:50182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389888AbfBOCKC (ORCPT ); Thu, 14 Feb 2019 21:10:02 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B377F21B68; Fri, 15 Feb 2019 02:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196601; bh=TON0jWu7Z48cGnW3MRq5Cs1m2Hlpe+QDwDUQJgb6nwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fWA/Wyw/EM0JCXqQsin/TcQVGB/UVujjuqUTfREHJncbuRn5rHgtRnKqBhB5XVK4i 1nHCCSAygq1LlCwgDgWJ+v/cMloSR4UpYRIKpxsE9D/r9ulWCLn43IIm9D9RHTiCQi V4VU4pBJt+h6i7u3DIA3IvCrhFgvw2X4d+CUduaE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Prateek Sood , Peter Zijlstra , Linus Torvalds , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 4.20 37/77] sched/wait: Fix rcuwait_wake_up() ordering Date: Thu, 14 Feb 2019 21:08:15 -0500 Message-Id: <20190215020855.176727-37-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Prateek Sood [ Upstream commit 6dc080eeb2ba01973bfff0d79844d7a59e12542e ] 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 Signed-off-by: Sasha Levin --- kernel/exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/exit.c b/kernel/exit.c index 55b4fa6d01eb..d607e23fd0c3 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, -- 2.19.1