From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "Sasha Levin" <sasha.levin@oracle.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"X86 ML" <x86@kernel.org>, "Rik van Riel" <riel@redhat.com>
Subject: Re: Reconciling rcu_irq_enter()/rcu_nmi_enter() with context tracking
Date: Thu, 16 Jul 2015 21:29:07 -0700 [thread overview]
Message-ID: <20150717042907.GZ3717@linux.vnet.ibm.com> (raw)
In-Reply-To: <CALCETrXDbRhXZcMM7ao___ExZ_9Hyh5cDorbvT1r8dfZor+9bA@mail.gmail.com>
On Thu, Jul 16, 2015 at 06:53:15PM -0700, Andy Lutomirski wrote:
> For reasons that mystify me a bit, we currently track context tracking
> state separately from rcu's watching state. This results in strange
> artifacts: nothing generic cause IRQs to enter CONTEXT_KERNEL, and we
> can nest exceptions inside the IRQ handler (an example would be
> wrmsr_safe failing), and, in -next, we splat a warning:
>
> https://gist.github.com/sashalevin/a006a44989312f6835e7
>
> I'm trying to make context tracking more exact, which will fix this
> issue (the particular splat that Sasha hit shouldn't be possible when
> I'm done), but I think it would be nice to unify all of this stuff.
> Would it be plausible for us to guarantee that RCU state is always in
> sync with context tracking state? If so, we could maybe simplify
> things and have fewer state variables.
A noble goal. Might even be possible, and maybe even advantageous.
But it is usually easier to say than to do. RCU really does need to make
some adjustments when the state changes, as do the other subsystems.
It might or might not be possible to do the transitions atomically.
And if the transitions are not atomic, there will still be weird code
paths where (say) the processor is considered non-idle, but RCU doesn't
realize it yet. Such a code path could not safely use rcu_read_lock(),
so you still need RCU to be able to scream if someone tries it.
Contrariwise, if there is a code path where the processor is considered
idle, but RCU thinks it is non-idle, that code path can stall
grace periods. (Yes, not a problem if the code path is short enough.
At least if the underlying VCPU is making progres...)
Still, I cannot prove that it is impossible, and if it is possible,
then as you say, there might well be benefits.
> Doing this for NMIs might be weird. Would it make sense to have a
> CONTEXT_NMI that's somehow valid even if the NMI happened while
> changing context tracking state.
Face it, NMIs are weird. ;-)
> Thoughts? As it stands, I think we might already be broken for real:
>
> Syscall -> user_exit. Perf NMI hits *during* user_exit. Perf does
> copy_from_user_nmi, which can fault, causing do_page_fault to get
> called, which calls exception_enter(), which can't be a good thing.
>
> RCU is okay (sort of) because of rcu_nmi_enter, but this seems very fragile.
Actually, I see more cases where people forget irq_enter() than
rcu_nmi_enter(). "We will just nip in quickly and do something without
actually letting the irq system know. Oh, and we want some event tracing
in that code path." Boom!
> Thoughts? As it stands, I need to do something because -tip and thus
> -next spews occasional warnings.
Tell me more?
Thanx, Paul
next prev parent reply other threads:[~2015-07-17 4:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 1:53 Reconciling rcu_irq_enter()/rcu_nmi_enter() with context tracking Andy Lutomirski
2015-07-17 4:29 ` Paul E. McKenney [this message]
2015-07-17 4:49 ` Paul E. McKenney
2015-07-17 18:59 ` Andy Lutomirski
2015-07-17 20:12 ` Paul E. McKenney
2015-07-17 20:32 ` Andy Lutomirski
2015-07-17 21:19 ` Paul E. McKenney
2015-07-17 21:22 ` Paul E. McKenney
2015-07-17 22:45 ` Andy Lutomirski
2015-07-17 22:13 ` Andy Lutomirski
2015-07-17 22:55 ` Paul E. McKenney
2015-07-17 23:20 ` Andy Lutomirski
2015-07-18 0:04 ` Paul E. McKenney
2015-07-18 13:12 ` Frederic Weisbecker
2015-07-18 13:00 ` Frederic Weisbecker
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=20150717042907.GZ3717@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=sasha.levin@oracle.com \
--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