From nobody Tue Oct 7 01:58:26 2025 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 A1CBA28682; Wed, 16 Jul 2025 00:45:40 +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=1752626740; cv=none; b=eA2/OUxOzRlhWjc4j5daeRLSbHuugOhpaj8vjXal0uddVxg2SuWsBab/TLF7/JsS1EnrDoWXtKL5CU2CpYeoD9dkTvEzZLVTSsAobpbAlE+k7RraI51GjjHGA7/pOeWuNKSVXzS1SLiElzUH5G/wsoDAzoWpXLNpm8mSYttatPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752626740; c=relaxed/simple; bh=tetN+e8Zroa12My4BH0Ixg4xi/YTNBr3shEjxkKCvWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AzU6Vr2wBi+1VUXVatAhQVgzGb4YFrv4fePiE0m8CnCRcBn4rIg3MNuPrxiifBotoZLuOGXFjGUPMPx8oevxrPSTmpot5x+Yf1QEAieaQf+R4hdYEvDKVf0Hiweej1bZB69Y2b1Ro502y/xii/idAjXAjDNfDKk/yAEjnmw8RKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pAHHJ1I3; 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="pAHHJ1I3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49F34C4CEF1; Wed, 16 Jul 2025 00:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752626740; bh=tetN+e8Zroa12My4BH0Ixg4xi/YTNBr3shEjxkKCvWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pAHHJ1I3IYcPnm/1o1v0txooGod8XB5YKzQCKr4zqWQ4cRmBQLR2jRl2sRoeMTaTu mTC1GXyzhVgLbMLZW9Wft7dvjWzSOl05mZT1BZPPeazC/An0vRcOdn4bdQowzRiHL1 DBk+n3bcOsUq78tnZ0ea13xRmCgqh1QcV84cyfgpWOewjY7+FQQKhQfAEUrVJ0xZGB tPKNEYkezrTziRE404PMli5IpvcHZjD8j1D/SCGFzdjRv9KNxsz1Z387biMdCYFsBn 3VQVZ+b/hpOKsnB0rs6QnYeP9SFGzxcRB1FfS89ckRiTilBmJe5khq61VgOTdaLsLF fBYonh77FoLww== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F0617CE0990; Tue, 15 Jul 2025 17:45:39 -0700 (PDT) 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 RFC 1/2] doc: Update whatisRCU.rst for recent RCU API additions Date: Tue, 15 Jul 2025 17:45:37 -0700 Message-Id: <20250716004538.2720239-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <70015517-57ab-4d07-9792-3ab1beced9e4@paulmck-laptop> References: <70015517-57ab-4d07-9792-3ab1beced9e4@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bring this file kicking and screaming into the year 2025! Signed-off-by: Paul E. McKenney --- Documentation/RCU/whatisRCU.rst | 150 +++++++++++++++++++++++++------- 1 file changed, 118 insertions(+), 32 deletions(-) diff --git a/Documentation/RCU/whatisRCU.rst b/Documentation/RCU/whatisRCU.= rst index be2eb6be16ece..6c69c20086e14 100644 --- a/Documentation/RCU/whatisRCU.rst +++ b/Documentation/RCU/whatisRCU.rst @@ -1021,32 +1021,41 @@ RCU list traversal:: list_entry_rcu list_entry_lockless list_first_entry_rcu + list_first_or_null_rcu + list_tail_rcu list_next_rcu + list_next_or_null_rcu list_for_each_entry_rcu list_for_each_entry_continue_rcu list_for_each_entry_from_rcu - list_first_or_null_rcu - list_next_or_null_rcu + list_for_each_entry_lockless hlist_first_rcu hlist_next_rcu hlist_pprev_rcu hlist_for_each_entry_rcu + hlist_for_each_entry_rcu_notrace hlist_for_each_entry_rcu_bh hlist_for_each_entry_from_rcu hlist_for_each_entry_continue_rcu hlist_for_each_entry_continue_rcu_bh hlist_nulls_first_rcu + hlist_nulls_next_rcu hlist_nulls_for_each_entry_rcu + hlist_nulls_for_each_entry_safe hlist_bl_first_rcu hlist_bl_for_each_entry_rcu =20 RCU pointer/list update:: =20 rcu_assign_pointer + rcu_replace_pointer + INIT_LIST_HEAD_RCU list_add_rcu list_add_tail_rcu list_del_rcu list_replace_rcu + list_splice_init_rcu + list_splice_tail_init_rcu hlist_add_behind_rcu hlist_add_before_rcu hlist_add_head_rcu @@ -1054,34 +1063,53 @@ RCU pointer/list update:: hlist_del_rcu hlist_del_init_rcu hlist_replace_rcu - list_splice_init_rcu - list_splice_tail_init_rcu hlist_nulls_del_init_rcu hlist_nulls_del_rcu hlist_nulls_add_head_rcu + hlist_nulls_add_tail_rcu + hlist_nulls_add_fake + hlists_swap_heads_rcu hlist_bl_add_head_rcu - hlist_bl_del_init_rcu hlist_bl_del_rcu hlist_bl_set_first_rcu =20 RCU:: =20 - Critical sections Grace period Barrier - - rcu_read_lock synchronize_net rcu_barrier - rcu_read_unlock synchronize_rcu - rcu_dereference synchronize_rcu_expedited - rcu_read_lock_held call_rcu - rcu_dereference_check kfree_rcu - rcu_dereference_protected + Critical sections Grace period Barrier + + rcu_read_lock synchronize_net rcu_barrier + rcu_read_unlock synchronize_rcu + guard(rcu)() synchronize_rcu_expedited + scoped_guard(rcu) synchronize_rcu_mult + rcu_dereference call_rcu + rcu_dereference_check call_rcu_hurry + rcu_dereference_protected kfree_rcu + rcu_read_lock_held kvfree_rcu + rcu_read_lock_any_held kfree_rcu_mightsleep + rcu_pointer_handoff cond_synchronize_rcu + unrcu_pointer cond_synchronize_rcu_full + cond_synchronize_rcu_expedited + cond_synchronize_rcu_expedited_full + get_completed_synchronize_rcu + get_completed_synchronize_rcu_full + get_state_synchronize_rcu + get_state_synchronize_rcu_full + poll_state_synchronize_rcu + poll_state_synchronize_rcu_full + same_state_synchronize_rcu + same_state_synchronize_rcu_full + start_poll_synchronize_rcu + start_poll_synchronize_rcu_full + start_poll_synchronize_rcu_expedited + start_poll_synchronize_rcu_expedited_full =20 bh:: =20 Critical sections Grace period Barrier =20 - rcu_read_lock_bh call_rcu rcu_barrier - rcu_read_unlock_bh synchronize_rcu - [local_bh_disable] synchronize_rcu_expedited + rcu_read_lock_bh [Same as RCU] [Same as RCU] + rcu_read_unlock_bh + [local_bh_disable] [and friends] rcu_dereference_bh rcu_dereference_bh_check @@ -1092,9 +1120,9 @@ sched:: =20 Critical sections Grace period Barrier =20 - rcu_read_lock_sched call_rcu rcu_barrier - rcu_read_unlock_sched synchronize_rcu - [preempt_disable] synchronize_rcu_expedited + rcu_read_lock_sched [Same as RCU] [Same as RCU] + rcu_read_unlock_sched + [preempt_disable] [and friends] rcu_read_lock_sched_notrace rcu_read_unlock_sched_notrace @@ -1104,46 +1132,104 @@ sched:: rcu_read_lock_sched_held =20 =20 +RCU: Initialization/cleanup/ordering:: + + RCU_INIT_POINTER + RCU_INITIALIZER + RCU_POINTER_INITIALIZER + init_rcu_head + destroy_rcu_head + init_rcu_head_on_stack + destroy_rcu_head_on_stack + SLAB_TYPESAFE_BY_RCU + + +RCU: Quiescents states and control:: + + cond_resched_tasks_rcu_qs + rcu_all_qs + rcu_softirq_qs_periodic + rcu_end_inkernel_boot + rcu_expedite_gp + rcu_gp_is_expedited + rcu_unexpedite_gp + rcu_cpu_stall_reset + rcu_head_after_call_rcu + rcu_is_watching + + +RCU-sync primitive: + + rcu_sync_is_idle + rcu_sync_init + rcu_sync_enter + rcu_sync_exit + rcu_sync_dtor + + RCU-Tasks:: =20 - Critical sections Grace period Barrier + Critical sections Grace period Barrier =20 - N/A call_rcu_tasks rcu_barrier_tasks + N/A call_rcu_tasks rcu_barrier_tasks synchronize_rcu_tasks =20 =20 RCU-Tasks-Rude:: =20 - Critical sections Grace period Barrier + Critical sections Grace period Barrier =20 - N/A N/A - synchronize_rcu_tasks_rude + N/A synchronize_rcu_tasks_rude rcu_barrier_tasks_rude + call_rcu_tasks_rude =20 =20 RCU-Tasks-Trace:: =20 - Critical sections Grace period Barrier + Critical sections Grace period Barrier =20 - rcu_read_lock_trace call_rcu_tasks_trace rcu_barrier_tasks_trace + rcu_read_lock_trace call_rcu_tasks_trace rcu_barrier_tasks_trace rcu_read_unlock_trace synchronize_rcu_tasks_trace + guard(rcu_tasks_trace)() + scoped_guard(rcu_tasks_trace) =20 =20 -SRCU:: +SRCU list traversal:: + list_for_each_entry_srcu + hlist_for_each_entry_srcu =20 - Critical sections Grace period Barrier =20 - srcu_read_lock call_srcu srcu_barrier - srcu_read_unlock synchronize_srcu - srcu_dereference synchronize_srcu_expedited +SRCU:: + + Critical sections Grace period Barrier + + srcu_read_lock call_srcu srcu_barrier + srcu_read_unlock synchronize_srcu + srcu_read_lock_fast synchronize_srcu_expedited + srcu_read_unlock_fast get_state_synchronize_srcu + srcu_read_lock_nmisafe start_poll_synchronize_srcu + srcu_read_unlock_nmisafe start_poll_synchronize_srcu_expedited + srcu_read_lock_notrace poll_state_synchronize_srcu + srcu_read_unlock_notrace + srcu_down_read + srcu_up_read + srcu_down_read_fast + srcu_up_read_fast + guard(srcu)() + scoped_guard(srcu) + srcu_read_lock_held + srcu_dereference srcu_dereference_check + srcu_dereference_notrace srcu_read_lock_held =20 -SRCU: Initialization/cleanup:: + +SRCU: Initialization/cleanup/ordering:: =20 DEFINE_SRCU DEFINE_STATIC_SRCU init_srcu_struct cleanup_srcu_struct + smp_mb__after_srcu_read_unlock =20 All: lockdep-checked RCU utility APIs:: =20 --=20 2.40.1 From nobody Tue Oct 7 01:58:26 2025 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 A1D0D4315C; Wed, 16 Jul 2025 00:45:40 +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=1752626740; cv=none; b=WMfmnsAn0wXL4YxoX0BlLwi+/zzRVLwX7RtVH03vHz8idaN2vypH4NAuIUSLbjs7LxfEIhTZYQRHcCBXZ/gpt4gQCz3oMCVU1U6UgYbPdgvAQoBKDvReI8uhCY/bEgY7Ldb1TpKJVWpdgj2bFV6ATEBWqOJlia+6jATGuerEkAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752626740; c=relaxed/simple; bh=4hZa1H+8tV2PdJc9DZTrt0zGwOLM6dKOexYzKnOiVxU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bG6TbNaxNyqwjjqnZ8j+hCkcskzQpMJ5jAppNizloUS4ghi2vUERWOOBa0uqkGYoWfVevRjSKxnmYyxYIcG5cftfZGRJmNW3ZszHtT+8HzDW2SOyAWUu+0NsiS6O038Zh5sIRyxtYJoyCpV8aSJ4EY6gdxYqyy1Fagqyh7WoisY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g7S+46ac; 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="g7S+46ac" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49EE5C4CEE3; Wed, 16 Jul 2025 00:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752626740; bh=4hZa1H+8tV2PdJc9DZTrt0zGwOLM6dKOexYzKnOiVxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7S+46accG5J4oZExQ55dMY46B24ULY6v98TbaecdtWMFS7S2pSv3+JGc6f8LghWL JyRcQBuoW1qqXyNE4dcK8IE4MaRj6m2WmuXzgIpn41zKh9HmGMlWLID/tWu6XIfaUQ HquXw0WVa2F+vsQERQSHAYlVP0iA3BoTCyBIvmqK494jR8JqDOIZobDVtrTM8qD0kp e3xC4MKyuH70C7zLd323JjyxCUoVytAb75nAgC2gp91ouLY9BTlCKQ6sACXgVvo7cs nhmCDzhcsin7FZGG3bX0CGZvm/IcNidDQOi9nfoHL7uGkyxIdYzJLqjf73tL+Uy0VX +Gg2PRwBGHPiw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F37FBCE0ADE; Tue, 15 Jul 2025 17:45:39 -0700 (PDT) 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 RFC 2/2] doc: Add RCU guards to checklist.rst Date: Tue, 15 Jul 2025 17:45:38 -0700 Message-Id: <20250716004538.2720239-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <70015517-57ab-4d07-9792-3ab1beced9e4@paulmck-laptop> References: <70015517-57ab-4d07-9792-3ab1beced9e4@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Also note that RCU guards can be easier to use. Signed-off-by: Paul E. McKenney --- Documentation/RCU/checklist.rst | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Documentation/RCU/checklist.rst b/Documentation/RCU/checklist.= rst index 7de3e308f330f..c9bfb2b218e52 100644 --- a/Documentation/RCU/checklist.rst +++ b/Documentation/RCU/checklist.rst @@ -69,7 +69,13 @@ over a rather long period of time, but improvements are = always welcome! Explicit disabling of preemption (preempt_disable(), for example) can serve as rcu_read_lock_sched(), but is less readable and prevents lockdep from detecting locking issues. Acquiring a - spinlock also enters an RCU read-side critical section. + raw spinlock also enters an RCU read-side critical section. + + The guard(rcu)() and scoped_guard(rcu) primitives designate + the remainder of the current scope or the next statement, + respectively, as the RCU read-side critical section. Use of + these guards can be less error-prone than rcu_read_lock(), + rcu_read_unlock(), and friends. =20 Please note that you *cannot* rely on code known to be built only in non-preemptible kernels. Such code can and will break, @@ -405,9 +411,11 @@ over a rather long period of time, but improvements ar= e always welcome! 13. Unlike most flavors of RCU, it *is* permissible to block in an SRCU read-side critical section (demarked by srcu_read_lock() and srcu_read_unlock()), hence the "SRCU": "sleepable RCU". - Please note that if you don't need to sleep in read-side critical - sections, you should be using RCU rather than SRCU, because RCU - is almost always faster and easier to use than is SRCU. + As with RCU, guard(srcu)() and scoped_guard(srcu) forms are + available, and often provide greater ease of use. Please note + that if you don't need to sleep in read-side critical sections, + you should be using RCU rather than SRCU, because RCU is almost + always faster and easier to use than is SRCU. =20 Also unlike other forms of RCU, explicit initialization and cleanup is required either at build time via DEFINE_SRCU() @@ -443,10 +451,13 @@ over a rather long period of time, but improvements a= re always welcome! real-time workloads than is synchronize_rcu_expedited(). =20 It is also permissible to sleep in RCU Tasks Trace read-side - critical section, which are delimited by rcu_read_lock_trace() and - rcu_read_unlock_trace(). However, this is a specialized flavor - of RCU, and you should not use it without first checking with - its current users. In most cases, you should instead use SRCU. + critical section, which are delimited by rcu_read_lock_trace() + and rcu_read_unlock_trace(). However, this is a specialized + flavor of RCU, and you should not use it without first checking + with its current users. In most cases, you should instead + use SRCU. As with RCU and SRCU, guard(rcu_tasks_trace)() and + scoped_guard(rcu_tasks_trace) are available, and often provide + greater ease of use. =20 Note that rcu_assign_pointer() relates to SRCU just as it does to other forms of RCU, but instead of rcu_dereference() you should --=20 2.40.1