srcu: Fix WARN_ON() for timer_delete_sync() in cleanup_srcu_struct()
Subsystems (2)
Zqiang
reviewerPATCH v2 1/1 srcu: Fix WARN_ON() for timer_delete_sync() in cleanup_srcu_struct()
The WARN_ON() for timer_delete_sync() means that the caller forgot to call srcu_barrier() before cleanup. however, it still can trigger even when srcu_barrier() was properly called.
When a SRCU grace period ends and find that the allocation of srcu_node tree has been completed, but the ss_state is still less than SRCU_SIZE_BIG, the mask=~0 causes delay_work timer be queued on every CPU which has been online regardless of whether it's sdp->srcu_cblist has callbacks. the srcu_barrier() only wait srcu_barrier_head's callbacks to complete, however, the srcu_barrier_head will not be inserted into an empty sdp->srcu_cblist. after that, when cleanup_srcu_struct() finds a pending delay_work timer on a CPU with no callbacks, triggering a false positive.
This commit therefore add rcu_segcblist_n_cbs() to WARN_ON(), make the warning triggers only when the timer is still pending and there are actual outstanding callbacks.
---
v1->v2:
Update commit log and modify indentation.
kernel/rcu/srcutree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/rcu/srcutree.c +3 -2
@@ -753,8 +753,9 @@ void cleanup_srcu_struct(struct srcu_struct *ssp)// Call srcu_barrier() before this cleanup_srcu_struct() // to avoid triggering this WARN_ON(). -if (WARN_ON (timer_delete_sync (&sdp->delay_work)) && -rcu_cpu_beenfullyonline (sdp->cpu)) +if (WARN_ON (timer_delete_sync (&sdp->delay_work) && +rcu_segcblist_n_cbs (&sdp->srcu_cblist)) && +rcu_cpu_beenfullyonline (sdp->cpu))queue_work_on (sdp->cpu, rcu_gp_wq, &sdp->work);flush_work (&sdp->work);if (WARN_ON (rcu_segcblist_n_cbs (&sdp->srcu_cblist)))
Signature · 1 line
2.48.1
Quoted 17 lines · Zqiang
The
WARN_ON()fortimer_delete_sync()means that the caller forgot to callsrcu_barrier()before cleanup. however, it still can trigger even whensrcu_barrier()was properly called.When a SRCU grace period ends and find that the allocation of
srcu_nodetree has been completed, but thess_stateis still less thanSRCU_SIZE_BIG, the mask=~0 causesdelay_worktimer be queued on every CPU which has been online regardless of whether it'ssdp->srcu_cblisthas callbacks. thesrcu_barrier()only wait srcu_barrier_head's callbacks to complete, however, thesrcu_barrier_headwill not be inserted into an emptysdp->srcu_cblist. after that, whencleanup_srcu_struct()finds a pendingdelay_worktimer on a CPU with no callbacks, triggering a false positive.This commit therefore add
rcu_segcblist_n_cbs()toWARN_ON(), make the warning triggers only when the timer is still pending and there are actual outstanding callbacks.
Quoted 6 lines
Fixes 05c3e88488ed ("srcu: Queue sdp->work when the delay timer is successfully deleted")Reported-by Breno Leitao <[email protected]>Reported-by kernel test robot <[email protected]>Tested-by kernel test robot <[email protected]>Signed-off-by Zqiang <[email protected]>
Signature · 2 lines
Frederic Weisbecker SUSE Labs
Paul E. McKenney
maintainerQuoted 18 lines · Frederic Weisbecker
Quoted 17 lines · Zqiang
The
WARN_ON()fortimer_delete_sync()means that the caller forgot to callsrcu_barrier()before cleanup. however, it still can trigger even whensrcu_barrier()was properly called.When a SRCU grace period ends and find that the allocation of
srcu_nodetree has been completed, but thess_stateis still less thanSRCU_SIZE_BIG, the mask=~0 causesdelay_worktimer be queued on every CPU which has been online regardless of whether it'ssdp->srcu_cblisthas callbacks. thesrcu_barrier()only wait srcu_barrier_head's callbacks to complete, however, thesrcu_barrier_headwill not be inserted into an emptysdp->srcu_cblist. after that, whencleanup_srcu_struct()finds a pendingdelay_worktimer on a CPU with no callbacks, triggering a false positive.This commit therefore add
rcu_segcblist_n_cbs()toWARN_ON(), make the warning triggers only when the timer is still pending and there are actual outstanding callbacks.
Quoted 8 lines
Quoted 6 lines
Fixes 05c3e88488ed ("srcu: Queue sdp->work when the delay timer is successfully deleted")Reported-by Breno Leitao <[email protected]>Reported-by kernel test robot <[email protected]>Tested-by kernel test robot <[email protected]>Signed-off-by Zqiang <[email protected]>Reviewed-by Frederic Weisbecker <[email protected]>
I pulled this in for further review and testing. My plan is to fold it in to the commit that it fixes, of course with attribution.
Thank you both!
Thanx, Paul
Quoted 17 lines · Zqiang
The
WARN_ON()fortimer_delete_sync()means that the caller forgot to callsrcu_barrier()before cleanup. however, it still can trigger even whensrcu_barrier()was properly called.When a SRCU grace period ends and find that the allocation of
srcu_nodetree has been completed, but thess_stateis still less thanSRCU_SIZE_BIG, the mask=~0 causesdelay_worktimer be queued on every CPU which has been online regardless of whether it'ssdp->srcu_cblisthas callbacks. thesrcu_barrier()only wait srcu_barrier_head's callbacks to complete, however, thesrcu_barrier_headwill not be inserted into an emptysdp->srcu_cblist. after that, whencleanup_srcu_struct()finds a pendingdelay_worktimer on a CPU with no callbacks, triggering a false positive.This commit therefore add
rcu_segcblist_n_cbs()toWARN_ON(), make the warning triggers only when the timer is still pending and there are actual outstanding callbacks.
Quoted 6 lines
Fixes 05c3e88488ed ("srcu: Queue sdp->work when the delay timer is successfully deleted")Reported-by Breno Leitao <[email protected]>Reported-by kernel test robot <[email protected]>Tested-by kernel test robot <[email protected]>Signed-off-by Zqiang <[email protected]>
Paul E. McKenney
maintainerQuoted 18 lines · Breno Leitao
Quoted 17 lines · Zqiang
The
WARN_ON()fortimer_delete_sync()means that the caller forgot to callsrcu_barrier()before cleanup. however, it still can trigger even whensrcu_barrier()was properly called.When a SRCU grace period ends and find that the allocation of
srcu_nodetree has been completed, but thess_stateis still less thanSRCU_SIZE_BIG, the mask=~0 causesdelay_worktimer be queued on every CPU which has been online regardless of whether it'ssdp->srcu_cblisthas callbacks. thesrcu_barrier()only wait srcu_barrier_head's callbacks to complete, however, thesrcu_barrier_headwill not be inserted into an emptysdp->srcu_cblist. after that, whencleanup_srcu_struct()finds a pendingdelay_worktimer on a CPU with no callbacks, triggering a false positive.This commit therefore add
rcu_segcblist_n_cbs()toWARN_ON(), make the warning triggers only when the timer is still pending and there are actual outstanding callbacks.
Quoted 8 lines
Quoted 6 lines
Fixes 05c3e88488ed ("srcu: Queue sdp->work when the delay timer is successfully deleted")Reported-by Breno Leitao <[email protected]>Reported-by kernel test robot <[email protected]>Tested-by kernel test robot <[email protected]>Signed-off-by Zqiang <[email protected]>Tested-by Breno Leitao <[email protected]>
Thank you, Breno! I will add this to the original, which I merged this fix into.
Thanx, Paul