Skip to content

Commit 3183059

Browse files
paulmckrcuurezki
authored andcommitted
rcu: Add lockdep checks and kernel-doc header to rcu_softirq_qs()
There is some indications that rcu_softirq_qs() might be more generally used than anticipated. This commit therefore adds some lockdep assertions and some cautionary tales in a new kernel-doc header. Link: https://lore.kernel.org/all/Zd4DXTyCf17lcTfq@debian.debian/ Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Yan Zhai <yan@cloudflare.com> Cc: <netdev@vger.kernel.org> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
1 parent 39cd87c commit 3183059

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

kernel/rcu/tree.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,36 @@ static long rcu_get_n_cbs_cpu(int cpu)
240240
return 0;
241241
}
242242

243+
/**
244+
* rcu_softirq_qs - Provide a set of RCU quiescent states in softirq processing
245+
*
246+
* Mark a quiescent state for RCU, Tasks RCU, and Tasks Trace RCU.
247+
* This is a special-purpose function to be used in the softirq
248+
* infrastructure and perhaps the occasional long-running softirq
249+
* handler.
250+
*
251+
* Note that from RCU's viewpoint, a call to rcu_softirq_qs() is
252+
* equivalent to momentarily completely enabling preemption. For
253+
* example, given this code::
254+
*
255+
* local_bh_disable();
256+
* do_something();
257+
* rcu_softirq_qs(); // A
258+
* do_something_else();
259+
* local_bh_enable(); // B
260+
*
261+
* A call to synchronize_rcu() that began concurrently with the
262+
* call to do_something() would be guaranteed to wait only until
263+
* execution reached statement A. Without that rcu_softirq_qs(),
264+
* that same synchronize_rcu() would instead be guaranteed to wait
265+
* until execution reached statement B.
266+
*/
243267
void rcu_softirq_qs(void)
244268
{
269+
RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map) ||
270+
lock_is_held(&rcu_lock_map) ||
271+
lock_is_held(&rcu_sched_lock_map),
272+
"Illegal rcu_softirq_qs() in RCU read-side critical section");
245273
rcu_qs();
246274
rcu_preempt_deferred_qs(current);
247275
rcu_tasks_qs(current, false);

0 commit comments

Comments
 (0)