From patchwork Fri Aug 19 16:35:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 3573 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 34DB223F41 for ; Fri, 19 Aug 2011 16:37:12 +0000 (UTC) Received: from mail-gw0-f52.google.com (mail-gw0-f52.google.com [74.125.83.52]) by fiordland.canonical.com (Postfix) with ESMTP id CE2F8A18160 for ; Fri, 19 Aug 2011 16:37:11 +0000 (UTC) Received: by gwj15 with SMTP id 15so2566323gwj.11 for ; Fri, 19 Aug 2011 09:37:11 -0700 (PDT) Received: by 10.150.68.26 with SMTP id q26mr2463362yba.276.1313771831251; Fri, 19 Aug 2011 09:37:11 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.150.157.17 with SMTP id f17cs106498ybe; Fri, 19 Aug 2011 09:37:10 -0700 (PDT) Received: by 10.236.181.97 with SMTP id k61mr9056870yhm.101.1313771829749; Fri, 19 Aug 2011 09:37:09 -0700 (PDT) Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com [32.97.182.137]) by mx.google.com with ESMTPS id v45si10775848yhd.132.2011.08.19.09.37.09 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Aug 2011 09:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.137 as permitted sender) client-ip=32.97.182.137; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.182.137 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p7JGAeZw015809 for ; Fri, 19 Aug 2011 12:10:40 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7JGZqIx248714 for ; Fri, 19 Aug 2011 12:35:52 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7JGZmIm004678 for ; Fri, 19 Aug 2011 12:35:51 -0400 Received: from paulmck-ThinkPad-W500 ([9.47.24.65]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p7JGZmE6004652; Fri, 19 Aug 2011 12:35:48 -0400 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id E3C9E13F804; Fri, 19 Aug 2011 09:35:47 -0700 (PDT) Date: Fri, 19 Aug 2011 09:35:47 -0700 From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, patches@linaro.org, stable@kernel.org Subject: [PATCH RFC tip/core/urgent] rcu: Avoid having just-onlined CPU resched itself when RCU is idle Message-ID: <20110819163547.GA5182@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 Reported-by: Michal Jaegermann Reported-by: Josh Boyer Signed-off-by: Paul E. McKenney Tested-by: Josh Boyer 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. */