Message ID | 20200324153643.15527-7-will@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Improve list integrity checking | expand |
On Tue, Mar 24, 2020 at 03:36:28PM +0000, Will Deacon wrote: > Commit 860c8802ace1 ("rcu: Use WRITE_ONCE() for assignments to ->pprev > for hlist_nulls") added WRITE_ONCE() invocations to hlist_nulls_add_head() > and hlist_nulls_del(). > > Since these functions should not ordinarily run concurrently with other > list accessors, restore the plain C assignments so that KCSAN can yell > if a data race occurs. > > Cc: Eric Dumazet <edumazet@google.com> > Cc: Paul E. McKenney <paulmck@kernel.org> > Cc: Peter Zijlstra <peterz@infradead.org> > Signed-off-by: Will Deacon <will@kernel.org> And this means that the lockless uses of hlist_nulls_empty() need attention, correct? Thanx, Paul > --- > include/linux/list_nulls.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h > index fa51a801bf32..fd154ceb5b0d 100644 > --- a/include/linux/list_nulls.h > +++ b/include/linux/list_nulls.h > @@ -80,10 +80,10 @@ static inline void hlist_nulls_add_head(struct hlist_nulls_node *n, > struct hlist_nulls_node *first = h->first; > > n->next = first; > - WRITE_ONCE(n->pprev, &h->first); > + n->pprev = &h->first; > h->first = n; > if (!is_a_nulls(first)) > - WRITE_ONCE(first->pprev, &n->next); > + first->pprev = &n->next; > } > > static inline void __hlist_nulls_del(struct hlist_nulls_node *n) > @@ -99,7 +99,7 @@ static inline void __hlist_nulls_del(struct hlist_nulls_node *n) > static inline void hlist_nulls_del(struct hlist_nulls_node *n) > { > __hlist_nulls_del(n); > - WRITE_ONCE(n->pprev, LIST_POISON2); > + n->pprev = LIST_POISON2; > } > > /** > -- > 2.20.1 >
diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h index fa51a801bf32..fd154ceb5b0d 100644 --- a/include/linux/list_nulls.h +++ b/include/linux/list_nulls.h @@ -80,10 +80,10 @@ static inline void hlist_nulls_add_head(struct hlist_nulls_node *n, struct hlist_nulls_node *first = h->first; n->next = first; - WRITE_ONCE(n->pprev, &h->first); + n->pprev = &h->first; h->first = n; if (!is_a_nulls(first)) - WRITE_ONCE(first->pprev, &n->next); + first->pprev = &n->next; } static inline void __hlist_nulls_del(struct hlist_nulls_node *n) @@ -99,7 +99,7 @@ static inline void __hlist_nulls_del(struct hlist_nulls_node *n) static inline void hlist_nulls_del(struct hlist_nulls_node *n) { __hlist_nulls_del(n); - WRITE_ONCE(n->pprev, LIST_POISON2); + n->pprev = LIST_POISON2; } /**
Commit 860c8802ace1 ("rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls") added WRITE_ONCE() invocations to hlist_nulls_add_head() and hlist_nulls_del(). Since these functions should not ordinarily run concurrently with other list accessors, restore the plain C assignments so that KCSAN can yell if a data race occurs. Cc: Eric Dumazet <edumazet@google.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Will Deacon <will@kernel.org> --- include/linux/list_nulls.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)