summaryrefslogtreecommitdiff
path: root/include/linux/rculist_nulls.h
diff options
context:
space:
mode:
authorAlan Huang <mmpgouride@gmail.com>2023-07-06 10:28:48 +0000
committerPaul E. McKenney <paulmck@kernel.org>2023-08-16 14:27:41 -0700
commitefd04f8a8b45b8b98704b5860e363bab239b8bae (patch)
treeccfaab884686930f555c931a7fa48d58e8965f8b /include/linux/rculist_nulls.h
parent3292ba0229dbe5f3e79b78b230354ada2888dc29 (diff)
rcu: Use WRITE_ONCE() for assignments to ->next for rculist_nulls
When the objects managed by rculist_nulls are allocated with SLAB_TYPESAFE_BY_RCU, old readers may still hold references to an object even though it is just now being added, which means the modification of ->next is visible to readers. This patch therefore uses WRITE_ONCE() for assignments to ->next. Signed-off-by: Alan Huang <mmpgouride@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Diffstat (limited to 'include/linux/rculist_nulls.h')
-rw-r--r--include/linux/rculist_nulls.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
index ba4c00dd8005..89186c499dd4 100644
--- a/include/linux/rculist_nulls.h
+++ b/include/linux/rculist_nulls.h
@@ -101,7 +101,7 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
{
struct hlist_nulls_node *first = h->first;
- n->next = first;
+ WRITE_ONCE(n->next, first);
WRITE_ONCE(n->pprev, &h->first);
rcu_assign_pointer(hlist_nulls_first_rcu(h), n);
if (!is_a_nulls(first))
@@ -137,7 +137,7 @@ static inline void hlist_nulls_add_tail_rcu(struct hlist_nulls_node *n,
last = i;
if (last) {
- n->next = last->next;
+ WRITE_ONCE(n->next, last->next);
n->pprev = &last->next;
rcu_assign_pointer(hlist_nulls_next_rcu(last), n);
} else {