lkml.org 
[lkml]   [2017]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] hlist_add_tail_rcu disable sparse warning
sparse is unhappy about this code in hlist_add_tail_rcu:

struct hlist_node *i, *last = NULL;

for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i))
last = i;

This is because hlist_next_rcu and hlist_next_rcu return
__rcu pointers.

It's a false positive - it's a write side primitive and so
does not need to be called in a read side critical section.

The following trivial patch disables the warning
without changing the behaviour in any way.

Note: __hlist_for_each_rcu would also remove the warning but it would be
confusing since it calls rcu_derefence and is designed to run in the rcu
read side critical section.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

changes since RFC
added commit log text to explain why don't we use __hlist_for_each_rcu

include/linux/rculist.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 4f7a956..bf578e8 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -509,7 +509,7 @@ static inline void hlist_add_tail_rcu(struct hlist_node *n,
{
struct hlist_node *i, *last = NULL;

- for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i))
+ for (i = h->first; i; i = i->next)
last = i;

if (last) {
--
MST
\
 
 \ /
  Last update: 2017-02-10 19:05    [W:0.057 / U:0.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site