diff options
| author | Ankur Arora <ankur.a.arora@oracle.com> | 2024-12-12 20:06:55 -0800 |
|---|---|---|
| committer | Boqun Feng <boqun.feng@gmail.com> | 2025-02-05 07:01:55 -0800 |
| commit | fcf0e25ad4c8d14d2faab4d9a17040f31efce205 (patch) | |
| tree | 5e8e3598ceb8b0166f46cfd8906eb0f0f952e434 /kernel/rcu | |
| parent | sched: update __cond_resched comment about RCU quiescent states (diff) | |
| download | linux-fcf0e25ad4c8d14d2faab4d9a17040f31efce205.tar.gz linux-fcf0e25ad4c8d14d2faab4d9a17040f31efce205.zip | |
rcu: handle unstable rdp in rcu_read_unlock_strict()
rcu_read_unlock_strict() can be called with preemption enabled
which can make for an unstable rdp and a racy norm value.
Fix this by dropping the preempt-count in __rcu_read_unlock()
after the call to rcu_read_unlock_strict(), adjusting the
preempt-count check appropriately.
Suggested-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Diffstat (limited to 'kernel/rcu')
| -rw-r--r-- | kernel/rcu/tree_plugin.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 3600152b858e..9573408a9800 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -833,8 +833,17 @@ void rcu_read_unlock_strict(void) { struct rcu_data *rdp; - if (irqs_disabled() || preempt_count() || !rcu_state.gp_kthread) + if (irqs_disabled() || in_atomic_preempt_off() || !rcu_state.gp_kthread) return; + + /* + * rcu_report_qs_rdp() can only be invoked with a stable rdp and + * from the local CPU. + * + * The in_atomic_preempt_off() check ensures that we come here holding + * the last preempt_count (which will get dropped once we return to + * __rcu_read_unlock(). + */ rdp = this_cpu_ptr(&rcu_data); rdp->cpu_no_qs.b.norm = false; rcu_report_qs_rdp(rdp); |
