]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
doc: Spinlocks are implied RCU readers
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 24 Nov 2023 22:55:37 +0000 (14:55 -0800)
committerBoqun Feng <boqun.feng@gmail.com>
Wed, 14 Feb 2024 15:53:49 +0000 (07:53 -0800)
In kernels built with CONFIG_PREEMPT_RT=n, spinlock critical sections
are RCU readers because they disable preemption.  However, they are also
RCU readers in CONFIG_PREEMPT_RT=y because the -rt locking primitives
contain rcu_read_lock() and rcu_read_unlock().  Therefore, upgrade
rcu_dereference.rst to document this non-obvious case.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Closes: https://lore.kernel.org/lkml/CAHk-=whGKvjHCtJ6W4pQ0_h_k9fiFQ8V2GpM=BqYnB2X=SJ+XQ@mail.gmail.com/
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Documentation/RCU/rcu_dereference.rst

index 659d5913784d0d9e2d196a04bdfb7fadb57d5eed..2524dcdadde2b801b33a4ce0a93f31948ea7aefb 100644 (file)
@@ -408,7 +408,10 @@ member of the rcu_dereference() to use in various situations:
        RCU flavors, an RCU read-side critical section is entered
        using rcu_read_lock(), anything that disables bottom halves,
        anything that disables interrupts, or anything that disables
-       preemption.
+       preemption.  Please note that spinlock critical sections
+       are also implied RCU read-side critical sections, even when
+       they are preemptible, as they are in kernels built with
+       CONFIG_PREEMPT_RT=y.
 
 2.     If the access might be within an RCU read-side critical section
        on the one hand, or protected by (say) my_lock on the other,