Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1306585lqb; Thu, 30 May 2024 06:46:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHbfQCfFuAtVW+RH4Pi+/Sl7zy7kvTVhJ2tTgPwsL+7v/KzHrO4IMNvVtlEsH/mJnYz/n4HY6X9jGGnXR/pLuV05SXb0HpSJ5iEV5PeQ== X-Google-Smtp-Source: AGHT+IHSF6gyKlhL0YtIfweI+HHuLLIcl50H5IjyrbQmzTtc+17LYJ57yb2qAG5XbRSXb0Shm8FV X-Received: by 2002:a05:6a21:6d97:b0:1ad:7e4d:2ea2 with SMTP id adf61e73a8af0-1b26451a0damr3085076637.4.1717076787870; Thu, 30 May 2024 06:46:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717076787; cv=pass; d=google.com; s=arc-20160816; b=VBw3uYN+eRuhZQWHXIVLgqiY8NdFReGB6RuvMd/COuNvR65zyqaJYDX5CD8AF2yhtp cEcVSOp4hNcDRE9hVHvi9gAkV0Vt9kApR43c5CHNlrX7qm2f8dG8WT1W9fHIZLBiDT7j xvo/qoXQ6c7HAzdVclBtP7qZZUMgzYyfpFlVkRtQoPU7YLVFnicLPd2K+nkASv/Kvaai +4woV0rL2Mb5b9nk/usp3qNw9eS19Xrct717MXamQNelDYkb1Ol3jqehls3Z7ztHoQHB u6junE6zFQ/biG6MXmJyeT0AtIl7rNk54C1XvC/F4YGGmfiT/wddqPVizHd6DVZWcFeR 1eAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WJSorcaxhBG7S5k+0CyiJx9wo40NfvfoDVwhMa2KUuw=; fh=ruOaVEkAbEh3t4sLFZXGQmBwM4c1/V/LLnMggyZGb4c=; b=OI0gfomWKyeO0QowA0/sB8gqCzRWxPEB4eSBqFz73OxSxR1Nnc2zeoH1aMov4vbfsE nU4JNtrY6Uq150zoy38GFEtNHf47xQynG2efZ+Q4KQAmr4X8Ju3pwwFvnLa9GsXThrqS Fh66rds9eI9FYTNDdWHxflOYkQs80XhIeu6efI0u00j5jQDtEjUCA2Y/+13j7SBBR96K knCgx/xutam2wOaOrcMa5H1Z+XcGAGYHHmYeRP+7CK00J0Y+pz8eBRXRHOBD+PEvr6Lv R+G15C3fYzsrFcAOmFAFDnGZCJzEEUqXnd1eU+HQoXWehZjJMI2Mg9I5efCgv23TJ0DU kIFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RV6lIgdq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-195439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fc051148si11715685b3a.77.2024.05.30.06.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 06:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RV6lIgdq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-195439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2CCCFB2294F for ; Thu, 30 May 2024 13:46:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 403E017D8A4; Thu, 30 May 2024 13:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RV6lIgdq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C8FC17D89C; Thu, 30 May 2024 13:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717076764; cv=none; b=bT2UwxTI63fLef9KXcPaRW/e34ZykJ6ZZyyGaQ2ApFCh801N/0L3mUNEvJ/bQhv9ayq9u9pNLHiD/woqakaI+0pT8T+Fmkuo0xqrHu+I5EyPb3XBeET9i1juIsbFKmTVfS1KZQu1ewd0bNxLETHUC0J2hRAE+XVrDeMONUt7ZDU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717076764; c=relaxed/simple; bh=QUqTf47U5266+G1RAYGGur6TId4oP4I8Z4uT9fa4U8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lmxe9od22Nyv0fvXneEypbDNNBIucseEsUUnlflS5LEfupu2s+uxj0EhFRUVc3wQwFlzOImANQFjIwbCLG0F67F1vZR7MP0XMvBbRGEMhKTpyuz50EkK75ahmMcXf6RQN/d498WjqLhvsigf56PUGW1EwXh47HADeMGTW/SBltU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RV6lIgdq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A1D6C32786; Thu, 30 May 2024 13:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717076763; bh=QUqTf47U5266+G1RAYGGur6TId4oP4I8Z4uT9fa4U8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RV6lIgdqok+I3N32iQOTjFIewW7ShzbN5c8IEDw/xUl3IqeA7neBXsufFpkIleUht PA2oWdhohOGwViCjISPag8qAV5T+9yug+yumsdqh5Q8RRt2/FoBwllY7ovT14dObSy llfrTtfuncXmPPJp7jtGzVb+TuCcHg9T9z5XO08whx281ciU/Ia3c57Y9xyUHp1LRy 3ol14uzlG1ST66rKawwHQiRNtHVMzls9Iufrhwc/0tdqJFnlGp7/LvUoB9EIQiRVA8 CUtu95MQzYqDTCwwWk3Y3KonzRbvi5MubD6rLwyMTFszdIu6Dzq2FN/RekwOL9kPIE cniS3ZZGrABUg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Boqun Feng , Joel Fernandes , Neeraj Upadhyay , "Paul E . McKenney" , Uladzislau Rezki , Zqiang , rcu Subject: [PATCH 01/11] rcu/nocb: Introduce RCU_NOCB_LOCKDEP_WARN() Date: Thu, 30 May 2024 15:45:42 +0200 Message-ID: <20240530134552.5467-2-frederic@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240530134552.5467-1-frederic@kernel.org> References: <20240530134552.5467-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Checking for races against concurrent (de-)offloading implies the creation of !CONFIG_RCU_NOCB_CPU stubs to check if each relevant lock is held. For now this only implies the nocb_lock but more are to be expected. Create instead a NOCB specific version of RCU_LOCKDEP_WARN() to avoid the proliferation of stubs. Signed-off-by: Frederic Weisbecker --- include/linux/rcupdate.h | 7 +++++++ kernel/rcu/tree_nocb.h | 14 -------------- kernel/rcu/tree_plugin.h | 4 ++-- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index be450a3477be..9161e00a0cf4 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -145,11 +145,18 @@ void rcu_init_nohz(void); int rcu_nocb_cpu_offload(int cpu); int rcu_nocb_cpu_deoffload(int cpu); void rcu_nocb_flush_deferred_wakeup(void); + +#define RCU_NOCB_LOCKDEP_WARN(c, s) RCU_LOCKDEP_WARN(c, s) + #else /* #ifdef CONFIG_RCU_NOCB_CPU */ + static inline void rcu_init_nohz(void) { } static inline int rcu_nocb_cpu_offload(int cpu) { return -EINVAL; } static inline int rcu_nocb_cpu_deoffload(int cpu) { return 0; } static inline void rcu_nocb_flush_deferred_wakeup(void) { } + +#define RCU_NOCB_LOCKDEP_WARN(c, s) + #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ /* diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 3ce30841119a..f4112fc663a7 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -16,10 +16,6 @@ #ifdef CONFIG_RCU_NOCB_CPU static cpumask_var_t rcu_nocb_mask; /* CPUs to have callbacks offloaded. */ static bool __read_mostly rcu_nocb_poll; /* Offload kthread are to poll. */ -static inline int rcu_lockdep_is_held_nocb(struct rcu_data *rdp) -{ - return lockdep_is_held(&rdp->nocb_lock); -} static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp) { @@ -1653,16 +1649,6 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) #else /* #ifdef CONFIG_RCU_NOCB_CPU */ -static inline int rcu_lockdep_is_held_nocb(struct rcu_data *rdp) -{ - return 0; -} - -static inline bool rcu_current_is_nocb_kthread(struct rcu_data *rdp) -{ - return false; -} - /* No ->nocb_lock to acquire. */ static void rcu_nocb_lock(struct rcu_data *rdp) { diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 51125f4130fd..0d6b152a9a17 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -24,10 +24,10 @@ static bool rcu_rdp_is_offloaded(struct rcu_data *rdp) * timers have their own means of synchronization against the * offloaded state updaters. */ - RCU_LOCKDEP_WARN( + RCU_NOCB_LOCKDEP_WARN( !(lockdep_is_held(&rcu_state.barrier_mutex) || (IS_ENABLED(CONFIG_HOTPLUG_CPU) && lockdep_is_cpus_held()) || - rcu_lockdep_is_held_nocb(rdp) || + lockdep_is_held(&rdp->nocb_lock) || (!(IS_ENABLED(CONFIG_PREEMPT_COUNT) && preemptible()) && rdp == this_cpu_ptr(&rcu_data)) || rcu_current_is_nocb_kthread(rdp)), -- 2.45.1