]> git.ipfire.org Git - thirdparty/linux.git/commit
rcu: Robustify rcu_is_cpu_rrupt_from_idle()
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 29 Apr 2025 10:08:40 +0000 (12:08 +0200)
committerNeeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
Wed, 25 Jun 2025 03:07:17 +0000 (08:37 +0530)
commit3dfdfaff2d49aa7895ced8a54e7d61755eac6830
treecf8c8349098da318de15a672416487794b2bfc2f
parent86731a2a651e58953fc949573895f2fa6d456841
rcu: Robustify rcu_is_cpu_rrupt_from_idle()

RCU relies on the context tracking nesting counter in order to determine
if it is running in extended quiescent state.

However the context tracking nesting counter is not completely
synchronized with the actual context tracking state:

* The nesting counter is set to 1 or incremented further _after_ the
  actual state is set to RCU watching.

* The nesting counter is set to 0 or decremented further _before_ the
  actual state is set to RCU not watching.

Therefore it is safe to assume that if ct_nesting() > 0, RCU is
watching. But if ct_nesting() <= 0, RCU is not watching except for tiny
windows.

This hasn't been a problem so far because rcu_is_cpu_rrupt_from_idle()
has only been called from interrupts. However the code is confusing
and abuses the role of the context tracking nesting counter while there
are more accurate indicators available.

Clarify and robustify accordingly.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
kernel/rcu/tree.c