rcu: Add WARN_ON_ONCE for blocked flag invariant in exit_rcu()

If a task is on the rcu_node_entry list, its blocked flag should
already be set (it's set before adding to any list in
rcu_note_context_switch()). The current code silently re-sets it,
which could mask bugs.

Add a WARN_ON_ONCE to detect this invariant violation. If this
warning ever fires, it indicates a bug where a task was added to
a blocked list without properly setting the blocked flag first.

As suggested by Steve Rostedt, only write the blocked flag if the
invariant is violated, since if it's already set there's no need
to set it again.

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
1 file changed