]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
rcu: Mark additional concurrent load from ->cpu_no_qs.b.exp
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 7 Apr 2023 23:05:38 +0000 (16:05 -0700)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:20:35 +0000 (17:20 +0200)
commit164c27d3030ec26bcea6901362d2effbbd06a179
tree9277ae7336f10b2f63cc952ce7eb263a7fc2dab0
parentde45e0bd5b643086fdae79063f557959c952114d
rcu: Mark additional concurrent load from ->cpu_no_qs.b.exp

BugLink: https://bugs.launchpad.net/bugs/2037005
[ Upstream commit 9146eb25495ea8bfb5010192e61e3ed5805ce9ef ]

The per-CPU rcu_data structure's ->cpu_no_qs.b.exp field is updated
only on the instance corresponding to the current CPU, but can be read
more widely.  Unmarked accesses are OK from the corresponding CPU, but
only if interrupts are disabled, given that interrupt handlers can and
do modify this field.

Unfortunately, although the load from rcu_preempt_deferred_qs() is always
carried out from the corresponding CPU, interrupts are not necessarily
disabled.  This commit therefore upgrades this load to READ_ONCE.

Similarly, the diagnostic access from synchronize_rcu_expedited_wait()
might run with interrupts disabled and from some other CPU.  This commit
therefore marks this load with data_race().

Finally, the C-language access in rcu_preempt_ctxt_queue() is OK as
is because interrupts are disabled and this load is always from the
corresponding CPU.  This commit adds a comment giving the rationale for
this access being safe.

This data race was reported by KCSAN.  Not appropriate for backporting
due to failure being unlikely.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
kernel/rcu/tree_exp.h
kernel/rcu/tree_plugin.h