Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1738608

Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers

From Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers
Date 2017-09-25 02:20 +0200
Message-ID <utphT-75W-7@gated-at.bofh.it> (permalink)
References <usZGN-7Ze-7@gated-at.bofh.it> <usZGN-7Ze-5@gated-at.bofh.it> <utl4B-4jB-7@gated-at.bofh.it> <utp8e-731-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Sep 24, 2017 at 5:03 PM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
>
> Mostly just paranoia on my part.  I would be happy to remove it if
> you prefer.  Or you or Steve can do so if that is more convenient.

I really don't think it's warranted. The values are *stable*. There's
no subtle lack of locking, or some optimistic access to a value that
can change.

The compiler can generate code to read the value fifteen billion
times, and it will always get the same value.

Yes, maybe in between the different accesses, an NMI will happen, and
the value will be incremented, but then as the NMI exits, it will
decrement again, so the code that got interrupted will not actually
see the change.

So the READ_ONCE() isn't "paranoia". It's just confusing.

> And yes, consistency would dictate that the uses in rcu_nmi_enter()
> and rcu_nmi_exit() should be _ONCE(), particularly the stores to
> ->dynticks_nmi_nesting.

NO.

That would be just more of that confusion.

That value is STABLE. It's stable even within an NMI handler. The NMI
code can read it, modify it, write it back, do a little dance, all
without having to care. There's no "_ONCE()" about it - not for the
readers, not for the writers, not for _anybody_.

So adding even more READ/WRITE_ONCE() accesses wouldn't be
"consistent", it would just be insanity.

Now, if an NMI happens and the value would be different on entry than
it is on exit, that would be something else. Then it really wouldn't
be stable wrt random users. But that would also be a major bug in the
NMI handler, as far as I can tell.

So the reason I'm objecting to that READ_ONCE() is that it isn't
"paranoia", it's "voodoo programming". And we don't do voodoo
programming.

            Linus

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/4] rcu: Allow for page faults in NMI handlers Steven Rostedt <rostedt@goodmis.org> - 2017-09-23 23:00 +0200
  Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers Linus Torvalds <torvalds@linux-foundation.org> - 2017-09-24 21:50 +0200
    Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-09-25 02:10 +0200
      Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers Linus Torvalds <torvalds@linux-foundation.org> - 2017-09-25 02:20 +0200
        Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-09-25 02:30 +0200
          Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-09-25 02:40 +0200
            Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers Steven Rostedt <rostedt@goodmis.org> - 2017-09-25 06:50 +0200
              Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-09-25 07:00 +0200
                Re: [PATCH 1/4] rcu: Allow for page faults in NMI handlers "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-09-26 05:20 +0200

csiph-web