]> git.baikalelectronics.ru Git - kernel.git/commit
rcu: Add checks for dynticks counters in rcu_is_cpu_rrupt_from_idle()
authorJoel Fernandes (Google) <joel@joelfernandes.org>
Tue, 26 Mar 2019 19:24:09 +0000 (15:24 -0400)
committerPaul E. McKenney <paulmck@linux.ibm.com>
Tue, 28 May 2019 15:48:19 +0000 (08:48 -0700)
commit0959bb7dcef4303e4e988cf9e3c8a87e97414a34
treed380b1a5b671af7231054641aeb9e57d05da2407
parentefe558e880c4ac5407fe0554b8c85bb97b277401
rcu: Add checks for dynticks counters in rcu_is_cpu_rrupt_from_idle()

It would be good to combine the dynticks and dynticks_nesting counters
in order to simplify the code.  Unfortunately, there are concerns
about usermode upcalls appearing to RCU as half of an interrupt, as
Byungchul learned [1].  The "half" in "half interrupt" is due to an
unpaired rcu_irq_enter(): Normally, each rcu_irq_enter() has a later
call to rcu_irq_exit().

Out of an abundance of caution, Paul added warnings [2] in the RCU
code which if not fired by 2021 will be interpreted as meaning that
this half-interrupt scenario cannot happen any more, thus permitting
simplification of this code.

In the meantime, this commit makes the following changes:

(1) Combining these two counters requires that rcu_rrupt_from_idle()
    is invoked only from hard-interrupt contexts as discussed here [3].
    This commit therefore adds the required lockdep_assert_in_irq()
    to check this constraint.

(2) Furthermore, rcu_rrupt_from_idle() is not explicit about how it
    is using the counters which can lead to weird future bugs. This
    commit therefore adds comments indicating the meaning and use of
    each counter.

(3) Lastly, this commit checks for counter underflows as another check
    that half interrupts don't occur.  (Previously, the function would
    simply return true upon underflow.)

All these checks checks are NOOPs if PROVE_LOCKING (and thus PROVE_RCU)
are disabled.

[1] https://lore.kernel.org/patchwork/patch/952349/
[2] Commit 7b52fd0e4285 ("rcu: Add warning to detect half-interrupts")
[3] https://lore.kernel.org/lkml/20190312150514.GB249405@google.com/

Cc: byungchul.park@lge.com
Cc: kernel-team@android.com
Cc: rcu@vger.kernel.org
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
kernel/rcu/tree.c