rcu: Make force_quiescent_state() start grace period if needed
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 4 Jan 2010 23:09:09 +0000 (15:09 -0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 13 Jan 2010 08:06:05 +0000 (09:06 +0100)
Grace periods cannot be started while force_quiescent_state() is
active.  This is OK in that the affected CPUs will try again
later, but it does induce needless grace-period delays.  This
patch causes rcu_start_gp() to record a failed attempt to start
a grace period. When force_quiescent_state() prepares to return,
it then starts the grace period if there was such a failed
attempt.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: laijs@cn.fujitsu.com
Cc: dipankar@in.ibm.com
Cc: mathieu.desnoyers@polymtl.ca
Cc: josh@joshtriplett.org
Cc: dvhltc@us.ibm.com
Cc: niv@us.ibm.com
Cc: peterz@infradead.org
Cc: rostedt@goodmis.org
Cc: Valdis.Kletnieks@vt.edu
Cc: dhowells@redhat.com
LKML-Reference: <12626465501854-git-send-email->
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/rcutree.c
kernel/rcutree.h

index d9202857d3adbc6d2fada5e3c401c4767ba2fbbd..55e8f6ef8195788a0bff13e76fadda70264ea7c5 100644 (file)
@@ -660,6 +660,8 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
        struct rcu_node *rnp = rcu_get_root(rsp);
 
        if (!cpu_needs_another_gp(rsp, rdp) || rsp->fqs_active) {
+               if (cpu_needs_another_gp(rsp, rdp))
+                       rsp->fqs_need_gp = 1;
                if (rnp->completed == rsp->completed) {
                        spin_unlock_irqrestore(&rnp->lock, flags);
                        return;
@@ -1239,6 +1241,12 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed)
                break;
        }
        rsp->fqs_active = 0;
+       if (rsp->fqs_need_gp) {
+               spin_unlock(&rsp->fqslock); /* irqs remain disabled */
+               rsp->fqs_need_gp = 0;
+               rcu_start_gp(rsp, flags); /* releases rnp->lock */
+               return;
+       }
        spin_unlock(&rnp->lock);  /* irqs remain disabled */
 unlock_fqs_ret:
        spin_unlock_irqrestore(&rsp->fqslock, flags);
index edb6fae0fa948ce220efcd74b749c3c0af78f1ad..bd5d78ad1c489a994e7225460adcfa3f2cea3053 100644 (file)
@@ -278,6 +278,11 @@ struct rcu_state {
                                                /* Force QS state. */
        u8      fqs_active;                     /* force_quiescent_state() */
                                                /*  is running. */
+       u8      fqs_need_gp;                    /* A CPU was prevented from */
+                                               /*  starting a new grace */
+                                               /*  period because */
+                                               /*  force_quiescent_state() */
+                                               /*  was running. */
        long    gpnum;                          /* Current gp number. */
        long    completed;                      /* # of last completed gp. */