netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch net] net: explain the lockdep annotations for dev_uc_unsync()
@ 2020-06-26 18:25 Cong Wang
  2020-06-29  4:38 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2020-06-26 18:25 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, Taehee Yoo, Dmitry Vyukov

The lockdep annotations for dev_uc_unsync() and dev_mc_unsync()
are not easy to understand, so add some comments to explain
why they are correct.

Similar for the rest netif_addr_lock_bh() cases, they don't
need nested version.

Cc: Taehee Yoo <ap420073@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/core/dev_addr_lists.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 6393ba930097..54cd568e7c2f 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -690,6 +690,15 @@ void dev_uc_unsync(struct net_device *to, struct net_device *from)
 	if (to->addr_len != from->addr_len)
 		return;
 
+	/* netif_addr_lock_bh() uses lockdep subclass 0, this is okay for two
+	 * reasons:
+	 * 1) This is always called without any addr_list_lock, so as the
+	 *    outermost one here, it must be 0.
+	 * 2) This is called by some callers after unlinking the upper device,
+	 *    so the dev->lower_level becomes 1 again.
+	 * Therefore, the subclass for 'from' is 0, for 'to' is either 1 or
+	 * larger.
+	 */
 	netif_addr_lock_bh(from);
 	netif_addr_lock_nested(to);
 	__hw_addr_unsync(&to->uc, &from->uc, to->addr_len);
@@ -911,6 +920,7 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
 	if (to->addr_len != from->addr_len)
 		return;
 
+	/* See the above comments inside dev_uc_unsync(). */
 	netif_addr_lock_bh(from);
 	netif_addr_lock_nested(to);
 	__hw_addr_unsync(&to->mc, &from->mc, to->addr_len);
-- 
2.27.0


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

* Re: [Patch net] net: explain the lockdep annotations for dev_uc_unsync()
  2020-06-26 18:25 [Patch net] net: explain the lockdep annotations for dev_uc_unsync() Cong Wang
@ 2020-06-29  4:38 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-06-29  4:38 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, ap420073, dvyukov

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri, 26 Jun 2020 11:25:27 -0700

> The lockdep annotations for dev_uc_unsync() and dev_mc_unsync()
> are not easy to understand, so add some comments to explain
> why they are correct.
> 
> Similar for the rest netif_addr_lock_bh() cases, they don't
> need nested version.
> 
> Cc: Taehee Yoo <ap420073@gmail.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied.

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

end of thread, other threads:[~2020-06-29 20:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-26 18:25 [Patch net] net: explain the lockdep annotations for dev_uc_unsync() Cong Wang
2020-06-29  4:38 ` David Miller

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