linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Arjan van de Ven <arjan@infradead.org>
Cc: Eric Dumazet <dada1@cosmosbay.com>,
	dipankar@in.ibm.com, linux-input@vger.kernel.org,
	dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: Question about usage of RCU in the input layer
Date: Thu, 2 Apr 2009 18:27:33 -0700	[thread overview]
Message-ID: <20090403012733.GA26871@linux.vnet.ibm.com> (raw)
In-Reply-To: <20090323012737.GO7148@linux.vnet.ibm.com>

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@linux.vnet.ibm.com> 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@linux.vnet.ibm.com>
---

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);
 }
 
 /*

  reply	other threads:[~2009-04-03  1:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19  4:58 Question about usage of RCU in the input layer Arjan van de Ven
2009-03-19  7:23 ` Dmitry Torokhov
2009-03-19 14:02   ` Arjan van de Ven
2009-03-19  8:56 ` Dipankar Sarma
2009-03-19 14:18   ` Arjan van de Ven
2009-03-20  2:07     ` Paul E. McKenney
2009-03-20  3:20       ` Arjan van de Ven
2009-03-20  4:45         ` Paul E. McKenney
2009-03-20  5:28           ` Eric Dumazet
2009-03-20  6:01             ` Dipankar Sarma
2009-03-20  6:35               ` Eric Dumazet
2009-03-20 13:50           ` Arjan van de Ven
2009-03-20 14:31             ` Paul E. McKenney
2009-03-20 18:13               ` Arjan van de Ven
2009-03-21  1:27                 ` Paul E. McKenney
2009-03-21  4:58                   ` Arjan van de Ven
2009-03-21 18:58                     ` Paul E. McKenney
2009-03-21 19:51                   ` Arjan van de Ven
2009-03-21 20:26                     ` Eric Dumazet
2009-03-21 21:07                       ` Paul E. McKenney
2009-03-22  3:40                         ` Arjan van de Ven
2009-03-22  4:38                           ` Paul E. McKenney
2009-03-22  4:51                             ` Arjan van de Ven
2009-03-22  5:18                               ` Paul E. McKenney
2009-03-22  5:53                                 ` Arjan van de Ven
2009-03-22 16:53                                   ` Paul E. McKenney
2009-03-22 19:46                                     ` Arjan van de Ven
2009-03-22 20:52                                       ` Paul E. McKenney
2009-03-22 22:44                                         ` Arjan van de Ven
2009-03-22 23:03                                           ` Paul E. McKenney
2009-03-22 23:16                                             ` Arjan van de Ven
2009-03-23  1:27                                               ` Paul E. McKenney
2009-04-03  1:27                                                 ` Paul E. McKenney [this message]
2009-03-21 21:13                       ` Arjan van de Ven
2009-03-20 22:21               ` Paul E. McKenney
2009-03-21  5:46         ` Dmitry Torokhov
2009-03-21  9:13           ` Eric Dumazet
2009-03-21 18:58             ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090403012733.GA26871@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=arjan@infradead.org \
    --cc=dada1@cosmosbay.com \
    --cc=dipankar@in.ibm.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).