mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@kernel.org, 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, dhowells@redhat.com,
	edumazet@google.com, darren@dvhart.com, fweisbec@gmail.com,
	oleg@redhat.com, sbw@mit.edu,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH tip/core/rcu 01/19] rcu: Protect ->gp_flags accesses with ACCESS_ONCE()
Date: Mon, 28 Apr 2014 16:56:14 -0700	[thread overview]
Message-ID: <1398729392-15087-1-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140428235600.GA12200@linux.vnet.ibm.com>

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

A number of ->gp_flags accesses don't have ACCESS_ONCE(), but all of
the can race against other loads or stores.  This commit therefore
applies ACCESS_ONCE() to the unprotected ->gp_flags accesses.

Reported-by: Alexey Roytman <alexey.roytman@oracle.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcu/tree.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 0c47e300210a..2c53ac924cab 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1403,12 +1403,12 @@ static int rcu_gp_init(struct rcu_state *rsp)
 	rcu_bind_gp_kthread();
 	raw_spin_lock_irq(&rnp->lock);
 	smp_mb__after_unlock_lock();
-	if (rsp->gp_flags == 0) {
+	if (!ACCESS_ONCE(rsp->gp_flags)) {
 		/* Spurious wakeup, tell caller to go back to sleep.  */
 		raw_spin_unlock_irq(&rnp->lock);
 		return 0;
 	}
-	rsp->gp_flags = 0; /* Clear all flags: New grace period. */
+	ACCESS_ONCE(rsp->gp_flags) = 0; /* Clear all flags: New grace period. */
 
 	if (WARN_ON_ONCE(rcu_gp_in_progress(rsp))) {
 		/*
@@ -1501,7 +1501,7 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
 	if (ACCESS_ONCE(rsp->gp_flags) & RCU_GP_FLAG_FQS) {
 		raw_spin_lock_irq(&rnp->lock);
 		smp_mb__after_unlock_lock();
-		rsp->gp_flags &= ~RCU_GP_FLAG_FQS;
+		ACCESS_ONCE(rsp->gp_flags) &= ~RCU_GP_FLAG_FQS;
 		raw_spin_unlock_irq(&rnp->lock);
 	}
 	return fqs_state;
@@ -1566,7 +1566,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
 	rdp = this_cpu_ptr(rsp->rda);
 	rcu_advance_cbs(rsp, rnp, rdp);  /* Reduce false positives below. */
 	if (cpu_needs_another_gp(rsp, rdp)) {
-		rsp->gp_flags = RCU_GP_FLAG_INIT;
+		ACCESS_ONCE(rsp->gp_flags) = RCU_GP_FLAG_INIT;
 		trace_rcu_grace_period(rsp->name,
 				       ACCESS_ONCE(rsp->gpnum),
 				       TPS("newreq"));
@@ -1695,7 +1695,7 @@ rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp,
 		 */
 		return;
 	}
-	rsp->gp_flags = RCU_GP_FLAG_INIT;
+	ACCESS_ONCE(rsp->gp_flags) = RCU_GP_FLAG_INIT;
 	trace_rcu_grace_period(rsp->name, ACCESS_ONCE(rsp->gpnum),
 			       TPS("newreq"));
 
@@ -2320,7 +2320,7 @@ static void force_quiescent_state(struct rcu_state *rsp)
 		raw_spin_unlock_irqrestore(&rnp_old->lock, flags);
 		return;  /* Someone beat us to it. */
 	}
-	rsp->gp_flags |= RCU_GP_FLAG_FQS;
+	ACCESS_ONCE(rsp->gp_flags) |= RCU_GP_FLAG_FQS;
 	raw_spin_unlock_irqrestore(&rnp_old->lock, flags);
 	wake_up(&rsp->gp_wq);  /* Memory barrier implied by wake_up() path. */
 }
-- 
1.8.1.5


  reply	other threads:[~2014-04-28 23:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28 23:56 [PATCH tip/core/rcu 0/3] Miscellaneous fixes for 3.16 Paul E. McKenney
2014-04-28 23:56 ` Paul E. McKenney [this message]
2014-04-28 23:56   ` [PATCH tip/core/rcu 02/19] rcu: Fix incorrect notes for code Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 03/19] rcu: Print negatives for stall-warning counter wraparound Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 04/19] rcu: Update cpu_needs_another_gp() for futures from non-NOCB CPUs Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 05/19] rcu: Remove unused rcu_data structure field Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 06/19] rcu: Protect uses of jiffies_stall field with ACCESS_ONCE() Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 07/19] rcu: Make callers awaken grace-period kthread Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 08/19] rcu: Remove "extern" from function declaration in include/linux/rcupdate.h Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 09/19] rcu: Protect uses of ->jiffies_stall with ACCESS_ONCE() Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 10/19] rcu: Add event tracing to dyntick_save_progress_counter() Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 11/19] rcu: Replace NR_CPUS with nr_cpu_ids Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 12/19] rcu: Consolidate kfree_call_rcu() to use rcu_state pointer Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 13/19] rcu: Merge rcu_sched_force_quiescent_state() with rcu_force_quiescent_state() Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 14/19] rcu: Document RCU_INIT_POINTER()'s lack of ordering guarantees Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 15/19] rcu: Bind RCU grace-period kthreads if NO_HZ_FULL Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 16/19] rcu: Make large and small sysidle systems use same state machine Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 17/19] rcu: Remove duplicate resched_cpu() declaration Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 18/19] rcu: Replace __this_cpu_ptr() uses with raw_cpu_ptr() Paul E. McKenney
2014-04-28 23:56   ` [PATCH tip/core/rcu 19/19] softirq: A single rcu_bh_qs() call per softirq set is enough Paul E. McKenney
2014-04-29  3:23 ` [PATCH tip/core/rcu 0/3] Miscellaneous fixes for 3.16 Josh Triplett
2014-04-29 15:46   ` 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=1398729392-15087-1-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=darren@dvhart.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=niv@us.ibm.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sbw@mit.edu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®