OSDN Git Service

rcu: Confine ->core_needs_qs accesses to the corresponding CPU
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 13 Sep 2019 21:09:56 +0000 (14:09 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 28 Oct 2019 14:02:21 +0000 (07:02 -0700)
commited93dfc6bc0084485ccad1ff6bd2ea81ab2c03cd
tree795726f4fab078ee48218e767f4bead620e7ab8e
parent516e5ae0c94016294d3ef175454215b235d03945
rcu: Confine ->core_needs_qs accesses to the corresponding CPU

Commit 671a63517cf9 ("rcu: Avoid unnecessary softirq when system
is idle") fixed a bug that could result in an indefinite number of
unnecessary invocations of the RCU_SOFTIRQ handler at the trailing edge
of a scheduler-clock interrupt.  However, the fix introduced off-CPU
stores to ->core_needs_qs.  These writes did not conflict with the
on-CPU stores because the CPU's leaf rcu_node structure's ->lock was
held across all such stores.  However, the loads from ->core_needs_qs
were not promoted to READ_ONCE() and, worse yet, the code loading from
->core_needs_qs was written assuming that it was only ever updated by
the corresponding CPU.  So operation has been robust, but only by luck.
This situation is therefore an accident waiting to happen.

This commit therefore takes a different approach.  Instead of clearing
->core_needs_qs from the grace-period kthread's force-quiescent-state
processing, it modifies the rcu_pending() function to suppress the
rcu_sched_clock_irq() function's call to invoke_rcu_core() if there is no
grace period in progress.  This avoids the infinite needless RCU_SOFTIRQ
handlers while still keeping all accesses to ->core_needs_qs local to
the corresponding CPU.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/tree.c