Skip to content

Commit c071b8e

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
srcu: Improve srcu_read_lock{,_nmisafe}() comments
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 <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Neeraj Upadhyay <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 9a87bda commit c071b8e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

include/linux/srcu.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,13 @@ static inline void srcu_check_read_flavor(struct srcu_struct *ssp, int read_flav
235235
* a mutex that is held elsewhere while calling synchronize_srcu() or
236236
* synchronize_srcu_expedited().
237237
*
238-
* Note that srcu_read_lock() and the matching srcu_read_unlock() must
239-
* occur in the same context, for example, it is illegal to invoke
240-
* srcu_read_unlock() in an irq handler if the matching srcu_read_lock()
241-
* was invoked in process context.
238+
* The return value from srcu_read_lock() must be passed unaltered
239+
* to the matching srcu_read_unlock(). Note that srcu_read_lock() and
240+
* the matching srcu_read_unlock() must occur in the same context, for
241+
* example, it is illegal to invoke srcu_read_unlock() in an irq handler
242+
* if the matching srcu_read_lock() was invoked in process context. Or,
243+
* for that matter to invoke srcu_read_unlock() from one task and the
244+
* matching srcu_read_lock() from another.
242245
*/
243246
static inline int srcu_read_lock(struct srcu_struct *ssp) __acquires(ssp)
244247
{
@@ -256,6 +259,10 @@ static inline int srcu_read_lock(struct srcu_struct *ssp) __acquires(ssp)
256259
*
257260
* Enter an SRCU read-side critical section, but in an NMI-safe manner.
258261
* See srcu_read_lock() for more information.
262+
*
263+
* If srcu_read_lock_nmisafe() is ever used on an srcu_struct structure,
264+
* then none of the other flavors may be used, whether before, during,
265+
* or after.
259266
*/
260267
static inline int srcu_read_lock_nmisafe(struct srcu_struct *ssp) __acquires(ssp)
261268
{

0 commit comments

Comments
 (0)