aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcutree.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2012-09-17 17:32:58 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2012-09-23 10:41:52 -0400
commit79bce6724366b3827c5c673fb07d7063082873cf (patch)
tree87b02ed03a42a194324e369152049246ceb091e2 /kernel/rcutree.c
parentb3dbec76e5334fbb063987dea14e7b255602d7e4 (diff)
rcu: Prevent initialization-time quiescent-state race
The next step in reducing RCU's grace-period initialization latency on large systems will make this initialization preemptible. Unfortunately, making the grace-period initialization subject to interrupts (let alone preemption) exposes the following race on systems whose rcu_node tree contains more than one node: 1. CPU 31 starts initializing the grace period, including the first leaf rcu_node structures, and is then preempted. 2. CPU 0 refers to the first leaf rcu_node structure, and notes that a new grace period has started. It passes through a quiescent state shortly thereafter, and informs the RCU core of this rite of passage. 3. CPU 0 enters an RCU read-side critical section, acquiring a pointer to an RCU-protected data item. 4. CPU 31 takes an interrupt whose handler removes the data item referenced by CPU 0 from the data structure, and registers an RCU callback in order to free it. 5. CPU 31 resumes initializing the grace period, including its own rcu_node structure. In invokes rcu_start_gp_per_cpu(), which advances all callbacks, including the one registered in #4 above, to be handled by the current grace period. 6. The remaining CPUs pass through quiescent states and inform the RCU core, but CPU 0 remains in its RCU read-side critical section, still referencing the now-removed data item. 7. The grace period completes and all the callbacks are invoked, including the one that frees the data item that CPU 0 is still referencing. Oops!!! One way to avoid this race is to remove grace-period acceleration from rcu_start_gp_per_cpu(). Now, the only reason for this acceleration was to allow CPUs bringing RCU out of idle state to have their callbacks invoked after only one grace period, rather than the two grace periods that would otherwise be required. But this acceleration does not work when RCU grace-period initialization is moved to a kthread because the CPU posting the callback is no longer necessarily the CPU that is initializing the resulting grace period. This commit therefore removes this now-pointless (and soon to be dangerous) grace-period acceleration, thus avoiding the above race. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/rcutree.c')
-rw-r--r--kernel/rcutree.c14
1 files changed, 0 insertions, 14 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 4792f1642bf2..e7a534498aa0 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1023,20 +1023,6 @@ rcu_start_gp_per_cpu(struct rcu_state *rsp, struct rcu_node *rnp, struct rcu_dat
1023 /* Prior grace period ended, so advance callbacks for current CPU. */ 1023 /* Prior grace period ended, so advance callbacks for current CPU. */
1024 __rcu_process_gp_end(rsp, rnp, rdp); 1024 __rcu_process_gp_end(rsp, rnp, rdp);
1025 1025
1026 /*
1027 * Because this CPU just now started the new grace period, we know
1028 * that all of its callbacks will be covered by this upcoming grace
1029 * period, even the ones that were registered arbitrarily recently.
1030 * Therefore, advance all outstanding callbacks to RCU_WAIT_TAIL.
1031 *
1032 * Other CPUs cannot be sure exactly when the grace period started.
1033 * Therefore, their recently registered callbacks must pass through
1034 * an additional RCU_NEXT_READY stage, so that they will be handled
1035 * by the next RCU grace period.
1036 */
1037 rdp->nxttail[RCU_NEXT_READY_TAIL] = rdp->nxttail[RCU_NEXT_TAIL];
1038 rdp->nxttail[RCU_WAIT_TAIL] = rdp->nxttail[RCU_NEXT_TAIL];
1039
1040 /* Set state so that this CPU will detect the next quiescent state. */ 1026 /* Set state so that this CPU will detect the next quiescent state. */
1041 __note_new_gpnum(rsp, rnp, rdp); 1027 __note_new_gpnum(rsp, rnp, rdp);
1042} 1028}