Skip to content

Commit 7ea9130

Browse files
qiangzh3joelagnel
authored andcommitted
rcu: Permit start_poll_synchronize_rcu_expedited() to be invoked early
According to the commit log of the patch that added it to the kernel, start_poll_synchronize_rcu_expedited() can be invoked very early, as in long before rcu_init() has been invoked. But before rcu_init(), the rcu_data structure's ->mynode field has not yet been initialized. This means that the start_poll_synchronize_rcu_expedited() function's attempt to set the CPU's leaf rcu_node structure's ->exp_seq_poll_rq field will result in a segmentation fault. This commit therefore causes start_poll_synchronize_rcu_expedited() to set ->exp_seq_poll_rq only after rcu_init() has initialized all CPUs' rcu_data structures' ->mynode fields. It also removes the check from the rcu_init() function so that start_poll_synchronize_rcu_expedited( is unconditionally invoked. Yes, this might result in an unnecessary boot-time grace period, but this is down in the noise. Signed-off-by: Zqiang <qiang1.zhang@intel.com> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
1 parent 46103fe commit 7ea9130

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

kernel/rcu/tree.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4942,9 +4942,8 @@ void __init rcu_init(void)
49424942
else
49434943
qovld_calc = qovld;
49444944

4945-
// Kick-start any polled grace periods that started early.
4946-
if (!(per_cpu_ptr(&rcu_data, cpu)->mynode->exp_seq_poll_rq & 0x1))
4947-
(void)start_poll_synchronize_rcu_expedited();
4945+
// Kick-start in case any polled grace periods started early.
4946+
(void)start_poll_synchronize_rcu_expedited();
49484947

49494948
rcu_test_sync_prims();
49504949
}

kernel/rcu/tree_exp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,10 @@ unsigned long start_poll_synchronize_rcu_expedited(void)
10661066
if (rcu_init_invoked())
10671067
raw_spin_lock_irqsave(&rnp->exp_poll_lock, flags);
10681068
if (!poll_state_synchronize_rcu(s)) {
1069-
rnp->exp_seq_poll_rq = s;
1070-
if (rcu_init_invoked())
1069+
if (rcu_init_invoked()) {
1070+
rnp->exp_seq_poll_rq = s;
10711071
queue_work(rcu_gp_wq, &rnp->exp_poll_wq);
1072+
}
10721073
}
10731074
if (rcu_init_invoked())
10741075
raw_spin_unlock_irqrestore(&rnp->exp_poll_lock, flags);

0 commit comments

Comments
 (0)