diff options
| author | Paul E. McKenney <paulmck@kernel.org> | 2026-07-16 12:53:56 -0700 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@kernel.org> | 2026-07-24 16:58:56 -0700 |
| commit | d2282f9bc75ca39a8ea5b7fe87191609985aca30 (patch) | |
| tree | 6b8ee0618937a2dcba04a1fdbe437a2532a0601a | |
| parent | d972d106965f16348f2c44035440f4926a5880d3 (diff) | |
| download | linux-next-d2282f9bc75ca39a8ea5b7fe87191609985aca30.tar.gz linux-next-d2282f9bc75ca39a8ea5b7fe87191609985aca30.zip | |
rcu: Use this_cpu_{read,write}() for ->cpu_no_qs.b.exp
Currently __this_cpu_read() and __this_cpu_write() is used to access the
->cpu_no_qs.b.exp field of the per-CPU rcu_data structure. However,
this can fail when the accesses can happen in interrupt handlers, as
recently started being exercised by rcutorture. This commit therefore
upgrades the uses of __this_cpu_read() and __this_cpu_write() to their
interrupt-safe counterparts this_cpu_read() and this_cpu_write().
KCSAN located this issue.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
| -rw-r--r-- | kernel/rcu/tree_exp.h | 4 | ||||
| -rw-r--r-- | kernel/rcu/tree_plugin.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h index 82cada459e5d..e03cb3d447a5 100644 --- a/kernel/rcu/tree_exp.h +++ b/kernel/rcu/tree_exp.h @@ -731,7 +731,7 @@ static void rcu_exp_need_qs(void) { lockdep_assert_irqs_disabled(); ASSERT_EXCLUSIVE_WRITER_SCOPED(*this_cpu_ptr(&rcu_data.cpu_no_qs.b.exp)); - __this_cpu_write(rcu_data.cpu_no_qs.b.exp, true); + this_cpu_write(rcu_data.cpu_no_qs.b.exp, true); /* Store .exp before .rcu_urgent_qs. */ smp_store_release(this_cpu_ptr(&rcu_data.rcu_urgent_qs), true); set_need_resched_current(); @@ -870,7 +870,7 @@ static void rcu_exp_handler(void *unused) ASSERT_EXCLUSIVE_WRITER_SCOPED(rdp->cpu_no_qs.b.exp); if (!(READ_ONCE(rnp->expmask) & rdp->grpmask) || - __this_cpu_read(rcu_data.cpu_no_qs.b.exp)) + this_cpu_read(rcu_data.cpu_no_qs.b.exp)) return; if (rcu_is_cpu_rrupt_from_idle() || (IS_ENABLED(CONFIG_PREEMPT_COUNT) && preempt_bh_enabled)) { diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 9ba136a4233a..c3db1ad4a280 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -599,7 +599,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags) */ static notrace bool rcu_preempt_need_deferred_qs(struct task_struct *t) { - return (__this_cpu_read(rcu_data.cpu_no_qs.b.exp) || + return (this_cpu_read(rcu_data.cpu_no_qs.b.exp) || READ_ONCE(t->rcu_read_unlock_special.s)) && rcu_preempt_depth() == 0; } @@ -981,7 +981,7 @@ static void rcu_qs(void) trace_rcu_grace_period(TPS("rcu_sched"), __this_cpu_read(rcu_data.gp_seq), TPS("cpuqs")); __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); - if (__this_cpu_read(rcu_data.cpu_no_qs.b.exp)) + if (this_cpu_read(rcu_data.cpu_no_qs.b.exp)) rcu_report_exp_rdp(this_cpu_ptr(&rcu_data)); } |
