aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcu
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.ibm.com>2019-05-13 18:57:50 -0400
committerPaul E. McKenney <paulmck@linux.ibm.com>2019-08-13 17:35:49 -0400
commite6060b41c9955374079926a7612b857a8458ed1f (patch)
tree297581f29d4caec633aa474b3b4dc30f16e5cffe /kernel/rcu
parent76c6927c3ee443e756f2c0c9f992cb04b26c65f2 (diff)
rcu/nocb: Allow lockless use of rcu_segcblist_empty()
Currently, rcu_segcblist_empty() assumes that the callback list is not being changed by other CPUs, but upcoming changes will require it to operate locklessly. This commit therefore adds the needed READ_ONCE() call, along with the WRITE_ONCE() calls when updating the callback list's ->head field. Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
Diffstat (limited to 'kernel/rcu')
-rw-r--r--kernel/rcu/rcu_segcblist.c4
-rw-r--r--kernel/rcu/rcu_segcblist.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c
index 0e7fe678b6ac..06435a368be5 100644
--- a/kernel/rcu/rcu_segcblist.c
+++ b/kernel/rcu/rcu_segcblist.c
@@ -213,7 +213,7 @@ void rcu_segcblist_extract_done_cbs(struct rcu_segcblist *rsclp,
213 if (!rcu_segcblist_ready_cbs(rsclp)) 213 if (!rcu_segcblist_ready_cbs(rsclp))
214 return; /* Nothing to do. */ 214 return; /* Nothing to do. */
215 *rclp->tail = rsclp->head; 215 *rclp->tail = rsclp->head;
216 rsclp->head = *rsclp->tails[RCU_DONE_TAIL]; 216 WRITE_ONCE(rsclp->head, *rsclp->tails[RCU_DONE_TAIL]);
217 WRITE_ONCE(*rsclp->tails[RCU_DONE_TAIL], NULL); 217 WRITE_ONCE(*rsclp->tails[RCU_DONE_TAIL], NULL);
218 rclp->tail = rsclp->tails[RCU_DONE_TAIL]; 218 rclp->tail = rsclp->tails[RCU_DONE_TAIL];
219 for (i = RCU_CBLIST_NSEGS - 1; i >= RCU_DONE_TAIL; i--) 219 for (i = RCU_CBLIST_NSEGS - 1; i >= RCU_DONE_TAIL; i--)
@@ -268,7 +268,7 @@ void rcu_segcblist_insert_done_cbs(struct rcu_segcblist *rsclp,
268 if (!rclp->head) 268 if (!rclp->head)
269 return; /* No callbacks to move. */ 269 return; /* No callbacks to move. */
270 *rclp->tail = rsclp->head; 270 *rclp->tail = rsclp->head;
271 rsclp->head = rclp->head; 271 WRITE_ONCE(rsclp->head, rclp->head);
272 for (i = RCU_DONE_TAIL; i < RCU_CBLIST_NSEGS; i++) 272 for (i = RCU_DONE_TAIL; i < RCU_CBLIST_NSEGS; i++)
273 if (&rsclp->head == rsclp->tails[i]) 273 if (&rsclp->head == rsclp->tails[i])
274 WRITE_ONCE(rsclp->tails[i], rclp->tail); 274 WRITE_ONCE(rsclp->tails[i], rclp->tail);
diff --git a/kernel/rcu/rcu_segcblist.h b/kernel/rcu/rcu_segcblist.h
index f74960f0305c..d9142b3590a8 100644
--- a/kernel/rcu/rcu_segcblist.h
+++ b/kernel/rcu/rcu_segcblist.h
@@ -36,7 +36,7 @@ struct rcu_head *rcu_cblist_dequeue(struct rcu_cblist *rclp);
36 */ 36 */
37static inline bool rcu_segcblist_empty(struct rcu_segcblist *rsclp) 37static inline bool rcu_segcblist_empty(struct rcu_segcblist *rsclp)
38{ 38{
39 return !rsclp->head; 39 return !READ_ONCE(rsclp->head);
40} 40}
41 41
42/* Return number of callbacks in segmented callback list. */ 42/* Return number of callbacks in segmented callback list. */