From: Peter Zijlstra <peterz@infradead.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com,
dipankar@in.ibm.com, akpm@linux-foundation.org,
mathieu.desnoyers@efficios.com, josh@joshtriplett.org,
tglx@linutronix.de, rostedt@goodmis.org, dhowells@redhat.com,
edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com,
joel@joelfernandes.org
Subject: Re: [PATCH tip/core/rcu 4/4] srcu: Add READ_ONCE() to srcu_struct ->srcu_gp_seq load
Date: Tue, 18 Feb 2020 12:46:31 +0100 [thread overview]
Message-ID: <20200218114631.GY14914@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200217230657.GA8985@paulmck-ThinkPad-P72>
On Mon, Feb 17, 2020 at 03:06:57PM -0800, Paul E. McKenney wrote:
> commit 52324a7b8a025f47a1a1a9fbd23ffe59fa764764
> Author: Paul E. McKenney <paulmck@kernel.org>
> Date: Fri Jan 3 11:42:05 2020 -0800
>
> srcu: Hold srcu_struct ->lock when updating ->srcu_gp_seq
>
> A read of the srcu_struct structure's ->srcu_gp_seq field should not
> need READ_ONCE() when that structure's ->lock is held. Except that this
> lock is not always held when updating this field. This commit therefore
> acquires the lock around updates and removes a now-unneeded READ_ONCE().
>
> This data race was reported by KCSAN.
>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index 119a373..c19c1df 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -450,7 +450,7 @@ static void srcu_gp_start(struct srcu_struct *ssp)
> spin_unlock_rcu_node(sdp); /* Interrupts remain disabled. */
> smp_mb(); /* Order prior store to ->srcu_gp_seq_needed vs. GP start. */
> rcu_seq_start(&ssp->srcu_gp_seq);
> - state = rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq));
> + state = rcu_seq_state(ssp->srcu_gp_seq);
> WARN_ON_ONCE(state != SRCU_STATE_SCAN1);
> }
>
> @@ -1130,7 +1130,9 @@ static void srcu_advance_state(struct srcu_struct *ssp)
> return; /* readers present, retry later. */
> }
> srcu_flip(ssp);
> + spin_lock_irq_rcu_node(ssp);
> rcu_seq_set_state(&ssp->srcu_gp_seq, SRCU_STATE_SCAN2);
> + spin_unlock_irq_rcu_node(ssp);
> }
>
> if (rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq)) == SRCU_STATE_SCAN2) {
next prev parent reply other threads:[~2020-02-18 11:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-15 0:29 [PATCH tip/core/rcu 0/4] SRCU updates for v5.7 Paul E. McKenney
2020-02-15 0:29 ` [PATCH tip/core/rcu 1/4] srcu: Fix __call_srcu()/process_srcu() datarace paulmck
2020-02-17 12:42 ` Peter Zijlstra
2020-02-17 17:01 ` Joel Fernandes
2020-02-17 17:11 ` Peter Zijlstra
2020-02-17 17:46 ` Joel Fernandes
2020-02-17 18:18 ` Paul E. McKenney
2020-02-15 0:29 ` [PATCH tip/core/rcu 2/4] srcu: Fix __call_srcu()/srcu_get_delay() datarace paulmck
2020-02-15 0:29 ` [PATCH tip/core/rcu 3/4] srcu: Fix process_srcu()/srcu_batches_completed() datarace paulmck
2020-02-15 0:29 ` [PATCH tip/core/rcu 4/4] srcu: Add READ_ONCE() to srcu_struct ->srcu_gp_seq load paulmck
2020-02-17 12:45 ` Peter Zijlstra
2020-02-17 18:32 ` Paul E. McKenney
2020-02-17 23:06 ` Paul E. McKenney
2020-02-18 11:46 ` Peter Zijlstra [this message]
2020-02-18 21:48 ` Paul E. McKenney
2020-02-18 11:43 ` Peter Zijlstra
2020-02-18 16:34 ` Paul E. McKenney
2020-02-18 20:26 ` Peter Zijlstra
2020-02-18 21:38 ` 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=20200218114631.GY14914@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).