From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07A11C64ED6 for ; Sun, 26 Feb 2023 14:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbjBZOz5 (ORCPT ); Sun, 26 Feb 2023 09:55:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbjBZOyE (ORCPT ); Sun, 26 Feb 2023 09:54:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715ED1B2FB; Sun, 26 Feb 2023 06:50:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0A10B60C4C; Sun, 26 Feb 2023 14:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B754C433D2; Sun, 26 Feb 2023 14:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677422821; bh=Uxwk4YxCk3Jxs7egsQ3xoA4041l1BnDxDegvC3A9COk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWH2RgUOuxnSkD9YHsRaIiP/BXonHDFYj73R1+uIAsvS952BcW1ChJyUviFscHuuI sDp3JLD3nR8xC/+XpajDs0ES5q4PvHzoo3pt6oj7TqKG6ZToumg3ZvkAcQT9QRaMrb 2+TM2lhrpFY5d63U+6N6b7X0I7/L+GGOgYxMXB1y2+gyjquwbhxPTbbwonjfB8Ab3J bjVsWiCO6pgWeSGyVcWEAVUDVVA6PEAbLi7kJ2p2LbDCQL8c29JafbC+jBXbNHj9ys kaQIHV8nyV69D8U+WJa1b1TEPQhB7en4Oa1pX38W5TkocJQMSg8hrUXVRns6JJJt2v XMNxXKPHWOy9A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Paul E. McKenney" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Boqun Feng , Matthew Wilcox , Thomas Gleixner , Sasha Levin , frederic@kernel.org, quic_neeraju@quicinc.com, josh@joshtriplett.org, rcu@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 04/49] rcu: Make RCU_LOCKDEP_WARN() avoid early lockdep checks Date: Sun, 26 Feb 2023 09:46:04 -0500 Message-Id: <20230226144650.826470-4-sashal@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230226144650.826470-1-sashal@kernel.org> References: <20230226144650.826470-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 0cae5ded535c3a80aed94f119bbd4ee3ae284a65 ] Currently, RCU_LOCKDEP_WARN() checks the condition before checking to see if lockdep is still enabled. This is necessary to avoid the false-positive splats fixed by commit 3066820034b5dd ("rcu: Reject RCU_LOCKDEP_WARN() false positives"). However, the current state can result in false-positive splats during early boot before lockdep is fully initialized. This commit therefore checks debug_lockdep_rcu_enabled() both before and after checking the condition, thus avoiding both sets of false-positive error reports. Reported-by: Steven Rostedt Reported-by: Masami Hiramatsu (Google) Reported-by: Mathieu Desnoyers Signed-off-by: Paul E. McKenney Reviewed-by: Mathieu Desnoyers Cc: Boqun Feng Cc: Matthew Wilcox Cc: Thomas Gleixner Signed-off-by: Sasha Levin --- include/linux/rcupdate.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 08605ce7379d7..f40c78a127954 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -348,11 +348,18 @@ static inline int rcu_read_lock_any_held(void) * RCU_LOCKDEP_WARN - emit lockdep splat if specified condition is met * @c: condition to check * @s: informative message + * + * This checks debug_lockdep_rcu_enabled() before checking (c) to + * prevent early boot splats due to lockdep not yet being initialized, + * and rechecks it after checking (c) to prevent false-positive splats + * due to races with lockdep being disabled. See commit 3066820034b5dd + * ("rcu: Reject RCU_LOCKDEP_WARN() false positives") for more detail. */ #define RCU_LOCKDEP_WARN(c, s) \ do { \ static bool __section(".data.unlikely") __warned; \ - if ((c) && debug_lockdep_rcu_enabled() && !__warned) { \ + if (debug_lockdep_rcu_enabled() && (c) && \ + debug_lockdep_rcu_enabled() && !__warned) { \ __warned = true; \ lockdep_rcu_suspicious(__FILE__, __LINE__, s); \ } \ -- 2.39.0