From patchwork Fri Jun 22 15:37:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 9582 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 DB09323E37 for ; Fri, 22 Jun 2012 15:45:18 +0000 (UTC) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by fiordland.canonical.com (Postfix) with ESMTP id 8A90BA18302 for ; Fri, 22 Jun 2012 15:45:18 +0000 (UTC) Received: by yhjj63 with SMTP id j63so1943660yhj.37 for ; Fri, 22 Jun 2012 08:45:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:reply-to:mime-version:content-type :content-disposition:user-agent:x-content-scanned:x-cbid :x-gm-message-state; bh=/7rIFt16ya1S8hnFqeJCUkgrc4Pixkv34Bi06DQu1B8=; b=JZ3vyl6xi7GdDv5JEVh0YQvxHOr+4Rw+XokhIjVEX2XRz3wmT3vutXwo6bDOekA7kU g62G6kV6gPRNRNO5PrTMjcCplmNBaAt4FViviKDWbIx2glnrqK66+LejjSFJF24o2WVl jbcjgH/Q7emW0arK73ZExflhzncgpGh1UkfqIMK+fjDGB2jVXHCJ8EQ0Glxpy/pLFFSJ bRMBT6qOKpAWYKu1Glb/sIPYg7W0JORUPst59S6Jv+wAuEBkWxcrigNxXOhJKI9Bzj+n JoK71jslEYVDnrsXHsJU9sJvL4/pWdF4SLqwefVZiHyXy1rZI1n0jMgs8LGL8Eq82RIs 81rg== Received: by 10.50.203.39 with SMTP id kn7mr2073561igc.53.1340379917817; Fri, 22 Jun 2012 08:45:17 -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.231.24.148 with SMTP id v20csp72830ibb; Fri, 22 Jun 2012 08:45:17 -0700 (PDT) Received: by 10.68.218.7 with SMTP id pc7mr11090969pbc.88.1340379916987; Fri, 22 Jun 2012 08:45:16 -0700 (PDT) Received: from e37.co.us.ibm.com (e37.co.us.ibm.com. [32.97.110.158]) by mx.google.com with ESMTPS id jr5si2934456pbc.291.2012.06.22.08.45.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jun 2012 08:45:16 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.158 as permitted sender) client-ip=32.97.110.158; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.158 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Jun 2012 09:45:15 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 22 Jun 2012 09:45:14 -0600 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 76234C40017 for ; Fri, 22 Jun 2012 15:45:01 +0000 (WET) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5MFidh3263306 for ; Fri, 22 Jun 2012 09:44:44 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5MFiX7r030771 for ; Fri, 22 Jun 2012 09:44:35 -0600 Received: from paulmck-ThinkPad-W500 ([9.47.24.152]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5MFiXl6030746; Fri, 22 Jun 2012 09:44:33 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 8C3E1E71A0; Fri, 22 Jun 2012 08:37:38 -0700 (PDT) Date: Fri, 22 Jun 2012 08:37:38 -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@efficios.com, 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, fweisbec@gmail.com, sbw@mit.edu, patches@linaro.org Subject: [PATCH tip/core/urgent] rcu: Stop rcu_do_batch() from multiplexing the "count" variable Message-ID: <20120622153738.GA6800@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12062215-7408-0000-0000-0000061D7C6F X-Gm-Message-State: ALoCoQloaT90SsPmrcYCczRiiN9YKmHw8sBjrlzRFWKVbtFE7xhRnXJQTysEYtYczkmgBN/qVZgX Commit b1420f1c (Make rcu_barrier() less disruptive) rearranged the code in rcu_do_batch(), moving the ->qlen manipulation to follow the requeueing of the callbacks. Unfortunately, this rearrangement clobbered the value of the "count" local variable before the value of rdp->qlen was adjusted, resulting in the value of rdp->qlen being inaccurate. This commit therefore introduces an index variable "i", avoiding the inadvertent multiplexing. Signed-off-by: Paul E. McKenney Signed-off-by: Paul E. McKenney Reviewed-by: Josh Triplett diff --git a/kernel/rcutree.c b/kernel/rcutree.c index 2f34d02..2001d38 100644 --- a/kernel/rcutree.c +++ b/kernel/rcutree.c @@ -1593,7 +1593,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) { unsigned long flags; struct rcu_head *next, *list, **tail; - int bl, count, count_lazy; + int bl, count, count_lazy, i; /* If no callbacks are ready, just return.*/ if (!cpu_has_callbacks_ready_to_invoke(rdp)) { @@ -1616,9 +1616,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) rdp->nxtlist = *rdp->nxttail[RCU_DONE_TAIL]; *rdp->nxttail[RCU_DONE_TAIL] = NULL; tail = rdp->nxttail[RCU_DONE_TAIL]; - for (count = RCU_NEXT_SIZE - 1; count >= 0; count--) - if (rdp->nxttail[count] == rdp->nxttail[RCU_DONE_TAIL]) - rdp->nxttail[count] = &rdp->nxtlist; + for (i = RCU_NEXT_SIZE - 1; i >= 0; i--) + if (rdp->nxttail[i] == rdp->nxttail[RCU_DONE_TAIL]) + rdp->nxttail[i] = &rdp->nxtlist; local_irq_restore(flags); /* Invoke callbacks. */ @@ -1646,9 +1646,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) if (list != NULL) { *tail = rdp->nxtlist; rdp->nxtlist = list; - for (count = 0; count < RCU_NEXT_SIZE; count++) - if (&rdp->nxtlist == rdp->nxttail[count]) - rdp->nxttail[count] = tail; + for (i = 0; i < RCU_NEXT_SIZE; i++) + if (&rdp->nxtlist == rdp->nxttail[i]) + rdp->nxttail[i] = tail; else break; }