Skip to contentSkip to conversation

rculist: Fix another sparse warning

PATCH Superseded Ying Xue 2 participants 3 messages Mar 25, 2015 – Mar 26, 2015 RCU

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ying Xue

author
#0 lore raw

PATCH 1/1 rculist: Fix another sparse warning

This fixes the following sparse warnings:

make C=1 CF=-D__CHECK_ENDIAN__ net/tipc/name_table.o
net/tipc/name_table.c:977:17: error: incompatible types in comparison expression (different address spaces) net/tipc/name_table.c:977:17: error: incompatible types in comparison expression (different address spaces)

To silence these spare complaints, an RCU annotation should be added to "next" pointer of hlist_node structure through hlist_next_rcu() macro when iterating over a hlist with hlist_for_each_entry_from_rcu().

---
 include/linux/rculist.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/rculist.h +2 -2
index a18b16f..18a3f15 100644
@@ -549,8 +549,8 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,
  */
 #define hlist_for_each_entry_from_rcu(pos, member)			\
 	for (; pos;							\
-	     pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\
-			typeof(*(pos)), member))
+	     pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu(	\
+			&(pos)->member)), typeof(*(pos)), member))
 
 #endif	/* __KERNEL__ */
 #endif
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 11 lines · Ying Xue

This fixes the following sparse warnings:

make C=1 CF=-D__CHECK_ENDIAN__ net/tipc/name_table.o
net/tipc/name_table.c:977:17: error: incompatible types in comparison expression (different address spaces) net/tipc/name_table.c:977:17: error: incompatible types in comparison expression (different address spaces)

To silence these spare complaints, an RCU annotation should be added to "next" pointer of hlist_node structure through hlist_next_rcu() macro when iterating over a hlist with hlist_for_each_entry_from_rcu().

If hlist_for_each_entry_from_rcu() is to use rcu_dereference_bh(), then it needs to be named hlist_for_each_entry_from_rcu_bh(). If we want to retain the generic nature, rcu_dereference_raw() would work.

(Otherwise, we would get splats if this was used under rcu_read_lock() rather than rcu_read_lock_bh().)

Thanx, Paul

Quoted 22 lines
---
 include/linux/rculist.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/rculist.h +2 -2
index a18b16f..18a3f15 100644
@@ -549,8 +549,8 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,
  */
 #define hlist_for_each_entry_from_rcu(pos, member)			\
 	for (; pos;							\
-	     pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\
-			typeof(*(pos)), member))
+	     pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu(	\
+			&(pos)->member)), typeof(*(pos)), member))
 
 #endif	/* __KERNEL__ */
 #endif
Signature · 1 line
1.7.9.5
author
#2 lore raw
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · Ying Xue

This fixes the following sparse warnings:

make C=1 CF=-D__CHECK_ENDIAN__ net/tipc/name_table.o
net/tipc/name_table.c:977:17: error: incompatible types in comparison expression (different address spaces) net/tipc/name_table.c:977:17: error: incompatible types in comparison expression (different address spaces)

To silence these spare complaints, an RCU annotation should be added to "next" pointer of hlist_node structure through hlist_next_rcu() macro when iterating over a hlist with hlist_for_each_entry_from_rcu().

Quoted 9 lines
Quoted 1 line

If hlist_for_each_entry_from_rcu() is to use rcu_dereference_bh(), then it needs to be named hlist_for_each_entry_from_rcu_bh(). If we want to retain the generic nature, rcu_dereference_raw() would work.

(Otherwise, we would get splats if this was used under rcu_read_lock() rather than rcu_read_lock_bh().)

Yes, you are absolutely right. Thanks to point out my mistake. I will fix it in next version.

Regards,
Ying

Quoted 27 lines

Thanx, Paul

Quoted 22 lines
---
 include/linux/rculist.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/rculist.h +2 -2
index a18b16f..18a3f15 100644
@@ -549,8 +549,8 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,
  */
 #define hlist_for_each_entry_from_rcu(pos, member)			\
 	for (; pos;							\
-	     pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\
-			typeof(*(pos)), member))
+	     pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu(	\
+			&(pos)->member)), typeof(*(pos)), member))
 
 #endif	/* __KERNEL__ */
 #endif
Signature · 1 line
1.7.9.5