All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
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, dvhltc@us.ibm.com, niv@us.ibm.com,
	tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
	Valdis.Kletnieks@vt.edu, dhowells@redhat.com,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 2/2] rcu: eliminate __rcu_pending() false positives
Date: Fri, 13 Nov 2009 19:51:39 -0800	[thread overview]
Message-ID: <12581706991966-git-send-email-> (raw)
In-Reply-To: <20091114035100.GA9599@linux.vnet.ibm.com>

From: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Now that there are both ->gpnum and ->completed fields in the rcu_node
structure, __rcu_pending() should check rdp->gpnum and rdp->completed
against rnp->gpnum and rdp->completed, respectively, instead of the prior
comparison against the rcu_state fields rsp->gpnum and rsp->completed.
Given the old comparison, __rcu_pending() could return 1, resulting in
a needless raise_softirq(RCU_SOFTIRQ).  This useless work would happen
if RCU responded to a scheduling-clock interrupt after the rcu_state
fields had been updated, but before the rcu_node fields had been updated.

Changing the comparison from the rcu_state fields to the rcu_node fields
prevents this useless work from happening.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcutree.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 1089d08..e3565cd 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1390,6 +1390,8 @@ EXPORT_SYMBOL_GPL(call_rcu_bh);
  */
 static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp)
 {
+	struct rcu_node *rnp = rdp->mynode;
+
 	rdp->n_rcu_pending++;
 
 	/* Check for CPU stalls, if enabled. */
@@ -1414,13 +1416,13 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp)
 	}
 
 	/* Has another RCU grace period completed?  */
-	if (ACCESS_ONCE(rsp->completed) != rdp->completed) { /* outside lock */
+	if (ACCESS_ONCE(rnp->completed) != rdp->completed) { /* outside lock */
 		rdp->n_rp_gp_completed++;
 		return 1;
 	}
 
 	/* Has a new RCU grace period started? */
-	if (ACCESS_ONCE(rsp->gpnum) != rdp->gpnum) { /* outside lock */
+	if (ACCESS_ONCE(rnp->gpnum) != rdp->gpnum) { /* outside lock */
 		rdp->n_rp_gp_started++;
 		return 1;
 	}
-- 
1.5.2.5


  parent reply	other threads:[~2009-11-14  3:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-14  3:51 [PATCH tip/core/rcu 0/2] rcu: lastcomp cleanups, fix rcu_pending() false positives Paul E. McKenney
2009-11-14  3:51 ` [PATCH tip/core/rcu 1/2] rcu: further cleanups of use of lastcomp Paul E. McKenney
2009-11-14 10:18   ` [tip:core/rcu] rcu: Further " tip-bot for Paul E. McKenney
2009-11-14  3:51 ` Paul E. McKenney [this message]
2009-11-14 10:19   ` [tip:core/rcu] rcu: Eliminate __rcu_pending() false positives tip-bot for 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=12581706991966-git-send-email- \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=dvhltc@us.ibm.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@elte.hu \
    --cc=niv@us.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.