* [PATCH net-next RESEND 0/2] fix rculist sparse errors
@ 2014-12-10 8:46 Ying Xue
2014-12-10 8:46 ` [PATCH net-next RESEND 1/2] tipc: fix RCU sparse error Ying Xue
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ying Xue @ 2014-12-10 8:46 UTC (permalink / raw)
To: paulmck
Cc: davem, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all,
linux-kernel
When hlist_for_each_entry_continue_rcu_bh() gets "next" pointer of
hlist_node structure through rcu_dereference_bh(), sparse warning
appears as the "next" pointer is not annotated as __rcu. So if
the "next" pointer is accessed with hlist_next_rcu() macro, the
__rcu annotation will be added to the pointer. As a consequence,
sparse warning is eliminated too.
The similar errors also appear in hlist_for_each_entry_continue_rcu()
and hlist_for_each_entry_from_rcu().
In this version, CC more people like Paul E. McKenney and lkml mail
list.
Ying Xue (2):
tipc: fix RCU sparse error
ipv6: fix sparse warning
include/linux/rculist.h | 20 ++++++++++----------
net/tipc/name_table.c | 6 +++---
2 files changed, 13 insertions(+), 13 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next RESEND 1/2] tipc: fix RCU sparse error 2014-12-10 8:46 [PATCH net-next RESEND 0/2] fix rculist sparse errors Ying Xue @ 2014-12-10 8:46 ` Ying Xue 2014-12-10 8:46 ` [PATCH net-next RESEND 2/2] ipv6: fix sparse warning Ying Xue 2014-12-10 18:49 ` [PATCH net-next RESEND 0/2] fix rculist sparse errors David Miller 2 siblings, 0 replies; 7+ messages in thread From: Ying Xue @ 2014-12-10 8:46 UTC (permalink / raw) To: paulmck Cc: davem, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all, linux-kernel The commit 97ede29e80ee ("tipc: convert name table read-write lock to RCU") involves the following sparse when using make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__ net/tipc/name_table.c:1136:17: sparse: incompatible types in comparison expression (different address spaces) net/tipc/name_table.c:1136:17: sparse: incompatible types in comparison expression (different address spaces) To silence above spare complaint, 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(). By the way, this commit also simplifies the way of dereferencing the first element of a hlist_head list by replacing hlist_for_each_entry_rcu() with hlist_entry_safe(). Reported-by: Kbuild test robot <kbuild-all@01.org> Cc: Kbuild test robot <kbuild-all@01.org> Signed-off-by: Ying Xue <ying.xue@windriver.com> --- include/linux/rculist.h | 4 ++-- net/tipc/name_table.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index aa79b3c..866d9c9 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_raw(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member)) #endif /* __KERNEL__ */ #endif diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index c8df022..fa4341f 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -1110,7 +1110,7 @@ static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type, u32 *last_lower, u32 *last_publ) { struct hlist_head *seq_head; - struct name_seq *seq = NULL; + struct name_seq *seq; int err; int i; @@ -1127,8 +1127,8 @@ static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type, if (!seq) return -EPIPE; } else { - hlist_for_each_entry_rcu(seq, seq_head, ns_list) - break; + seq = hlist_entry_safe(rcu_dereference_raw( + hlist_first_rcu(seq_head)), struct name_seq, ns_list); if (!seq) continue; } -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net-next RESEND 2/2] ipv6: fix sparse warning 2014-12-10 8:46 [PATCH net-next RESEND 0/2] fix rculist sparse errors Ying Xue 2014-12-10 8:46 ` [PATCH net-next RESEND 1/2] tipc: fix RCU sparse error Ying Xue @ 2014-12-10 8:46 ` Ying Xue 2014-12-10 16:04 ` Paul E. McKenney 2014-12-10 18:49 ` [PATCH net-next RESEND 0/2] fix rculist sparse errors David Miller 2 siblings, 1 reply; 7+ messages in thread From: Ying Xue @ 2014-12-10 8:46 UTC (permalink / raw) To: paulmck Cc: davem, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all, linux-kernel This fixes the following spare warning when using make C=1 CF=-D__CHECK_ENDIAN__ net/ipv6/addrconf.o net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) To silence above spare complaint, 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_continue_rcu_bh(). By the way, this commit also resolves the same error appearing in hlist_for_each_entry_continue_rcu(). Signed-off-by: Ying Xue <ying.xue@windriver.com> --- include/linux/rculist.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 866d9c9..32bd4ad 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -524,11 +524,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, * @member: the name of the hlist_node within the struct. */ #define hlist_for_each_entry_continue_rcu(pos, member) \ - for (pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ - typeof(*(pos)), member); \ + for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member); \ pos; \ - pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ - typeof(*(pos)), member)) + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member)) /** * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point @@ -536,11 +536,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, * @member: the name of the hlist_node within the struct. */ #define hlist_for_each_entry_continue_rcu_bh(pos, member) \ - for (pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ - typeof(*(pos)), member); \ + for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member); \ pos; \ - pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ - typeof(*(pos)), member)) + pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member)) /** * hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next RESEND 2/2] ipv6: fix sparse warning 2014-12-10 8:46 ` [PATCH net-next RESEND 2/2] ipv6: fix sparse warning Ying Xue @ 2014-12-10 16:04 ` Paul E. McKenney 2014-12-11 1:56 ` Ying Xue 0 siblings, 1 reply; 7+ messages in thread From: Paul E. McKenney @ 2014-12-10 16:04 UTC (permalink / raw) To: Ying Xue Cc: davem, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all, linux-kernel On Wed, Dec 10, 2014 at 04:46:07PM +0800, Ying Xue wrote: > This fixes the following spare warning when using > > make C=1 CF=-D__CHECK_ENDIAN__ net/ipv6/addrconf.o > net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > > To silence above spare complaint, 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_continue_rcu_bh(). > > By the way, this commit also resolves the same error appearing in > hlist_for_each_entry_continue_rcu(). > > Signed-off-by: Ying Xue <ying.xue@windriver.com> If you pull the rculist.h changes from the first patch into this one, I will queue it up through -rcu. Thanx, Paul > --- > include/linux/rculist.h | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/include/linux/rculist.h b/include/linux/rculist.h > index 866d9c9..32bd4ad 100644 > --- a/include/linux/rculist.h > +++ b/include/linux/rculist.h > @@ -524,11 +524,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, > * @member: the name of the hlist_node within the struct. > */ > #define hlist_for_each_entry_continue_rcu(pos, member) \ > - for (pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ > - typeof(*(pos)), member); \ > + for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ > + &(pos)->member)), typeof(*(pos)), member); \ > pos; \ > - pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ > - typeof(*(pos)), member)) > + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ > + &(pos)->member)), typeof(*(pos)), member)) > > /** > * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point > @@ -536,11 +536,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, > * @member: the name of the hlist_node within the struct. > */ > #define hlist_for_each_entry_continue_rcu_bh(pos, member) \ > - for (pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ > - typeof(*(pos)), member); \ > + for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ > + &(pos)->member)), typeof(*(pos)), member); \ > pos; \ > - pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ > - typeof(*(pos)), member)) > + pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ > + &(pos)->member)), typeof(*(pos)), member)) > > /** > * hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point > -- > 1.7.9.5 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next RESEND 2/2] ipv6: fix sparse warning 2014-12-10 16:04 ` Paul E. McKenney @ 2014-12-11 1:56 ` Ying Xue 2014-12-11 17:02 ` Paul E. McKenney 0 siblings, 1 reply; 7+ messages in thread From: Ying Xue @ 2014-12-11 1:56 UTC (permalink / raw) To: paulmck Cc: davem, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all, linux-kernel On 12/11/2014 12:04 AM, Paul E. McKenney wrote: > On Wed, Dec 10, 2014 at 04:46:07PM +0800, Ying Xue wrote: >> This fixes the following spare warning when using >> >> make C=1 CF=-D__CHECK_ENDIAN__ net/ipv6/addrconf.o >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) >> >> To silence above spare complaint, 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_continue_rcu_bh(). >> >> By the way, this commit also resolves the same error appearing in >> hlist_for_each_entry_continue_rcu(). >> >> Signed-off-by: Ying Xue <ying.xue@windriver.com> > > If you pull the rculist.h changes from the first patch into this one, > I will queue it up through -rcu. > Please just queue this patch into your RCU tree. Some changes of the first patch currently only exists in net-next tree, so it cannot be merged into RCU tree now. Therefore, please temporarily ignore it. In next 3.19 development cycle, I will resubmit it to you. Thanks, Ying > Thanx, Paul > >> --- >> include/linux/rculist.h | 16 ++++++++-------- >> 1 file changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/include/linux/rculist.h b/include/linux/rculist.h >> index 866d9c9..32bd4ad 100644 >> --- a/include/linux/rculist.h >> +++ b/include/linux/rculist.h >> @@ -524,11 +524,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, >> * @member: the name of the hlist_node within the struct. >> */ >> #define hlist_for_each_entry_continue_rcu(pos, member) \ >> - for (pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ >> - typeof(*(pos)), member); \ >> + for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ >> + &(pos)->member)), typeof(*(pos)), member); \ >> pos; \ >> - pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ >> - typeof(*(pos)), member)) >> + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ >> + &(pos)->member)), typeof(*(pos)), member)) >> >> /** >> * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point >> @@ -536,11 +536,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, >> * @member: the name of the hlist_node within the struct. >> */ >> #define hlist_for_each_entry_continue_rcu_bh(pos, member) \ >> - for (pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ >> - typeof(*(pos)), member); \ >> + for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ >> + &(pos)->member)), typeof(*(pos)), member); \ >> pos; \ >> - pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ >> - typeof(*(pos)), member)) >> + pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ >> + &(pos)->member)), typeof(*(pos)), member)) >> >> /** >> * hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point >> -- >> 1.7.9.5 >> > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next RESEND 2/2] ipv6: fix sparse warning 2014-12-11 1:56 ` Ying Xue @ 2014-12-11 17:02 ` Paul E. McKenney 0 siblings, 0 replies; 7+ messages in thread From: Paul E. McKenney @ 2014-12-11 17:02 UTC (permalink / raw) To: Ying Xue Cc: davem, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all, linux-kernel On Thu, Dec 11, 2014 at 09:56:33AM +0800, Ying Xue wrote: > On 12/11/2014 12:04 AM, Paul E. McKenney wrote: > > On Wed, Dec 10, 2014 at 04:46:07PM +0800, Ying Xue wrote: > >> This fixes the following spare warning when using > >> > >> make C=1 CF=-D__CHECK_ENDIAN__ net/ipv6/addrconf.o > >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > >> net/ipv6/addrconf.c:3495:9: error: incompatible types in comparison expression (different address spaces) > >> > >> To silence above spare complaint, 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_continue_rcu_bh(). > >> > >> By the way, this commit also resolves the same error appearing in > >> hlist_for_each_entry_continue_rcu(). > >> > >> Signed-off-by: Ying Xue <ying.xue@windriver.com> > > > > If you pull the rculist.h changes from the first patch into this one, > > I will queue it up through -rcu. > > Please just queue this patch into your RCU tree. Some changes of the > first patch currently only exists in net-next tree, so it cannot be > merged into RCU tree now. Therefore, please temporarily ignore it. In > next 3.19 development cycle, I will resubmit it to you. Sounds good, but could you please rebase the second patch to be independent of the first patch? If you do that, I would be happy to queue it. Thanx, Paul > Thanks, > Ying > > > Thanx, Paul > > > >> --- > >> include/linux/rculist.h | 16 ++++++++-------- > >> 1 file changed, 8 insertions(+), 8 deletions(-) > >> > >> diff --git a/include/linux/rculist.h b/include/linux/rculist.h > >> index 866d9c9..32bd4ad 100644 > >> --- a/include/linux/rculist.h > >> +++ b/include/linux/rculist.h > >> @@ -524,11 +524,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, > >> * @member: the name of the hlist_node within the struct. > >> */ > >> #define hlist_for_each_entry_continue_rcu(pos, member) \ > >> - for (pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ > >> - typeof(*(pos)), member); \ > >> + for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ > >> + &(pos)->member)), typeof(*(pos)), member); \ > >> pos; \ > >> - pos = hlist_entry_safe(rcu_dereference((pos)->member.next),\ > >> - typeof(*(pos)), member)) > >> + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ > >> + &(pos)->member)), typeof(*(pos)), member)) > >> > >> /** > >> * hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point > >> @@ -536,11 +536,11 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, > >> * @member: the name of the hlist_node within the struct. > >> */ > >> #define hlist_for_each_entry_continue_rcu_bh(pos, member) \ > >> - for (pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ > >> - typeof(*(pos)), member); \ > >> + for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ > >> + &(pos)->member)), typeof(*(pos)), member); \ > >> pos; \ > >> - pos = hlist_entry_safe(rcu_dereference_bh((pos)->member.next),\ > >> - typeof(*(pos)), member)) > >> + pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \ > >> + &(pos)->member)), typeof(*(pos)), member)) > >> > >> /** > >> * hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point > >> -- > >> 1.7.9.5 > >> > > > > > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next RESEND 0/2] fix rculist sparse errors 2014-12-10 8:46 [PATCH net-next RESEND 0/2] fix rculist sparse errors Ying Xue 2014-12-10 8:46 ` [PATCH net-next RESEND 1/2] tipc: fix RCU sparse error Ying Xue 2014-12-10 8:46 ` [PATCH net-next RESEND 2/2] ipv6: fix sparse warning Ying Xue @ 2014-12-10 18:49 ` David Miller 2 siblings, 0 replies; 7+ messages in thread From: David Miller @ 2014-12-10 18:49 UTC (permalink / raw) To: ying.xue Cc: paulmck, eric.dumazet, jon.maloy, erik.hugne, netdev, kbuild-all, linux-kernel From: Ying Xue <ying.xue@windriver.com> Date: Wed, 10 Dec 2014 16:46:05 +0800 > When hlist_for_each_entry_continue_rcu_bh() gets "next" pointer of > hlist_node structure through rcu_dereference_bh(), sparse warning > appears as the "next" pointer is not annotated as __rcu. So if > the "next" pointer is accessed with hlist_next_rcu() macro, the > __rcu annotation will be added to the pointer. As a consequence, > sparse warning is eliminated too. > > The similar errors also appear in hlist_for_each_entry_continue_rcu() > and hlist_for_each_entry_from_rcu(). > > In this version, CC more people like Paul E. McKenney and lkml mail > list. The rculist.h changes should go via Paul's tree, not mine. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-11 17:02 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-10 8:46 [PATCH net-next RESEND 0/2] fix rculist sparse errors Ying Xue 2014-12-10 8:46 ` [PATCH net-next RESEND 1/2] tipc: fix RCU sparse error Ying Xue 2014-12-10 8:46 ` [PATCH net-next RESEND 2/2] ipv6: fix sparse warning Ying Xue 2014-12-10 16:04 ` Paul E. McKenney 2014-12-11 1:56 ` Ying Xue 2014-12-11 17:02 ` Paul E. McKenney 2014-12-10 18:49 ` [PATCH net-next RESEND 0/2] fix rculist sparse errors David Miller
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.