public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC tip/core/urgent] rcu: Avoid having just-onlined CPU resched itself when RCU is idle
@ 2011-08-19 16:35 Paul E. McKenney
  2011-08-19 18:01 ` [stable] " Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Paul E. McKenney @ 2011-08-19 16:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, niv, tglx,
	peterz, rostedt, Valdis.Kletnieks, dhowells, eric.dumazet, darren,
	patches, stable

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.

This patch is believed to fix or otherwise suppress problems in
https://bugzilla.redhat.com/show_bug.cgi?id=726877, however, the
relationship is not apparent to this patch's author.  That said, it is
hard to argue with test results.

This will be available from -rcu as soon as kernel.org's mirrors update:

git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent

Reported-by: Nicolas Mailhot <nicolas.mailhot@laposte.net>
Reported-by: Michal Jaegermann <michal@harddata.com>
Reported-by: Josh Boyer <jwboyer@redhat.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Tested-by: Josh Boyer <jwboyer@redhat.com>

 rcutree.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index ba06207..39cc360 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1865,8 +1865,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_quiesc = 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;
@@ -1891,8 +1889,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_quiesc = 0;
+			rdp->qs_pending = 0;
 			rdp->passed_quiesc_completed = rnp->completed - 1;
 		}
 		raw_spin_unlock(&rnp->lock); /* irqs already disabled. */

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [stable] [PATCH RFC tip/core/urgent] rcu: Avoid having just-onlined CPU resched itself when RCU is idle
  2011-08-19 16:35 [PATCH RFC tip/core/urgent] rcu: Avoid having just-onlined CPU resched itself when RCU is idle Paul E. McKenney
@ 2011-08-19 18:01 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2011-08-19 18:01 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-kernel, mathieu.desnoyers, laijs, eric.dumazet, patches,
	peterz, josh, rostedt, stable, dhowells, darren, niv, tglx,
	dipankar, Valdis.Kletnieks, mingo, akpm

On Fri, Aug 19, 2011 at 09:35:47AM -0700, Paul E. McKenney wrote:
> 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.
> 
> This patch is believed to fix or otherwise suppress problems in
> https://bugzilla.redhat.com/show_bug.cgi?id=726877, however, the
> relationship is not apparent to this patch's author.  That said, it is
> hard to argue with test results.
> 
> This will be available from -rcu as soon as kernel.org's mirrors update:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-2.6-rcu.git rcu/urgent
> 
> Reported-by: Nicolas Mailhot <nicolas.mailhot@laposte.net>
> Reported-by: Michal Jaegermann <michal@harddata.com>
> Reported-by: Josh Boyer <jwboyer@redhat.com>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Tested-by: Josh Boyer <jwboyer@redhat.com>
> 
>  rcutree.c |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read Documentation/stable_kernel_rules.txt
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-19 18:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-19 16:35 [PATCH RFC tip/core/urgent] rcu: Avoid having just-onlined CPU resched itself when RCU is idle Paul E. McKenney
2011-08-19 18:01 ` [stable] " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox