Re: Question about usage of RCU in the input layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 22, 2009 at 06:27:37PM -0700, Paul E. McKenney wrote:
> On Sun, Mar 22, 2009 at 04:16:37PM -0700, Arjan van de Ven wrote:
> > On Sun, 22 Mar 2009 16:03:31 -0700
> > "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> wrote:

[ . . . ]

> > > But in any case, I will see what I can do about speeding up
> > > synchronize_rcu().  I will likely start with TREE_RCU, and I may need
> > > some sort of indication that boot is in progress.
> > 
> > system_state == SYSTEM_BOOTING is not a very elegant test but it works
> 
> Fair enough...  This would be until init, correct?

Here is a first attempt.  The idea is to accelerate grace-period
detection when all but one of the CPUs is in nohz state by checking
for nohz CPUs immediately upon starting a grace period, instead of
waiting for three jiffies in that case.  Lightly tested.

Not for inclusion.

Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
---

diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 97ce315..77ce937 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -373,7 +373,26 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
 	return rcu_implicit_offline_qs(rdp);
 }
 
-#endif /* #ifdef CONFIG_SMP */
+/*
+ * If almost all the other CPUs are in dyntick-idle mode, invoke
+ * force_quiescent_state() in order to make the RCU grace period
+ * happen more quickly.  The main purpose is to speed up boot
+ * on multiprocessor machines with CONFIG_NO_HZ.
+ */
+static void accelerate_almost_idle(struct rcu_state *rsp)
+{
+	if (cpumask_weight(cpu_online_mask) -
+	    cpumask_weight(nohz_cpu_mask) <= 1)
+		force_quiescent_state(rsp, 0);
+}
+
+#else /* #ifdef CONFIG_SMP */
+
+static void accelerate_almost_idle(struct rcu_state *rsp)
+{
+}
+
+#endif /* #else #ifdef CONFIG_SMP */
 
 #else /* #ifdef CONFIG_NO_HZ */
 
@@ -407,6 +426,10 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
 
 #endif /* #ifdef CONFIG_SMP */
 
+static void accelerate_almost_idle(struct rcu_state *rsp)
+{
+}
+
 #endif /* #else #ifdef CONFIG_NO_HZ */
 
 #ifdef CONFIG_RCU_CPU_STALL_DETECTOR
@@ -577,6 +600,7 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
 		rnp->qsmask = rnp->qsmaskinit;
 		rsp->signaled = RCU_SIGNAL_INIT; /* force_quiescent_state OK. */
 		spin_unlock_irqrestore(&rnp->lock, flags);
+		accelerate_almost_idle(rsp);
 		return;
 	}
 
@@ -627,6 +651,7 @@ rcu_start_gp(struct rcu_state *rsp, unsigned long flags)
 
 	rsp->signaled = RCU_SIGNAL_INIT; /* force_quiescent_state now OK. */
 	spin_unlock_irqrestore(&rsp->onofflock, flags);
+	accelerate_almost_idle(rsp);
 }
 
 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux