list: Use WRITE_ONCE() when initializing list_head structures

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>
This commit is contained in:
Paul E. McKenney 2015-10-12 16:56:42 -07:00
parent 7d86dccf28
commit 2f073848c3
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}