linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rculist: Fix another sparse warning
@ 2015-03-25  4:43 Ying Xue
  2015-03-25 13:49 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Ying Xue @ 2015-03-25  4:43 UTC (permalink / raw)
  To: paulmck; +Cc: linux-kernel

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().

Signed-off-by: Ying Xue <ying.xue@windriver.com>
---
 include/linux/rculist.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index a18b16f..18a3f15 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -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
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rculist: Fix another sparse warning
  2015-03-25  4:43 [PATCH] rculist: Fix another sparse warning Ying Xue
@ 2015-03-25 13:49 ` Paul E. McKenney
  2015-03-26  5:19   ` Ying Xue
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2015-03-25 13:49 UTC (permalink / raw)
  To: Ying Xue; +Cc: linux-kernel

On Wed, Mar 25, 2015 at 12:43:38PM +0800, Ying Xue wrote:
> 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().
> 
> Signed-off-by: Ying Xue <ying.xue@windriver.com>

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

> ---
>  include/linux/rculist.h |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
> index a18b16f..18a3f15 100644
> --- a/include/linux/rculist.h
> +++ b/include/linux/rculist.h
> @@ -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
> -- 
> 1.7.9.5
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rculist: Fix another sparse warning
  2015-03-25 13:49 ` Paul E. McKenney
@ 2015-03-26  5:19   ` Ying Xue
  0 siblings, 0 replies; 3+ messages in thread
From: Ying Xue @ 2015-03-26  5:19 UTC (permalink / raw)
  To: paulmck; +Cc: linux-kernel

On 03/25/2015 09:49 PM, Paul E. McKenney wrote:
> On Wed, Mar 25, 2015 at 12:43:38PM +0800, Ying Xue wrote:
>> 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().
>>
>> Signed-off-by: Ying Xue <ying.xue@windriver.com>
> 
> 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

> 							Thanx, Paul
> 
>> ---
>>  include/linux/rculist.h |    4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
>> index a18b16f..18a3f15 100644
>> --- a/include/linux/rculist.h
>> +++ b/include/linux/rculist.h
>> @@ -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
>> -- 
>> 1.7.9.5
>>
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-26  5:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25  4:43 [PATCH] rculist: Fix another sparse warning Ying Xue
2015-03-25 13:49 ` Paul E. McKenney
2015-03-26  5:19   ` Ying Xue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).