summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2026-08-26 09:03:57 -0700
committerPaul E. McKenney <paulmck@kernel.org>2026-10-12 16:50:39 -0700
commit18c55d888b0afa3d8156b812e76c3d29a1bb2a2d (patch)
treecc2eba6e0c1fe8679f0569862166389b034862c0 /kernel
parent7fb2388e0da08cd1b3591b651736ce43144d3e6d (diff)
srcutree: Disable preemption across synchronize_srcu_atomic()
Because synchronize_srcu_atomic() cannot sleep, if a pair of them run concurrently pinned to the same CPU, it is possible that one will spin uselessly waiting for the other while at the same time preventing that other from running. This commit therefore disables preemption to prevent this failure mode. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/rcu/srcutree.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 7ff45e992c01..672fb41345c9 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -2123,11 +2123,14 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp)
// Perhaps others will do our work for us.
srcu_state = get_state_synchronize_srcu(ssp);
+ preempt_disable();
while (atomic_read(&sup->srcu_atomic_gp_flag) ||
atomic_xchg(&sup->srcu_atomic_gp_flag, 1)) {
+ preempt_enable();
if (poll_state_synchronize_srcu(ssp, srcu_state))
return;
cpu_relax();
+ preempt_disable();
}
// One last check for others doing our work for us under the lock.
@@ -2135,6 +2138,7 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp)
if (poll_state_synchronize_srcu(ssp, srcu_state)) {
raw_spin_unlock_irq_rcu_node(sup);
atomic_set(&sup->srcu_atomic_gp_flag, 0);
+ preempt_enable();
return;
}
@@ -2152,6 +2156,7 @@ void synchronize_srcu_atomic(struct srcu_struct *ssp)
}
ASSERT_EXCLUSIVE_WRITER(sup->srcu_atomic_gp_flag);
atomic_set_release(&sup->srcu_atomic_gp_flag, 0);
+ preempt_enable();
non_block_end();
}
EXPORT_SYMBOL_GPL(synchronize_srcu_atomic);