rcu: Tighten rcu_advance_cbs_nowake() checks
authorPaul E. McKenney <paulmck@kernel.org>
Fri, 17 Sep 2021 22:04:48 +0000 (15:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Jan 2022 09:58:25 +0000 (10:58 +0100)
commitc3156dbd5082c65b84936c8de47149799dee3ef8
tree0cb3de051b6163342bfde30fc347ffea8e4a27b3
parent6ebe994b54a63f78e7bba65ac5ebaca7dfa88526
rcu: Tighten rcu_advance_cbs_nowake() checks

commit 614ddad17f22a22e035e2ea37a04815f50362017 upstream.

Currently, rcu_advance_cbs_nowake() checks that a grace period is in
progress, however, that grace period could end just after the check.
This commit rechecks that a grace period is still in progress while
holding the rcu_node structure's lock.  The grace period cannot end while
the current CPU's rcu_node structure's ->lock is held, thus avoiding
false positives from the WARN_ON_ONCE().

As Daniel Vacek noted, it is not necessary for the rcu_node structure
to have a CPU that has not yet passed through its quiescent state.

Tested-by: Guillaume Morin <guillaume@morinfr.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/rcu/tree.c