]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rcu: Avoid having just-onlined CPU resched itself when RCU is idle
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sun, 14 Aug 2011 22:56:54 +0000 (15:56 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 12 Sep 2011 17:10:27 +0000 (10:10 -0700)
CPUs set rdp->qs_pending when coming online to resolve races with
grace-period start.  However, this means that if RCU is idle, the
just-onlined CPU might needlessly send itself resched IPIs.  Adjust
the online-CPU initialization to avoid this, and also to correctly
cause the CPU to respond to the current grace period if needed.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Tested-by: Josh Boyer <jwboyer@redhat.com>
Tested-by: Christian Hoffmann <email@christianhoffmann.info>
kernel/rcutree.c

index ade788320dd6ad7319180bb76bcc732e7c2fd18e..c95fa89ffef9d4bce14b3dc272e55aba5c8055ef 100644 (file)
@@ -1911,8 +1911,6 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
 
        /* Set up local state, ensuring consistent view of global state. */
        raw_spin_lock_irqsave(&rnp->lock, flags);
-       rdp->passed_quiesce = 0;  /* We could be racing with new GP, */
-       rdp->qs_pending = 1;     /*  so set up to respond to current GP. */
        rdp->beenonline = 1;     /* We have now been online. */
        rdp->preemptible = preemptible;
        rdp->qlen_last_fqs_check = 0;
@@ -1937,8 +1935,15 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
                rnp->qsmaskinit |= mask;
                mask = rnp->grpmask;
                if (rnp == rdp->mynode) {
-                       rdp->gpnum = rnp->completed; /* if GP in progress... */
+                       /*
+                        * If there is a grace period in progress, we will
+                        * set up to wait for it next time we run the
+                        * RCU core code.
+                        */
+                       rdp->gpnum = rnp->completed;
                        rdp->completed = rnp->completed;
+                       rdp->passed_quiesce = 0;
+                       rdp->qs_pending = 0;
                        rdp->passed_quiesce_gpnum = rnp->gpnum - 1;
                        trace_rcu_grace_period(rsp->name, rdp->gpnum, "cpuonl");
                }