Skip to content

Commit 0607ba8

Browse files
paulmckPaul E. McKenney
authored andcommitted
srcu: Prevent __call_srcu() counter wrap with read-side critical section
Ever since cdf7abc ("srcu: Allow use of Tiny/Tree SRCU from both process and interrupt context"), it has been permissible to use SRCU read-side critical sections in interrupt context. This allows __call_srcu() to use SRCU read-side critical sections to prevent a new SRCU grace period from ending before the call to either srcu_funnel_gp_start() or srcu_funnel_exp_start completes, thus preventing SRCU grace-period counter overflow during that time. Note that this does not permit removal of the counter-wrap checks in srcu_gp_end(). These check are necessary to handle the case where a given CPU does not interact at all with SRCU for an extended time period. This commit therefore adds an SRCU read-side critical section to __call_srcu() in order to prevent grace period counter wrap during the funnel-locking process. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
1 parent f3e763c commit 0607ba8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎kernel/rcu/srcutree.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp,
858858
rcu_callback_t func, bool do_norm)
859859
{
860860
unsigned long flags;
861+
int idx;
861862
bool needexp = false;
862863
bool needgp = false;
863864
unsigned long s;
@@ -871,6 +872,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp,
871872
return;
872873
}
873874
rhp->func = func;
875+
idx = srcu_read_lock(sp);
874876
local_irq_save(flags);
875877
sdp = this_cpu_ptr(sp->sda);
876878
spin_lock_rcu_node(sdp);
@@ -892,6 +894,7 @@ void __call_srcu(struct srcu_struct *sp, struct rcu_head *rhp,
892894
srcu_funnel_gp_start(sp, sdp, s, do_norm);
893895
else if (needexp)
894896
srcu_funnel_exp_start(sp, sdp->mynode, s);
897+
srcu_read_unlock(sp, idx);
895898
}
896899

897900
/**

0 commit comments

Comments
 (0)