rcu: Stop rcu_do_batch() from multiplexing the "count" variable
PATCH 1/1 rcu: Stop rcu_do_batch() from multiplexing the "count" variable
Commit b1420f1c (Make rcu_barrier() less disruptive) rearranged the code in rcu_do_batch(), moving the ->qlen manipulation to follow the requeueing of the callbacks. Unfortunately, this rearrangement clobbered the value of the "count" local variable before the value of rdp->qlen was adjusted, resulting in the value of rdp->qlen being inaccurate. This commit therefore introduces an index variable "i", avoiding the inadvertent multiplexing.
kernel/rcutree.c +7 -7
@@ -1593,7 +1593,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) {unsigned long flags;struct rcu_head *next, *list, **tail; -int bl, count, count_lazy; +int bl, count, count_lazy, i;/* If no callbacks are ready, just return.*/ if (!cpu_has_callbacks_ready_to_invoke (rdp)) {
@@ -1616,9 +1616,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) rdp->nxtlist = *rdp->nxttail[RCU_DONE_TAIL ]; *rdp->nxttail[RCU_DONE_TAIL ] =NULL ; tail = rdp->nxttail[RCU_DONE_TAIL ]; -for (count =RCU_NEXT_SIZE -1 ; count >=0 ; count--) -if (rdp->nxttail[count] == rdp->nxttail[RCU_DONE_TAIL ]) - rdp->nxttail[count] = &rdp->nxtlist; +for (i =RCU_NEXT_SIZE -1 ; i >=0 ; i--) +if (rdp->nxttail[i] == rdp->nxttail[RCU_DONE_TAIL ]) + rdp->nxttail[i] = &rdp->nxtlist;local_irq_restore (flags);/* Invoke callbacks. */
@@ -1646,9 +1646,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)if (list !=NULL ) { *tail = rdp->nxtlist; rdp->nxtlist = list; -for (count =0 ; count <RCU_NEXT_SIZE ; count++) -if (&rdp->nxtlist == rdp->nxttail[count]) - rdp->nxttail[count] = tail; +for (i =0 ; i <RCU_NEXT_SIZE ; i++) +if (&rdp->nxtlist == rdp->nxttail[i]) + rdp->nxttail[i] = tail;else break ; }
Quoted 10 lines · Paul E. McKenney
Commit
b1420f1c(Makercu_barrier()less disruptive) rearranged the code inrcu_do_batch(), moving the ->qlen manipulation to follow the requeueing of the callbacks. Unfortunately, this rearrangement clobbered the value of the "count" local variable before the value ofrdp->qlenwas adjusted, resulting in the value ofrdp->qlenbeing inaccurate. This commit therefore introduces an index variable "i", avoiding the inadvertent multiplexing.Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>
Quoted 40 lines
kernel/rcutree.c +7
-7@@ -1593,7 +1593,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) {unsigned long flags;struct rcu_head *next, *list, **tail; -int bl, count, count_lazy; +int bl, count, count_lazy, i;/* If no callbacks are ready, just return.*/ if (!cpu_has_callbacks_ready_to_invoke (rdp)) {@@ -1616,9 +1616,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) rdp->nxtlist = *rdp->nxttail[RCU_DONE_TAIL ]; *rdp->nxttail[RCU_DONE_TAIL ] =NULL ; tail = rdp->nxttail[RCU_DONE_TAIL ]; -for (count =RCU_NEXT_SIZE -1 ; count >=0 ; count--) -if (rdp->nxttail[count] == rdp->nxttail[RCU_DONE_TAIL ]) - rdp->nxttail[count] = &rdp->nxtlist; +for (i =RCU_NEXT_SIZE -1 ; i >=0 ; i--) +if (rdp->nxttail[i] == rdp->nxttail[RCU_DONE_TAIL ]) + rdp->nxttail[i] = &rdp->nxtlist;local_irq_restore (flags);/* Invoke callbacks. */ @@ -1646,9 +1646,9 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)if (list !=NULL ) { *tail = rdp->nxtlist; rdp->nxtlist = list; -for (count =0 ; count <RCU_NEXT_SIZE ; count++) -if (&rdp->nxtlist == rdp->nxttail[count]) - rdp->nxttail[count] = tail; +for (i =0 ; i <RCU_NEXT_SIZE ; i++) +if (&rdp->nxtlist == rdp->nxttail[i]) + rdp->nxttail[i] = tail;else break ; }