Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1284371

[PATCH tip/core/rcu 4/4] list: Use WRITE_ONCE() when initializing list_head structures

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH tip/core/rcu 4/4] list: Use WRITE_ONCE() when initializing list_head structures
Date 2015-12-05 01:20 +0100
Message-ID <qC8JZ-1nw-21@gated-at.bofh.it> (permalink)
References <qC8JY-1nw-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Code that does lockless emptiness testing of non-RCU lists is relying
on INIT_LIST_HEAD() to write the list head's ->next pointer atomically,
particularly when INIT_LIST_HEAD() is invoked from list_del_init().
This commit therefore adds WRITE_ONCE() to this function's pointer stores
that could affect the head's ->next pointer.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 include/linux/list.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/list.h b/include/linux/list.h
index 06c2d887a918..5356f4d661a7 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -24,7 +24,7 @@
 
 static inline void INIT_LIST_HEAD(struct list_head *list)
 {
-	list->next = list;
+	WRITE_ONCE(list->next, list);
 	list->prev = list;
 }
 
-- 
2.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH tip/core/rcu 0/4] linked-list updates for 4.5 "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-12-05 01:20 +0100
  [PATCH tip/core/rcu 4/4] list: Use WRITE_ONCE() when initializing list_head structures "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-12-05 01:20 +0100
  [PATCH tip/core/rcu 1/4] list: Use WRITE_ONCE() when adding to lists and hlists "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-12-05 01:20 +0100
  [PATCH tip/core/rcu 3/4] list: Introduces generic list_splice_tail_init_rcu() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-12-05 01:20 +0100
  [PATCH tip/core/rcu 2/4] list: Use READ_ONCE() when testing for empty lists "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-12-05 01:20 +0100

csiph-web