Skip to content
This repository was archived by the owner on Nov 21, 2022. It is now read-only.

Commit 7b9e9b5

Browse files
committed
srcu: Make srcu_funnel_gp_start() cache ->mynode in snp_leaf
Currently, the srcu_funnel_gp_start() walks its local variable snp up the tree and reloads sdp->mynode whenever it is necessary to check whether it is still at the leaf srcu_node level. This works, but is a bit more obtuse than absolutely necessary. In addition, upcoming commits will dynamically size srcu_struct structures, in which case sdp->mynode will no longer necessarily be a constant, and this commit helps prepare for that dynamic sizing. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 95ebe80 commit 7b9e9b5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

kernel/rcu/srcutree.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,20 +632,21 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp,
632632
{
633633
unsigned long flags;
634634
int idx = rcu_seq_ctr(s) % ARRAY_SIZE(sdp->mynode->srcu_have_cbs);
635-
struct srcu_node *snp = sdp->mynode;
635+
struct srcu_node *snp;
636+
struct srcu_node *snp_leaf = sdp->mynode;
636637
unsigned long snp_seq;
637638

638639
/* Each pass through the loop does one level of the srcu_node tree. */
639-
for (; snp != NULL; snp = snp->srcu_parent) {
640-
if (rcu_seq_done(&ssp->srcu_gp_seq, s) && snp != sdp->mynode)
640+
for (snp = snp_leaf; snp != NULL; snp = snp->srcu_parent) {
641+
if (rcu_seq_done(&ssp->srcu_gp_seq, s) && snp != snp_leaf)
641642
return; /* GP already done and CBs recorded. */
642643
spin_lock_irqsave_rcu_node(snp, flags);
643644
if (ULONG_CMP_GE(snp->srcu_have_cbs[idx], s)) {
644645
snp_seq = snp->srcu_have_cbs[idx];
645-
if (snp == sdp->mynode && snp_seq == s)
646+
if (snp == snp_leaf && snp_seq == s)
646647
snp->srcu_data_have_cbs[idx] |= sdp->grpmask;
647648
spin_unlock_irqrestore_rcu_node(snp, flags);
648-
if (snp == sdp->mynode && snp_seq != s) {
649+
if (snp == snp_leaf && snp_seq != s) {
649650
srcu_schedule_cbs_sdp(sdp, do_norm
650651
? SRCU_INTERVAL
651652
: 0);
@@ -656,7 +657,7 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp,
656657
return;
657658
}
658659
snp->srcu_have_cbs[idx] = s;
659-
if (snp == sdp->mynode)
660+
if (snp == snp_leaf)
660661
snp->srcu_data_have_cbs[idx] |= sdp->grpmask;
661662
if (!do_norm && ULONG_CMP_LT(snp->srcu_gp_seq_needed_exp, s))
662663
WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s);

0 commit comments

Comments
 (0)