From patchwork Thu Jan 16 20:02:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942183 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 D33D81DE894; Thu, 16 Jan 2025 20:02:41 +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=1737057761; cv=none; b=oB3SkmEEm+q1fx3b4WyTMBLizy0NyKO9VBDkoE8Y8rbXKSaKZ5RLWJfFu+K1OCi1+/Tas2AxQCc4s/tWVs3C5yWczBNL9bX99yRd+h70cisRmrg1dT2Q0lafWfLBMOkoGJod3Cosul+UfMveFbjOhcrhWqLTU5yk8zNdjUnNJDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057761; c=relaxed/simple; bh=lafpHyVaSYlRTcQ8LIw7WT/QIW65DigJmxVxCRz15TA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T/b12YEZFTmpb2TW06jRn+uQSwk1SPgSrD7iSTleabqlmJZyZ7KE8tSkKHDKyHbTUUk8ua4gyJIR+J26fpxuHyu4SYNAX+zm1HseJcBIJhcVIl0Fggq0GZIK+HNKb7YA5H+BAv8rzN5mW0f6nkfNZcsB3SKAOhum+UFqx0iW7c0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GC8028aJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GC8028aJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 726CFC4CED6; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=lafpHyVaSYlRTcQ8LIw7WT/QIW65DigJmxVxCRz15TA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GC8028aJN+2xagjw79rkzXVZmwPzhF0F8aF7sEPSO1IamPMXS5BEvFn3NmjUTU+YR rwZUlFxuDaS6fVUwoazh9ft1l0NtrIdl5+CjZsyV4W5pZNGLy+IaMNFxqm15WohSH3 svgJnOwaRFqIWrvPN0IN1CD1c/xreBBhSv7x3lTXWYOaL2Yuu53y515TJdnRqGgwqB UuIkPk9h3KPVUGncu/vgwoEjt9JtjKMoUah4rxQY8kPKTdlj2YexH50lYphRDZRXu8 Nqn4a61iacwkwtYFGufPeljqski1b3ObA1OSTDJ2eheyL6U/lF3b9Ky8A1MHoiS4xR acmjXhyLJZfHQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 298B9CE0EDF; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 1/7] doc: Add broken-timing possibility to stallwarn.rst Date: Thu, 16 Jan 2025 12:02:33 -0800 Message-Id: <20250116200239.3782374-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, stallwarn.rst does not mention the fact that timer bugs can result in false-positive RCU CPU stall warnings. This commit therefore adds this to the list. Signed-off-by: Paul E. McKenney --- Documentation/RCU/stallwarn.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/RCU/stallwarn.rst b/Documentation/RCU/stallwarn.rst index 30080ff6f4062..d1ccd6039a8c3 100644 --- a/Documentation/RCU/stallwarn.rst +++ b/Documentation/RCU/stallwarn.rst @@ -96,6 +96,13 @@ warnings: the ``rcu_.*timer wakeup didn't happen for`` console-log message, which will include additional debugging information. +- A timer issue causes time to appear to jump forward, so that RCU + believes that the RCU CPU stall-warning timeout has been exceeded + when in fact much less time has passed. This could be due to + timer hardware bugs, timer driver bugs, or even corruption of + the "jiffies" global variable. These sorts of timer hardware + and driver bugs are not uncommon when testing new hardware. + - A low-level kernel issue that either fails to invoke one of the variants of rcu_eqs_enter(true), rcu_eqs_exit(true), ct_idle_enter(), ct_idle_exit(), ct_irq_enter(), or ct_irq_exit() on the one From patchwork Thu Jan 16 20:02:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942184 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 D343A22FDEC; Thu, 16 Jan 2025 20:02:41 +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=1737057761; cv=none; b=GPVjA+2VYiSw1XGqWEjckDSWVWCjnKHtZQN62H0eye7H7UoRLBStnAacLGM4fSLQNUQs9NX9XocQN60Rsc+TW0a/VOxccKsnRWs6VxpgBY2crNhky9Q2hN+DnRWgx26zoERhnkIKcyxEV6aagEtqKyA2K78p8XggSIj34A+3LcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057761; c=relaxed/simple; bh=F+8+Q9SIp7U9jRLhjSu8vofJvIuuC8FLrTqiXt/jqag=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BKWNYqwCbn8DkeS2Oo0T0yWr4LmTrUAUipzmYUUgXJb01hPDmjZwM90OyRikv4nSU6b4b/bwdxGitmQJZF/23V8Q1rKYCJHK/pudqiih00qu0j1KiqEFF0wpKJPt/TTMp0i/wPGEP8cL330sAS1ObirG4o19tTLnLTrq6jjUudc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=grOwb6iw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="grOwb6iw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D21FC4CEDD; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=F+8+Q9SIp7U9jRLhjSu8vofJvIuuC8FLrTqiXt/jqag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=grOwb6iwUE2pGQI6EYvOqpj8fYJxW/+VTF90/nVQKvr3b787/sE67+cW5j4hzQjIL oKn4oSmi/yl8gbeV6swhRvwMp/44Gk9tPdlCWq6M+iQNwbLQUDHaf9jjbsm5+EloSh XAtWGxEcpS8xX1bcCZLV5EaqrZqIh7OyfRHo9A0/75v5MZJee9aCrYrdzKYf4Btg+Z vCG6BMMA6uWov1rsnMKeRMQiCB2J8HjXSfUXmoH6TqtIssje6Q9hUhmsn5X0vyAZE7 Nq6+D1KzJAuU2C66jqtsZZsHXjpITrXCUkXH0yzMQbZkZ+S+FsrjWUlLKDVHsKbFYX IXC0O5DSw6GfA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2BEFBCE10F9; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Jonathan Corbet , Peter Zijlstra , Mark Rutland , Boqun Feng , linux-doc@vger.kernel.org Subject: [PATCH rcu 2/7] docs: Improve discussion of this_cpu_ptr(), add raw_cpu_ptr() Date: Thu, 16 Jan 2025 12:02:34 -0800 Message-Id: <20250116200239.3782374-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of the this_cpu_*() operations may be used in preemptible code, but not this_cpu_ptr(), and for good reasons. Therefore, better explain the reasons and call out raw_cpu_ptr() as an alternative in certain very special cases. Signed-off-by: Paul E. McKenney Cc: Jonathan Corbet Cc: Peter Zijlstra Cc: Mark Rutland Cc: Boqun Feng Cc: --- Documentation/core-api/this_cpu_ops.rst | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Documentation/core-api/this_cpu_ops.rst b/Documentation/core-api/this_cpu_ops.rst index 91acbcf30e9bd..11e3e48731553 100644 --- a/Documentation/core-api/this_cpu_ops.rst +++ b/Documentation/core-api/this_cpu_ops.rst @@ -138,12 +138,22 @@ get_cpu/put_cpu sequence requires. No processor number is available. Instead, the offset of the local per cpu area is simply added to the per cpu offset. -Note that this operation is usually used in a code segment when -preemption has been disabled. The pointer is then used to -access local per cpu data in a critical section. When preemption -is re-enabled this pointer is usually no longer useful since it may -no longer point to per cpu data of the current processor. - +Note that this operation can only be used in code segments where +smp_processor_id() may be used, for example, where preemption has been +disabled. The pointer is then used to access local per cpu data in a +critical section. When preemption is re-enabled this pointer is usually +no longer useful since it may no longer point to per cpu data of the +current processor. + +The special cases where it makes sense do obtain a per-CPU pointer in +preemptible code are addressed by raw_cpu_ptr(), but please note that such +use cases need to handle cases where two different CPUs are accessing +the same per cpu variable, which might well be that of a third CPU. +These use cases are typically performance optimizations. For example, +SRCU implements a pair of counters as a pair of per-CPU variables, +and rcu_read_lock_nmisafe() uses raw_cpu_ptr() to get a pointer to some +CPU's counter, and uses atomic_inc_long() to handle migration between +the raw_cpu_ptr() and the atomic_inc_long(). Per cpu variables and offsets ----------------------------- From patchwork Thu Jan 16 20:02:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942182 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 AF8B0156237; Thu, 16 Jan 2025 20:02:41 +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=1737057761; cv=none; b=M4by0BjnkcWOxTonz1NkgHHBGLY9ItQIEkTvYcUQvv6OrZgl7+6Ibu0sqjQgsdL0FC5EG01T5zKIwtjKlADNwbeZxoVTzBOhmrZCc56z0CVbt6GScEjgOv5GtRC1j8bvbocDw42s3Tp0itZ5ZnLBu+DdGTyokFGJbiSHseO7d/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057761; c=relaxed/simple; bh=vpYCxzM5TqeGtWd5gS64X54MnN9UyW5aYLPvOP20U3M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fUW+/kxijrfX61s5AD+FAdcHGkd9aKkYrExriOGplBgD+48WlkDGxEU6WtC+5T+Z4YdyMPYHqLw92Xq4y2oQNfXMk2yTYISiZbQouJZkgc399wikdxs2pbZCnwYSTjWOlMn502KHF47e/zaegPDGJi1QkqJO0pn8GEqA4xckeec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nYPueWTs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nYPueWTs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87973C4CEDF; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=vpYCxzM5TqeGtWd5gS64X54MnN9UyW5aYLPvOP20U3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYPueWTsbb0iMbGz4SjwMq3BvJwUZQR7QnJLpEQetku5niMZZSDNn2P+Gu7kyyh7v g4sRQNwyVz6Z9CHwtMPNzJmAmwQzKFCVK1dAXpF7xv/2dAh+funVly2cANsm6LLNPK 9NZhsji0audzbtp9Jgno6KXHYFOoVW3cYaM8Ze9oyjYmmxXTgpXjueikC9td9jhhsg XRJJcc1RyE3yRDg58NXn47ht2SL3ty1QDskxnTLUVwOm0OxFJC6sYzOyRnQOP900ih rsoaqmlrDyGsi+hI9pNlEMp+knfHFdbcTjdonJNmHn5nTprgx5NoE1GdnK+xvOvuJk euIuEt4fv9meQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2E169CE37B4; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Jens Axboe Subject: [PATCH rcu 3/7] rcu: Document self-propagating callbacks Date: Thu, 16 Jan 2025 12:02:35 -0800 Message-Id: <20250116200239.3782374-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit documents the fact that a given RCU callback function can repost itself. Reported-by: Jens Axboe Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 24f1cb292a92d..befe35058c49a 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3128,7 +3128,7 @@ module_param(enable_rcu_lazy, bool, 0444); * critical sections have completed. * * Use this API instead of call_rcu() if you don't want the callback to be - * invoked after very long periods of time, which can happen on systems without + * delayed for very long periods of time, which can happen on systems without * memory pressure and on systems which are lightly loaded or mostly idle. * This function will cause callbacks to be invoked sooner than later at the * expense of extra power. Other than that, this function is identical to, and @@ -3159,6 +3159,12 @@ EXPORT_SYMBOL_GPL(call_rcu_hurry); * might well execute concurrently with RCU read-side critical sections * that started after call_rcu() was invoked. * + * It is perfectly legal to repost an RCU callback, potentially with + * a different callback function, from within its callback function. + * The specified function will be invoked after another full grace period + * has elapsed. This use case is similar in form to the common practice + * of reposting a timer from within its own handler. + * * RCU read-side critical sections are delimited by rcu_read_lock() * and rcu_read_unlock(), and may be nested. In addition, but only in * v5.0 and later, regions of code across which interrupts, preemption, From patchwork Thu Jan 16 20:02:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942186 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 318A0236ED6; Thu, 16 Jan 2025 20:02:41 +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=1737057762; cv=none; b=NTj5/DoEoh4gOAFtKwZAHX8uaxk2MlaglR1joAqdQ09mUxB0DXO0HNH8MQdzBJId3kIK6eXx3Vm9ts3MAQ6aXxLmXJmItC6jbaR+HgxSYFAtxY5+WxH70Uv0FkYdc7GIjgHAo6/2WRCDvTVpJwCdhx11ePhDyzcNiffmSxuPr3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057762; c=relaxed/simple; bh=LxAVjkcceEBX+kWOutmMnZ3hzVxe3HxARfJHuCJyvGc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Lj4bOkPr1fOaiABobs3P/uxkaMs/YZ7fLKYBdM4Lq6WwxKm0nrKlf/2df66r7NrufXOGLAhNy0ejImS0ntshlPjQoYzQ8p4qDbnALoXYhanECqrcuud2JfYUuIyT1ejhgNovzGyWSsogs6mMPTlO+JpNSQ7nY2bB/75EY/LX1SY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TfPjC6VX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TfPjC6VX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3346C4CEE8; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=LxAVjkcceEBX+kWOutmMnZ3hzVxe3HxARfJHuCJyvGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TfPjC6VX/rGmwBSWAUV1Y0Ly8rV9gU24Jc1nFSlgR3868pqeFppW7Ok2Rr1pyzTD+ IusOWW6r8JZx3S3xzfXBEw825bon3yONTOCwX1BgOksQhL6Ajb+w1K0FMOLHvg/cqt E/wRNOOoib789QsLZiCy1JIJDIfpQQ/YgC8xnRxK2LnucKV/YUJmOCXmBZDvI8Qb9H Y4go8Arp7RhmeOpCe6i5UuqLFQZbTMNz3Q3CId4qapA/mU/+NDUgzAV+mQi/URTFFC 5xUJpj7QUb6p1lhqkNaLDoKWsthV8Zu4QKe+SXeJ4Hyd8lWQfBwyXM3+5whCRQ7V+m zZJrdg6w4CZbg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 30408CE37B6; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 4/7] srcu: Point call_srcu() to call_rcu() for detailed memory ordering Date: Thu, 16 Jan 2025 12:02:36 -0800 Message-Id: <20250116200239.3782374-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit causes the call_srcu() kernel-doc header to reference that of call_rcu() for detailed memory-ordering guarantees. Signed-off-by: Paul E. McKenney --- kernel/rcu/srcutree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index b83c74c4dcc0d..f87a9fb6d6bb8 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -1398,8 +1398,12 @@ static void __call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp, * read-side critical sections are delimited by srcu_read_lock() and * srcu_read_unlock(), and may be nested. * - * The callback will be invoked from process context, but must nevertheless - * be fast and must not block. + * The callback will be invoked from process context, but with bh + * disabled. The callback function must therefore be fast and must + * not block. + * + * See the description of call_rcu() for more detailed information on + * memory ordering guarantees. */ void call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp, rcu_callback_t func) From patchwork Thu Jan 16 20:02:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942185 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 F3848230D15; Thu, 16 Jan 2025 20:02:41 +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=1737057762; cv=none; b=diXw2ADjKUWLEH6V7m9wPCKA+055zsMlbbi/IamHdEC7KkJ0FCDw+zj0KZj/J5YL1yxwkdgIczaEKUWIdwjUAHB+WrYZnU2uzY3rcUjQOqiXf/JQFD0kgV3tPG3TTVfOrYGxaxwMiseKMuXPTbeMoXqSyjh5QX1K+MX/3qjLhpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057762; c=relaxed/simple; bh=rVsXW6OIYTVEN0bfuaeNNyP5q/z2Ibgs5P1cnobIV5c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BoR4Y91QuKLBzdfTmBjna1i3OulhMA+emTazVIqsQF4b62fJdeDgHHxiCyjRIEzewd79jgmCojOczzsLmso/3MeCIaHgosYplI1iiZeW7v1ihUzzsWIvtgJx1w4/tXWHc3tOPyqO9pxGxTCahUOsWQfOYSWQbFL+cGajI98iGeA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tG3DwXri; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tG3DwXri" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93481C4CEE4; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=rVsXW6OIYTVEN0bfuaeNNyP5q/z2Ibgs5P1cnobIV5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tG3DwXriUypkz5Rb226tMVXp1RyoyfZZyS/+4AwGQl8vbddBDfYM/fJEqO2NQTGdm J7WnY1p8gmTxHmBJYZ4vG36+TJbuJ3LqYWyZtaqACTY5GYzfy6aduEoDkLXbJiAvR/ +coa3OhEQs+1eyJ/GVYyPkSDBwkijjB0w7fE5kB/5p2/gvLUjUutiHKaiTFnVvhlai FQuElAgF/f5KGtzmaLsOiOPpRZesDO7xRY12BlCQ0whvJH373PzVFdypf+1agRXNqU 1swYBdLNY+qYkAVurL3gGBA4JFG2dfQ14NyFTajMZv9gVoTZGBbJ7l9T3SRpgehJVo IB4uTl4cjpiPQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 329A1CE37C1; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 5/7] rcu: Add CONFIG_RCU_LAZY delays to call_rcu() kernel-doc header Date: Thu, 16 Jan 2025 12:02:37 -0800 Message-Id: <20250116200239.3782374-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds a description of the energy-efficiency delays that call_rcu() can impose, along with a pointer to call_rcu_hurry() for latency-sensitive kernel code. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index befe35058c49a..229f427b8c821 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3193,6 +3193,13 @@ EXPORT_SYMBOL_GPL(call_rcu_hurry); * * Implementation of these memory-ordering guarantees is described here: * Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst. + * + * Specific to call_rcu() (as opposed to the other call_rcu*() functions), + * in kernels built with CONFIG_RCU_LAZY=y, call_rcu() might delay for many + * seconds before starting the grace period needed by the corresponding + * callback. This delay can significantly improve energy-efficiency + * on low-utilization battery-powered devices. To avoid this delay, + * in latency-sensitive kernel code, use call_rcu_hurry(). */ void call_rcu(struct rcu_head *head, rcu_callback_t func) { From patchwork Thu Jan 16 20:02:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942188 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 3ABBE23F269; Thu, 16 Jan 2025 20:02:42 +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=1737057762; cv=none; b=gnBaNt0REXU+6H68uFwZ132ur8Q6f6N7wrWMbMQnlq6MKJ62gLuwk6rImqCUMoZp3xDiTbKof7IyHMyAV2oErd57J2841ckP2QhSkGPiPjspOjluwO3hnF1rr1UPwTeQVUGjctK2UuoNxaEVk4BLM32K0DRLdBoXxBGDqUZj0MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057762; c=relaxed/simple; bh=nCzBiBHz3M2xxT1NTdXIMhRys/kvq/wbFX7EYoDah+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=inuuzqddOIqOdtfULxIPZmQE1hKe2Kgt4okz7md3jlhwuuNmQNZ/EH+aYWZHmOLSUszAJWG4gQobib8UGVzTPBfzkSqtmaNxe6ETdCU5mNt0M/eCYPaS+oPOM+fVvy7vNhPc58lt2RaI99ppfnlXHoe0xlla+6PXHtT+UhrhYGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kEcvtssV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kEcvtssV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2AA3C4CEE9; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=nCzBiBHz3M2xxT1NTdXIMhRys/kvq/wbFX7EYoDah+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEcvtssV3oT38qFLKH/36T5Z2kPdhHLdBFij255x0R67OP5KNYWBp1/Yu5s8vMGMf wPVwQLxawWj8Zulkjv0+0v3SezcxrWly8FqsrkXQxBiZKqcCz8X+JkU2mrd5E1cdRd cQ13/84dD+OzyS4RW3tGwOOpsLjZxyqYLOosjhLPMQY4IKHojK++O9JUEeo7/3bBHW hTeJaxikTKpjC7htp4PhAjDsU2JScTjegjsvbyVzto/MDMryCbXOWZZhBRUV5iPxLA f3j9XIXvE6ioh4Z5Z0HpGnkYpkzjGOubAwmGkuvX996CY+qeXhhVtZyj7/fGRhjIrm GCuDNmI9v76mA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 349F7CE37C4; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" Subject: [PATCH rcu 6/7] rcu: Clarify RCU_LAZY and RCU_LAZY_DEFAULT_OFF help text Date: Thu, 16 Jan 2025 12:02:38 -0800 Message-Id: <20250116200239.3782374-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit wordsmiths the RCU_LAZY and RCU_LAZY_DEFAULT_OFF Kconfig options' help text. Signed-off-by: Paul E. McKenney --- kernel/rcu/Kconfig | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig index b9b6bc55185db..2bb22dac3b5a9 100644 --- a/kernel/rcu/Kconfig +++ b/kernel/rcu/Kconfig @@ -323,21 +323,27 @@ config RCU_LAZY depends on RCU_NOCB_CPU default n help - To save power, batch RCU callbacks and flush after delay, memory - pressure, or callback list growing too big. + To save power, batch RCU callbacks and delay starting the + corresponding grace period for multiple seconds. The grace + period will be started after this delay, in case of memory + pressure, or if the corresponding CPU's callback list grows + too large. - Requires rcu_nocbs=all to be set. + These delays happen only on rcu_nocbs CPUs, that is, CPUs + whose callbacks have been offloaded. - Use rcutree.enable_rcu_lazy=0 to turn it off at boot time. + Use the rcutree.enable_rcu_lazy=0 kernel-boot parameter to + globally disable these delays. config RCU_LAZY_DEFAULT_OFF bool "Turn RCU lazy invocation off by default" depends on RCU_LAZY default n help - Allows building the kernel with CONFIG_RCU_LAZY=y yet keep it default - off. Boot time param rcutree.enable_rcu_lazy=1 can be used to switch - it back on. + Build the kernel with CONFIG_RCU_LAZY=y, but cause the kernel + to boot with these energy-efficiency delays disabled. Use the + rcutree.enable_rcu_lazy=0 kernel-boot parameter to override + the this option at boot time, thus re-enabling these delays. config RCU_DOUBLE_CHECK_CB_TIME bool "RCU callback-batch backup time check" From patchwork Thu Jan 16 20:02:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13942187 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 3AB2523F263; Thu, 16 Jan 2025 20:02:42 +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=1737057762; cv=none; b=TrqCwjNN7ffrPWkJukPoSppB7sQfmggW3YcktxOAbM1nD5s+mVJNqARyMjdj/6y95qs/KSUnzv5JhzzY8pavDyv6z8MczXaYwYtUNWgCv/txdF7oP7Lp9NZ9tdINcIb4w5mPjzauKToy2IZYVX+Q6JhQoCrcexqw1AQPK0dw2+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737057762; c=relaxed/simple; bh=YaVLSsW7PyxGcjEkwPWdmu0BULuqG4DED/ZbOXpCbco=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i8EzY2wcBXcX0UcUWXhkIDYRzxd8zEbu8DsPxiwiEL+xd2faIEsb3WRSzZYlPP6UdeEanP2U14lcCn2q4Aqne7TUQLR7q3T3ORDEC8C9v3d++I48/APLiIbGi3aFnt1qR7Fa9S2VEg9NvuTB6ARfTMxrQJ5C31asb2+gFl9Xv3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KTJTGboL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KTJTGboL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC825C4CEEA; Thu, 16 Jan 2025 20:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737057761; bh=YaVLSsW7PyxGcjEkwPWdmu0BULuqG4DED/ZbOXpCbco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTJTGboLdcqnAM3RTXIFIl/yBcPpuXefkftz9oN74iS7GZh0sqiIpoAZK9p55s7LN QYtYHHCJO4ZKbEu5zpdXme76XbGRIBq/xpbCN+plW1gDohXUTq3tjBNSKDx+xPMDwj AdCmfPMfyl1uQMHyRm5XRe9kKDgNpSgIkDDs6156uB5uxrJbmn8bQHZDTE55+Ni/Ws uSswqK8mtZBo8INMSEgXU5l4roXTG55/7Ay9JK2WhkDf2zyYVbcMH9DGYezdOA9f7z Weajtk9AWqnmsYBh6rDxqJqAr73GeB/C/xlcwR63yMTtjrqzbgX/cp1bM17glN7NhV 7eElULNEKVjnA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 37005CE37D2; Thu, 16 Jan 2025 12:02:41 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Joe Perches Subject: [PATCH rcu 7/7] rcu: Remove references to old grace-period-wait primitives Date: Thu, 16 Jan 2025 12:02:39 -0800 Message-Id: <20250116200239.3782374-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The rcu_barrier_sched(), synchronize_sched(), and synchronize_rcu_bh() RCU API members have been gone for many years. This commit therefore removes non-historical instances of them. Reported-by: Joe Perches Signed-off-by: Paul E. McKenney --- Documentation/RCU/rcubarrier.rst | 5 +---- include/linux/rcupdate.h | 17 +++++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Documentation/RCU/rcubarrier.rst b/Documentation/RCU/rcubarrier.rst index 6da7f66da2a80..12a7b059654f7 100644 --- a/Documentation/RCU/rcubarrier.rst +++ b/Documentation/RCU/rcubarrier.rst @@ -329,10 +329,7 @@ Answer: was first added back in 2005. This is because on_each_cpu() disables preemption, which acted as an RCU read-side critical section, thus preventing CPU 0's grace period from completing - until on_each_cpu() had dealt with all of the CPUs. However, - with the advent of preemptible RCU, rcu_barrier() no longer - waited on nonpreemptible regions of code in preemptible kernels, - that being the job of the new rcu_barrier_sched() function. + until on_each_cpu() had dealt with all of the CPUs. However, with the RCU flavor consolidation around v4.20, this possibility was once again ruled out, because the consolidated diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 48e5c03df1dd8..3bb554723074d 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -806,11 +806,9 @@ do { \ * sections, invocation of the corresponding RCU callback is deferred * until after the all the other CPUs exit their critical sections. * - * In v5.0 and later kernels, synchronize_rcu() and call_rcu() also - * wait for regions of code with preemption disabled, including regions of - * code with interrupts or softirqs disabled. In pre-v5.0 kernels, which - * define synchronize_sched(), only code enclosed within rcu_read_lock() - * and rcu_read_unlock() are guaranteed to be waited for. + * Both synchronize_rcu() and call_rcu() also wait for regions of code + * with preemption disabled, including regions of code with interrupts or + * softirqs disabled. * * Note, however, that RCU callbacks are permitted to run concurrently * with new RCU read-side critical sections. One way that this can happen @@ -865,11 +863,10 @@ static __always_inline void rcu_read_lock(void) * rcu_read_unlock() - marks the end of an RCU read-side critical section. * * In almost all situations, rcu_read_unlock() is immune from deadlock. - * In recent kernels that have consolidated synchronize_sched() and - * synchronize_rcu_bh() into synchronize_rcu(), this deadlock immunity - * also extends to the scheduler's runqueue and priority-inheritance - * spinlocks, courtesy of the quiescent-state deferral that is carried - * out when rcu_read_unlock() is invoked with interrupts disabled. + * This deadlock immunity also extends to the scheduler's runqueue + * and priority-inheritance spinlocks, courtesy of the quiescent-state + * deferral that is carried out when rcu_read_unlock() is invoked with + * interrupts disabled. * * See rcu_read_lock() for more information. */