diff mbox series

[v1] net: macvlan: Use built-in RCU list checking

Message ID 20221108125254.688234-1-nashuiliang@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v1] net: macvlan: Use built-in RCU list checking | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Chuang Wang Nov. 8, 2022, 12:52 p.m. UTC
hlist_for_each_entry_rcu() has built-in RCU and lock checking.

Pass cond argument to hlist_for_each_entry_rcu() to silence false
lockdep warning when CONFIG_PROVE_RCU_LIST is enabled.

Execute as follow:

 ip link add link eth0 type macvlan mode source macaddr add <MAC-ADDR>

The rtnl_lock is held when macvlan_hash_lookup_source() or
macvlan_fill_info_macaddr() are called in the non-RCU read side section.
So, pass lockdep_rtnl_is_held() to silence false lockdep warning.

Signed-off-by: Chuang Wang <nashuiliang@gmail.com>
---
v0 -> v1:
- fix typo

 drivers/net/macvlan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paolo Abeni Nov. 10, 2022, 10:57 a.m. UTC | #1
Hello,

On Tue, 2022-11-08 at 20:52 +0800, Chuang Wang wrote:
> hlist_for_each_entry_rcu() has built-in RCU and lock checking.
> 
> Pass cond argument to hlist_for_each_entry_rcu() to silence false
> lockdep warning when CONFIG_PROVE_RCU_LIST is enabled.
> 
> Execute as follow:
> 
>  ip link add link eth0 type macvlan mode source macaddr add <MAC-ADDR>
> 
> The rtnl_lock is held when macvlan_hash_lookup_source() or
> macvlan_fill_info_macaddr() are called in the non-RCU read side section.
> So, pass lockdep_rtnl_is_held() to silence false lockdep warning.
> 
> Signed-off-by: Chuang Wang <nashuiliang@gmail.com>

The patch LGTM, but IMHO this should target the -net tree, as it's
addressing an issue bothering people. 

Can you please re-submit, specifying the target tree into the subj and
including a suitable Fixes tag?

Thanks!

Paolo
Chuang Wang Nov. 10, 2022, 11:27 a.m. UTC | #2
Hi,

On Thu, Nov 10, 2022 at 6:57 PM Paolo Abeni <pabeni@redhat.com> wrote:
>
> Hello,
>
> On Tue, 2022-11-08 at 20:52 +0800, Chuang Wang wrote:
> > hlist_for_each_entry_rcu() has built-in RCU and lock checking.
> >
> > Pass cond argument to hlist_for_each_entry_rcu() to silence false
> > lockdep warning when CONFIG_PROVE_RCU_LIST is enabled.
> >
> > Execute as follow:
> >
> >  ip link add link eth0 type macvlan mode source macaddr add <MAC-ADDR>
> >
> > The rtnl_lock is held when macvlan_hash_lookup_source() or
> > macvlan_fill_info_macaddr() are called in the non-RCU read side section.
> > So, pass lockdep_rtnl_is_held() to silence false lockdep warning.
> >
> > Signed-off-by: Chuang Wang <nashuiliang@gmail.com>
>
> The patch LGTM, but IMHO this should target the -net tree, as it's
> addressing an issue bothering people.

Sorry, can I sincerely ask if the -net tree is
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git or
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git ?

>
> Can you please re-submit, specifying the target tree into the subj and
> including a suitable Fixes tag?

ok, I will add a suitable Fixed tag and resubmit. Thanks.

>
> Thanks!
>
> Paolo
>
>
Jakub Kicinski Nov. 10, 2022, 4:46 p.m. UTC | #3
On Thu, 10 Nov 2022 19:27:52 +0800 Chuang W wrote:
> > The patch LGTM, but IMHO this should target the -net tree, as it's
> > addressing an issue bothering people.  
> 
> Sorry, can I sincerely ask if the -net tree is
> git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git or

This one, but you should also put the name in the subject, like this:

	[PATCH net v2] net: macvlan: Use built-in RCU list checking

> git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git ?
diff mbox series

Patch

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index c58fea63be7d..deb7929004a7 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -141,7 +141,7 @@  static struct macvlan_source_entry *macvlan_hash_lookup_source(
 	u32 idx = macvlan_eth_hash(addr);
 	struct hlist_head *h = &vlan->port->vlan_source_hash[idx];
 
-	hlist_for_each_entry_rcu(entry, h, hlist) {
+	hlist_for_each_entry_rcu(entry, h, hlist, lockdep_rtnl_is_held()) {
 		if (ether_addr_equal_64bits(entry->addr, addr) &&
 		    entry->vlan == vlan)
 			return entry;
@@ -1645,7 +1645,7 @@  static int macvlan_fill_info_macaddr(struct sk_buff *skb,
 	struct hlist_head *h = &vlan->port->vlan_source_hash[i];
 	struct macvlan_source_entry *entry;
 
-	hlist_for_each_entry_rcu(entry, h, hlist) {
+	hlist_for_each_entry_rcu(entry, h, hlist, lockdep_rtnl_is_held()) {
 		if (entry->vlan != vlan)
 			continue;
 		if (nla_put(skb, IFLA_MACVLAN_MACADDR, ETH_ALEN, entry->addr))