Skip to content

Commit 4aa6e94

Browse files
author
Joel Fernandes
committed
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 <[email protected]> Signed-off-by: Joel Fernandes <[email protected]>
1 parent 9c94c5a commit 4aa6e94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/rcu/tree.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,7 @@ static noinline_for_stack bool rcu_gp_init(void)
17981798
struct rcu_data *rdp;
17991799
struct rcu_node *rnp = rcu_get_root();
18001800
bool start_new_poll;
1801+
unsigned long old_gp_seq;
18011802

18021803
WRITE_ONCE(rcu_state.gp_activity, jiffies);
18031804
raw_spin_lock_irq_rcu_node(rnp);
@@ -1825,7 +1826,12 @@ static noinline_for_stack bool rcu_gp_init(void)
18251826
*/
18261827
start_new_poll = rcu_sr_normal_gp_init();
18271828
/* Record GP times before starting GP, hence rcu_seq_start(). */
1829+
old_gp_seq = rcu_state.gp_seq;
18281830
rcu_seq_start(&rcu_state.gp_seq);
1831+
/* Ensure that rcu_seq_done_exact() guardband doesn't give false positives. */
1832+
WARN_ON_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) &&
1833+
rcu_seq_done_exact(&old_gp_seq, rcu_seq_snap(&rcu_state.gp_seq)));
1834+
18291835
ASSERT_EXCLUSIVE_WRITER(rcu_state.gp_seq);
18301836
trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("start"));
18311837
rcu_poll_gp_seq_start(&rcu_state.gp_seq_polled_snap);

0 commit comments

Comments
 (0)