diff options
author | Joel Fernandes <joelagnelf@nvidia.com> | 2025-03-24 09:29:26 -0400 |
---|---|---|
committer | Joel Fernandes <joelagnelf@nvidia.com> | 2025-04-08 14:55:54 -0400 |
commit | 4aa6e94cf90c0d7414580bd6a936600aef8b1e43 (patch) | |
tree | 0597f14d949bee3f2f99d73df385dd4b73aea2d4 | |
parent | 9c94c5ad39182ccf8ae81a2fa4fa4e63abedcbf7 (diff) |
rcu: Add warning to ensure rcu_seq_done_exact() is working
The previous patch improved the rcu_seq_done_exact() function by adding
a meaningful constant for the guardband.
Ensure that this is working for the future by a quick check during
rcu_gp_init().
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
-rw-r--r-- | kernel/rcu/tree.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 659f83e71048..6b1bb85b2a56 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1798,6 +1798,7 @@ static noinline_for_stack bool rcu_gp_init(void) struct rcu_data *rdp; struct rcu_node *rnp = rcu_get_root(); bool start_new_poll; + unsigned long old_gp_seq; WRITE_ONCE(rcu_state.gp_activity, jiffies); raw_spin_lock_irq_rcu_node(rnp); @@ -1825,7 +1826,12 @@ static noinline_for_stack bool rcu_gp_init(void) */ start_new_poll = rcu_sr_normal_gp_init(); /* Record GP times before starting GP, hence rcu_seq_start(). */ + old_gp_seq = rcu_state.gp_seq; rcu_seq_start(&rcu_state.gp_seq); + /* Ensure that rcu_seq_done_exact() guardband doesn't give false positives. */ + WARN_ON_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) && + rcu_seq_done_exact(&old_gp_seq, rcu_seq_snap(&rcu_state.gp_seq))); + ASSERT_EXCLUSIVE_WRITER(rcu_state.gp_seq); trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("start")); rcu_poll_gp_seq_start(&rcu_state.gp_seq_polled_snap); |