From: "Paul E. McKenney" <paulmck@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: tglx@linutronix.de, x86@kernel.org, elver@google.com,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
will@kernel.org, dvyukov@google.com, glider@google.com,
andreyknvl@google.com
Subject: Re: [PATCH 2/9] rcu: Fixup noinstr warnings
Date: Thu, 4 Jun 2020 07:17:26 -0700 [thread overview]
Message-ID: <20200604141726.GZ29598@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20200604080512.GA2587@hirez.programming.kicks-ass.net>
On Thu, Jun 04, 2020 at 10:05:12AM +0200, Peter Zijlstra wrote:
> On Wed, Jun 03, 2020 at 08:34:09PM -0700, Paul E. McKenney wrote:
> > On Wed, Jun 03, 2020 at 07:13:20PM +0200, Peter Zijlstra wrote:
> > > On Wed, Jun 03, 2020 at 09:46:00AM -0700, Paul E. McKenney wrote:
>
> > > > > @@ -313,7 +313,7 @@ static __always_inline bool rcu_dynticks
> > > > > {
> > > > > struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
> > > > >
> > > > > - return !(atomic_read(&rdp->dynticks) & RCU_DYNTICK_CTRL_CTR);
> > > > > + return !(arch_atomic_read(&rdp->dynticks) & RCU_DYNTICK_CTRL_CTR);
> > >
> > > The above is actually instrumented by KCSAN, due to arch_atomic_read()
> > > being a READ_ONCE() and it now understanding volatile.
> > >
> > > > Also instrument_atomic_write(&rdp->dynticks, sizeof(rdp->dynticks)) as
> >
> > Right, this should instead be instrument_read(...).
> >
> > Though if KCSAN is unconditionally instrumenting volatile, how does
> > this help? Or does KCSAN's instrumentation of volatile somehow avoid
> > causing trouble?
>
> As Marco already explained, when used inside noinstr no instrumentation
> will be emitted, when used outside noinstr it will emit the right
> instrumentation.
>
> > > > o In theory in rcu_irq_exit_preempt(), but as this generates code
> > > > only in lockdep builds, it might not be worth worrying about.
> > > >
> > > > o Ditto for rcu_irq_exit_check_preempt().
> > > >
> > > > o Ditto for __rcu_irq_enter_check_tick().
> > >
> > > Not these, afaict they're all the above arch_atomic_read(), which is
> > > instrumented due to volatile in these cases.
>
> I this case, the above call-sites are all not noinstr (double negative!)
> and will thus cause instrumentation to be emitted.
>
> This is all a 'special' case for arch_atomic_read() (and _set()),
> because they're basically READ_ONCE() (and WRITE_ONCE() resp.). The
> normal atomics are asm() and it doesn't do anything for those (although
> I suppose clang could, since it has this internal assembler to parse the
> inline asm, but afaiu that's not something GCC ever wants to do).
Got it, and I had missed the inlining.
Again, commenting this will be interesting. And your earlier comment
about the compiler refusing to inline now makes sense...
Thanx, Paul
next prev parent reply other threads:[~2020-06-04 14:17 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 11:40 [PATCH 0/9] x86/entry fixes Peter Zijlstra
2020-06-03 11:40 ` [PATCH 1/9] x86/entry: Fix irq_exit() Peter Zijlstra
2020-06-03 11:40 ` [PATCH 2/9] rcu: Fixup noinstr warnings Peter Zijlstra
2020-06-03 16:46 ` Paul E. McKenney
2020-06-03 17:13 ` Peter Zijlstra
2020-06-04 3:34 ` Paul E. McKenney
2020-06-04 6:02 ` Marco Elver
2020-06-04 14:14 ` Paul E. McKenney
2020-06-04 8:05 ` Peter Zijlstra
2020-06-04 14:17 ` Paul E. McKenney [this message]
2020-06-15 15:30 ` Peter Zijlstra
2020-06-15 15:52 ` Paul E. McKenney
2020-06-15 16:06 ` Peter Zijlstra
2020-06-15 15:49 ` Peter Zijlstra
2020-06-15 15:55 ` Peter Zijlstra
2020-06-15 16:24 ` Peter Zijlstra
2020-06-15 17:14 ` Paul E. McKenney
2020-06-15 18:33 ` Peter Zijlstra
2020-06-15 18:59 ` Paul E. McKenney
2020-06-15 20:00 ` Paul E. McKenney
2020-06-19 22:15 ` Paul E. McKenney
2020-06-23 20:46 ` Peter Zijlstra
2020-06-23 21:44 ` Paul E. McKenney
2020-06-24 7:52 ` Peter Zijlstra
2020-06-24 13:03 ` Paul E. McKenney
2020-06-03 11:40 ` [PATCH 3/9] x86/entry: __always_inline debugreg for noinstr Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 4/9] x86/entry: __always_inline irqflags " Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 5/9] x86/entry: __always_inline arch_atomic_* " Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 6/9] x86/entry: Re-order #DB handler to avoid *SAN instrumentation Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 7/9] lockdep: __always_inline more for noinstr Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 8/9] x86/entry: __always_inline CR2 " Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 11:40 ` [PATCH 9/9] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline() Peter Zijlstra
2020-06-03 17:50 ` [tip: x86/entry] " tip-bot2 for Peter Zijlstra
2020-06-03 12:00 ` [PATCH 0/9] x86/entry fixes Peter Zijlstra
2020-06-03 12:08 ` Peter Zijlstra
2020-06-03 12:08 ` Marco Elver
2020-06-03 12:18 ` Peter Zijlstra
2020-06-03 13:32 ` Marco Elver
2020-06-03 14:47 ` Marco Elver
2020-06-03 16:07 ` Peter Zijlstra
2020-06-03 17:26 ` Marco Elver
2020-06-03 18:16 ` Peter Zijlstra
2020-06-03 19:10 ` Marco Elver
2020-06-04 6:00 ` Marco Elver
2020-06-04 9:52 ` Marco Elver
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=20200604141726.GZ29598@paulmck-ThinkPad-P72 \
--to=paulmck@kernel.org \
--cc=andreyknvl@google.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/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).