public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Neeraj Upadhyay <neeraj.upadhyay@amd.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Zqiang <qiang.zhang1211@gmail.com>, rcu <rcu@vger.kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>,
	Frederic Weisbecker <frederic@kernel.org>
Subject: [PATCH 07/16] srcu: Improve srcu_read_lock{,_nmisafe}() comments
Date: Tue, 12 Nov 2024 15:51:50 +0100	[thread overview]
Message-ID: <20241112145159.23032-8-frederic@kernel.org> (raw)
In-Reply-To: <20241112145159.23032-1-frederic@kernel.org>

From: "Paul E. McKenney" <paulmck@kernel.org>

This commit adds some additional usage constraints to the kernel-doc
headers of srcu_read_lock() and srcu_read_lock_nmi_safe().

Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 include/linux/srcu.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 06728ef6f32a..46fd06b212ba 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -235,10 +235,13 @@ static inline void srcu_check_read_flavor(struct srcu_struct *ssp, int read_flav
  * a mutex that is held elsewhere while calling synchronize_srcu() or
  * synchronize_srcu_expedited().
  *
- * Note that srcu_read_lock() and the matching srcu_read_unlock() must
- * occur in the same context, for example, it is illegal to invoke
- * srcu_read_unlock() in an irq handler if the matching srcu_read_lock()
- * was invoked in process context.
+ * The return value from srcu_read_lock() must be passed unaltered
+ * to the matching srcu_read_unlock().  Note that srcu_read_lock() and
+ * the matching srcu_read_unlock() must occur in the same context, for
+ * example, it is illegal to invoke srcu_read_unlock() in an irq handler
+ * if the matching srcu_read_lock() was invoked in process context.  Or,
+ * for that matter to invoke srcu_read_unlock() from one task and the
+ * matching srcu_read_lock() from another.
  */
 static inline int srcu_read_lock(struct srcu_struct *ssp) __acquires(ssp)
 {
@@ -256,6 +259,10 @@ static inline int srcu_read_lock(struct srcu_struct *ssp) __acquires(ssp)
  *
  * Enter an SRCU read-side critical section, but in an NMI-safe manner.
  * See srcu_read_lock() for more information.
+ *
+ * If srcu_read_lock_nmisafe() is ever used on an srcu_struct structure,
+ * then none of the other flavors may be used, whether before, during,
+ * or after.
  */
 static inline int srcu_read_lock_nmisafe(struct srcu_struct *ssp) __acquires(ssp)
 {
-- 
2.46.0


  parent reply	other threads:[~2024-11-12 14:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 14:51 [PATCH 00/16] SRCU for v6.13 Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 01/16] srcu: Replace WARN_ON_ONCE() with BUILD_BUG_ON() if possible Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 02/16] srcu: Rename srcu_might_be_idle() to srcu_should_expedite() Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 03/16] srcu: Introduce srcu_gp_is_expedited() helper function Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 04/16] srcu: Renaming in preparation for additional reader flavor Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 05/16] srcu: Bit manipulation changes " Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 06/16] srcu: Standardize srcu_data pointers to "sdp" and similar Frederic Weisbecker
2024-11-12 14:51 ` Frederic Weisbecker [this message]
2024-11-12 14:51 ` [PATCH 08/16] srcu: Create CPP macros for normal and NMI-safe SRCU readers Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 09/16] srcu: Add srcu_read_lock_lite() and srcu_read_unlock_lite() Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 10/16] srcu: Allow inlining of __srcu_read_{,un}lock_lite() Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 11/16] rcutorture: Expand RCUTORTURE_RDR_MASK_[12] to eight bits Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 12/16] rcutorture: Add reader_flavor parameter for SRCU readers Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 13/16] rcutorture: Add srcu_read_lock_lite() support to rcutorture.reader_flavor Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 14/16] rcutorture: Add light-weight SRCU scenario Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 15/16] refscale: Add srcu_read_lock_lite() support using "srcu-lite" Frederic Weisbecker
2024-11-12 14:51 ` [PATCH 16/16] srcu: Improve srcu_read_lock_lite() kernel-doc comment Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241112145159.23032-8-frederic@kernel.org \
    --to=frederic@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@amd.com \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox