developer | 7e32f7e | 2022-05-18 21:10:08 +0800 | [diff] [blame^] | 1 | From be74294ffa24f5fbc0d6643842e3e095447e17a2 Mon Sep 17 00:00:00 2001 |
| 2 | From: Cong Wang <xiyou.wangcong@gmail.com> |
| 3 | Date: Fri, 26 Jun 2020 11:24:22 -0700 |
| 4 | Subject: net: get rid of lockdep_set_class_and_subclass() |
| 5 | |
| 6 | lockdep_set_class_and_subclass() is meant to reduce |
| 7 | the _nested() annotations by assigning a default subclass. |
| 8 | For addr_list_lock, we have to compute the subclass at |
| 9 | run-time as the netdevice topology changes after creation. |
| 10 | |
| 11 | So, we should just get rid of these |
| 12 | lockdep_set_class_and_subclass() and stick with our _nested() |
| 13 | annotations. |
| 14 | |
| 15 | Fixes: 845e0ebb4408 ("net: change addr_list_lock back to static key") |
| 16 | Suggested-by: Taehee Yoo <ap420073@gmail.com> |
| 17 | Cc: Dmitry Vyukov <dvyukov@google.com> |
| 18 | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> |
| 19 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 20 | --- |
| 21 | drivers/net/macsec.c | 5 ++--- |
| 22 | drivers/net/macvlan.c | 5 ++--- |
| 23 | net/8021q/vlan_dev.c | 9 ++++----- |
| 24 | 3 files changed, 8 insertions(+), 11 deletions(-) |
| 25 | |
| 26 | diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c |
| 27 | index e56547bfdac9a..9159846b8b938 100644 |
| 28 | --- a/drivers/net/macsec.c |
| 29 | +++ b/drivers/net/macsec.c |
| 30 | @@ -4052,9 +4052,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev, |
| 31 | return err; |
| 32 | |
| 33 | netdev_lockdep_set_classes(dev); |
| 34 | - lockdep_set_class_and_subclass(&dev->addr_list_lock, |
| 35 | - &macsec_netdev_addr_lock_key, |
| 36 | - dev->lower_level); |
| 37 | + lockdep_set_class(&dev->addr_list_lock, |
| 38 | + &macsec_netdev_addr_lock_key); |
| 39 | |
| 40 | err = netdev_upper_dev_link(real_dev, dev, extack); |
| 41 | if (err < 0) |
| 42 | diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c |
| 43 | index 6a6cc9f753075..4942f6112e51f 100644 |
| 44 | --- a/drivers/net/macvlan.c |
| 45 | +++ b/drivers/net/macvlan.c |
| 46 | @@ -880,9 +880,8 @@ static struct lock_class_key macvlan_netdev_addr_lock_key; |
| 47 | static void macvlan_set_lockdep_class(struct net_device *dev) |
| 48 | { |
| 49 | netdev_lockdep_set_classes(dev); |
| 50 | - lockdep_set_class_and_subclass(&dev->addr_list_lock, |
| 51 | - &macvlan_netdev_addr_lock_key, |
| 52 | - dev->lower_level); |
| 53 | + lockdep_set_class(&dev->addr_list_lock, |
| 54 | + &macvlan_netdev_addr_lock_key); |
| 55 | } |
| 56 | |
| 57 | static int macvlan_init(struct net_device *dev) |
| 58 | diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c |
| 59 | index c8d6a07e23c57..3dd7c972677be 100644 |
| 60 | --- a/net/8021q/vlan_dev.c |
| 61 | +++ b/net/8021q/vlan_dev.c |
| 62 | @@ -503,11 +503,10 @@ static void vlan_dev_set_lockdep_one(struct net_device *dev, |
| 63 | lockdep_set_class(&txq->_xmit_lock, &vlan_netdev_xmit_lock_key); |
| 64 | } |
| 65 | |
| 66 | -static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass) |
| 67 | +static void vlan_dev_set_lockdep_class(struct net_device *dev) |
| 68 | { |
| 69 | - lockdep_set_class_and_subclass(&dev->addr_list_lock, |
| 70 | - &vlan_netdev_addr_lock_key, |
| 71 | - subclass); |
| 72 | + lockdep_set_class(&dev->addr_list_lock, |
| 73 | + &vlan_netdev_addr_lock_key); |
| 74 | netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, NULL); |
| 75 | } |
| 76 | |
| 77 | @@ -601,7 +600,7 @@ static int vlan_dev_init(struct net_device *dev) |
| 78 | |
| 79 | SET_NETDEV_DEVTYPE(dev, &vlan_type); |
| 80 | |
| 81 | - vlan_dev_set_lockdep_class(dev, dev->lower_level); |
| 82 | + vlan_dev_set_lockdep_class(dev); |
| 83 | |
| 84 | vlan->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); |
| 85 | if (!vlan->vlan_pcpu_stats) |
| 86 | -- |
| 87 | cgit 1.2.3-1.el7 |
| 88 | |