From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org, mingo@kernel.org,
jiangshanlai@gmail.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, dhowells@redhat.com,
edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com
Subject: Re: [PATCH tip/core/rcu 1/9] rcu: Provide GP ordering in face of migrations and delays
Date: Thu, 5 Oct 2017 10:13:04 -0400 [thread overview]
Message-ID: <20171005101304.2abca088@gandalf.local.home> (raw)
In-Reply-To: <20171005134042.ccftrgkay7pvbw3g@hirez.programming.kicks-ass.net>
On Thu, 5 Oct 2017 15:40:42 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> On Thu, Oct 05, 2017 at 09:17:03AM -0400, Steven Rostedt wrote:
> > On Wed, 4 Oct 2017 14:29:27 -0700
> > "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:
> >
> > > Consider the following admittedly improbable sequence of events:
> > >
> > > o RCU is initially idle.
> > >
> > > o Task A on CPU 0 executes rcu_read_lock().
> >
> > A starts rcu_read_lock() critical section.
> >
> > >
> > > o Task B on CPU 1 executes synchronize_rcu(), which must
> > > wait on Task A:
> >
> > B waits for A.
> >
> > >
> > > o Task B registers the callback, which starts a new
> > > grace period, awakening the grace-period kthread
> > > on CPU 3, which immediately starts a new grace period.
> >
> > [ isn't B blocked (off rq)? How does it migrate? ]
>
> No, its running synchronize_rcu() but hasn't blocked yet. It would block
> on wait_for_completion(), but per the very last point, we'll observe the
> complete() before we block.
Hmm, maybe this should be stated as well, as it looked confusing.
>
> > > o Task B migrates to CPU 2, which provides a quiescent
> > > state for both CPUs 1 and 2.
> > >
> > > o Both CPUs 1 and 2 take scheduling-clock interrupts,
> > > and both invoke RCU_SOFTIRQ, both thus learning of the
> > > new grace period.
> > >
> > > o Task B is delayed, perhaps by vCPU preemption on CPU 2.
> > >
> > > o CPUs 2 and 3 pass through quiescent states, which are reported
> > > to core RCU.
> > >
> > > o Task B is resumed just long enough to be migrated to CPU 3,
> > > and then is once again delayed.
> > >
> > > o Task A executes rcu_read_unlock(), exiting its RCU read-side
> > > critical section.
> >
> > A calls rcu_read_unlock() ending the critical section
>
> The point is that rcu_read_unlock() doesn't have memory ordering.
Ah, that makes a difference. Can we state that in the change log too.
>
> > >
> > > o CPU 0 passes through a quiescent sate, which is reported to
> > > core RCU. Only CPU 1 continues to block the grace period.
> > >
> > > o CPU 1 passes through a quiescent state, which is reported to
> > > core RCU. This ends the grace period, and CPU 1 therefore
> > > invokes its callbacks, one of which awakens Task B via
> > > complete().
> > >
> > > o Task B resumes (still on CPU 3) and starts executing
> > > wait_for_completion(), which sees that the completion has
> > > already completed, and thus does not block. It returns from
> > > the synchronize_rcu() without any ordering against the
> > > end of Task A's RCU read-side critical section.
> >
> > B runs
> >
> >
> > >
> > > It can therefore mess up Task A's RCU read-side critical section,
> > > in theory, anyway.
> >
> > I don't see how B ran during A's critical section.
>
> It didn't but that doesn't mean the memory ordering agrees. What we
> require is B observes (per the memory ordering) everything up to and
> including the rcu_read_unlock(). This is not 'time' related.
OK, that makes sense. It was just missing from the change log, so mere
mortals like myself can keep up. (This is why I'm Batman. I'm only
human but I can still compete with superheros ;-)
>
>
> That said, I don't think it can actually happen, because CPU0's QS state
> is ordered against the complete and the wait_for_completion is ordered
> against the complete.
OK, but this doesn't hurt to have. Just a paranoid check, which when it
comes to RCU, leaning toward paranoid is good.
-- Steve
next prev parent reply other threads:[~2017-10-05 14:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 21:29 [PATCH tip/core/rcu 0/9] Miscellaneous fixes for v4.15 Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 1/9] rcu: Provide GP ordering in face of migrations and delays Paul E. McKenney
2017-10-05 9:41 ` Peter Zijlstra
2017-10-05 14:55 ` Paul E. McKenney
2017-10-05 15:39 ` Peter Zijlstra
2017-10-05 16:19 ` Paul E. McKenney
2017-10-05 16:25 ` Peter Zijlstra
2017-10-05 18:22 ` Paul E. McKenney
2017-10-06 9:07 ` Peter Zijlstra
2017-10-06 19:18 ` Paul E. McKenney
2017-10-06 20:15 ` Peter Zijlstra
2017-10-07 3:31 ` Paul E. McKenney
2017-10-07 9:29 ` Peter Zijlstra
2017-10-07 18:28 ` Paul E. McKenney
2017-10-09 8:16 ` Peter Zijlstra
2017-10-09 14:37 ` Andrea Parri
2017-10-09 23:15 ` Paul E. McKenney
2017-10-05 13:17 ` Steven Rostedt
2017-10-05 13:40 ` Peter Zijlstra
2017-10-05 14:13 ` Steven Rostedt [this message]
2017-10-04 21:29 ` [PATCH tip/core/rcu 2/9] rcu: Fix up pending cbs check in rcu_prepare_for_idle Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 3/9] rcu: Create call_rcu_tasks() kthread at boot time Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 4/9] irq_work: Map irq_work_on_queue() to irq_work_on() in !SMP Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 5/9] srcu: Add parameters to SRCU docbook comments Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 6/9] sched: Make resched_cpu() unconditional Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 7/9] rcu: Pretend ->boost_mtx acquired legitimately Paul E. McKenney
2017-10-05 9:50 ` Peter Zijlstra
2017-10-05 15:06 ` Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 8/9] rcu: Add extended-quiescent-state testing advice Paul E. McKenney
2017-10-04 21:29 ` [PATCH tip/core/rcu 9/9] rcu/segcblist: Include rcupdate.h 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=20171005101304.2abca088@gandalf.local.home \
--to=rostedt@goodmis.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=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®