Commit cf508b12 authored by David S. Miller's avatar David S. Miller

netdev: Handle ->addr_list_lock just like ->_xmit_lock for lockdep.

The new address list lock needs to handle the same device layering
issues that the _xmit_lock one does.

This integrates work done by Patrick McHardy.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d29f749e
...@@ -5041,6 +5041,7 @@ static int bond_check_params(struct bond_params *params) ...@@ -5041,6 +5041,7 @@ static int bond_check_params(struct bond_params *params)
} }
static struct lock_class_key bonding_netdev_xmit_lock_key; static struct lock_class_key bonding_netdev_xmit_lock_key;
static struct lock_class_key bonding_netdev_addr_lock_key;
static void bond_set_lockdep_class_one(struct net_device *dev, static void bond_set_lockdep_class_one(struct net_device *dev,
struct netdev_queue *txq, struct netdev_queue *txq,
...@@ -5052,6 +5053,8 @@ static void bond_set_lockdep_class_one(struct net_device *dev, ...@@ -5052,6 +5053,8 @@ static void bond_set_lockdep_class_one(struct net_device *dev,
static void bond_set_lockdep_class(struct net_device *dev) static void bond_set_lockdep_class(struct net_device *dev)
{ {
lockdep_set_class(&dev->addr_list_lock,
&bonding_netdev_addr_lock_key);
netdev_for_each_tx_queue(dev, bond_set_lockdep_class_one, NULL); netdev_for_each_tx_queue(dev, bond_set_lockdep_class_one, NULL);
} }
......
...@@ -123,6 +123,7 @@ static LIST_HEAD(bpq_devices); ...@@ -123,6 +123,7 @@ static LIST_HEAD(bpq_devices);
* off into a separate class since they always nest. * off into a separate class since they always nest.
*/ */
static struct lock_class_key bpq_netdev_xmit_lock_key; static struct lock_class_key bpq_netdev_xmit_lock_key;
static struct lock_class_key bpq_netdev_addr_lock_key;
static void bpq_set_lockdep_class_one(struct net_device *dev, static void bpq_set_lockdep_class_one(struct net_device *dev,
struct netdev_queue *txq, struct netdev_queue *txq,
...@@ -133,6 +134,7 @@ static void bpq_set_lockdep_class_one(struct net_device *dev, ...@@ -133,6 +134,7 @@ static void bpq_set_lockdep_class_one(struct net_device *dev,
static void bpq_set_lockdep_class(struct net_device *dev) static void bpq_set_lockdep_class(struct net_device *dev)
{ {
lockdep_set_class(&dev->addr_list_lock, &bpq_netdev_addr_lock_key);
netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one, NULL); netdev_for_each_tx_queue(dev, bpq_set_lockdep_class_one, NULL);
} }
......
...@@ -276,6 +276,7 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu) ...@@ -276,6 +276,7 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu)
* separate class since they always nest. * separate class since they always nest.
*/ */
static struct lock_class_key macvlan_netdev_xmit_lock_key; static struct lock_class_key macvlan_netdev_xmit_lock_key;
static struct lock_class_key macvlan_netdev_addr_lock_key;
#define MACVLAN_FEATURES \ #define MACVLAN_FEATURES \
(NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \ (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
...@@ -295,6 +296,8 @@ static void macvlan_set_lockdep_class_one(struct net_device *dev, ...@@ -295,6 +296,8 @@ static void macvlan_set_lockdep_class_one(struct net_device *dev,
static void macvlan_set_lockdep_class(struct net_device *dev) static void macvlan_set_lockdep_class(struct net_device *dev)
{ {
lockdep_set_class(&dev->addr_list_lock,
&macvlan_netdev_addr_lock_key);
netdev_for_each_tx_queue(dev, macvlan_set_lockdep_class_one, NULL); netdev_for_each_tx_queue(dev, macvlan_set_lockdep_class_one, NULL);
} }
......
...@@ -3101,6 +3101,7 @@ static void prism2_clear_set_tim_queue(local_info_t *local) ...@@ -3101,6 +3101,7 @@ static void prism2_clear_set_tim_queue(local_info_t *local)
* This is a natural nesting, which needs a split lock type. * This is a natural nesting, which needs a split lock type.
*/ */
static struct lock_class_key hostap_netdev_xmit_lock_key; static struct lock_class_key hostap_netdev_xmit_lock_key;
static struct lock_class_key hostap_netdev_addr_lock_key;
static void prism2_set_lockdep_class_one(struct net_device *dev, static void prism2_set_lockdep_class_one(struct net_device *dev,
struct netdev_queue *txq, struct netdev_queue *txq,
...@@ -3112,6 +3113,8 @@ static void prism2_set_lockdep_class_one(struct net_device *dev, ...@@ -3112,6 +3113,8 @@ static void prism2_set_lockdep_class_one(struct net_device *dev,
static void prism2_set_lockdep_class(struct net_device *dev) static void prism2_set_lockdep_class(struct net_device *dev)
{ {
lockdep_set_class(&dev->addr_list_lock,
&hostap_netdev_addr_lock_key);
netdev_for_each_tx_queue(dev, prism2_set_lockdep_class_one, NULL); netdev_for_each_tx_queue(dev, prism2_set_lockdep_class_one, NULL);
} }
......
...@@ -569,6 +569,7 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev) ...@@ -569,6 +569,7 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev)
* separate class since they always nest. * separate class since they always nest.
*/ */
static struct lock_class_key vlan_netdev_xmit_lock_key; static struct lock_class_key vlan_netdev_xmit_lock_key;
static struct lock_class_key vlan_netdev_addr_lock_key;
static void vlan_dev_set_lockdep_one(struct net_device *dev, static void vlan_dev_set_lockdep_one(struct net_device *dev,
struct netdev_queue *txq, struct netdev_queue *txq,
...@@ -581,6 +582,9 @@ static void vlan_dev_set_lockdep_one(struct net_device *dev, ...@@ -581,6 +582,9 @@ static void vlan_dev_set_lockdep_one(struct net_device *dev,
static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass) static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass)
{ {
lockdep_set_class_and_subclass(&dev->addr_list_lock,
&vlan_netdev_addr_lock_key,
subclass);
netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass); netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass);
} }
......
...@@ -261,7 +261,7 @@ static RAW_NOTIFIER_HEAD(netdev_chain); ...@@ -261,7 +261,7 @@ static RAW_NOTIFIER_HEAD(netdev_chain);
DEFINE_PER_CPU(struct softnet_data, softnet_data); DEFINE_PER_CPU(struct softnet_data, softnet_data);
#ifdef CONFIG_DEBUG_LOCK_ALLOC #ifdef CONFIG_LOCKDEP
/* /*
* register_netdevice() inits txq->_xmit_lock and sets lockdep class * register_netdevice() inits txq->_xmit_lock and sets lockdep class
* according to dev->type * according to dev->type
...@@ -301,6 +301,7 @@ static const char *netdev_lock_name[] = ...@@ -301,6 +301,7 @@ static const char *netdev_lock_name[] =
"_xmit_NONE"}; "_xmit_NONE"};
static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)]; static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)];
static struct lock_class_key netdev_addr_lock_key[ARRAY_SIZE(netdev_lock_type)];
static inline unsigned short netdev_lock_pos(unsigned short dev_type) static inline unsigned short netdev_lock_pos(unsigned short dev_type)
{ {
...@@ -313,7 +314,7 @@ static inline unsigned short netdev_lock_pos(unsigned short dev_type) ...@@ -313,7 +314,7 @@ static inline unsigned short netdev_lock_pos(unsigned short dev_type)
return ARRAY_SIZE(netdev_lock_type) - 1; return ARRAY_SIZE(netdev_lock_type) - 1;
} }
static inline void netdev_set_lockdep_class(spinlock_t *lock, static inline void netdev_set_xmit_lockdep_class(spinlock_t *lock,
unsigned short dev_type) unsigned short dev_type)
{ {
int i; int i;
...@@ -322,11 +323,24 @@ static inline void netdev_set_lockdep_class(spinlock_t *lock, ...@@ -322,11 +323,24 @@ static inline void netdev_set_lockdep_class(spinlock_t *lock,
lockdep_set_class_and_name(lock, &netdev_xmit_lock_key[i], lockdep_set_class_and_name(lock, &netdev_xmit_lock_key[i],
netdev_lock_name[i]); netdev_lock_name[i]);
} }
static inline void netdev_set_addr_lockdep_class(struct net_device *dev)
{
int i;
i = netdev_lock_pos(dev->type);
lockdep_set_class_and_name(&dev->addr_list_lock,
&netdev_addr_lock_key[i],
netdev_lock_name[i]);
}
#else #else
static inline void netdev_set_lockdep_class(spinlock_t *lock, static inline void netdev_set_xmit_lockdep_class(spinlock_t *lock,
unsigned short dev_type) unsigned short dev_type)
{ {
} }
static inline void netdev_set_addr_lockdep_class(struct net_device *dev)
{
}
#endif #endif
/******************************************************************************* /*******************************************************************************
...@@ -3851,7 +3865,7 @@ static void __netdev_init_queue_locks_one(struct net_device *dev, ...@@ -3851,7 +3865,7 @@ static void __netdev_init_queue_locks_one(struct net_device *dev,
void *_unused) void *_unused)
{ {
spin_lock_init(&dev_queue->_xmit_lock); spin_lock_init(&dev_queue->_xmit_lock);
netdev_set_lockdep_class(&dev_queue->_xmit_lock, dev->type); netdev_set_xmit_lockdep_class(&dev_queue->_xmit_lock, dev->type);
dev_queue->xmit_lock_owner = -1; dev_queue->xmit_lock_owner = -1;
} }
...@@ -3896,6 +3910,7 @@ int register_netdevice(struct net_device *dev) ...@@ -3896,6 +3910,7 @@ int register_netdevice(struct net_device *dev)
net = dev_net(dev); net = dev_net(dev);
spin_lock_init(&dev->addr_list_lock); spin_lock_init(&dev->addr_list_lock);
netdev_set_addr_lockdep_class(dev);
netdev_init_queue_locks(dev); netdev_init_queue_locks(dev);
dev->iflink = -1; dev->iflink = -1;
......
...@@ -73,6 +73,7 @@ static const struct proto_ops nr_proto_ops; ...@@ -73,6 +73,7 @@ static const struct proto_ops nr_proto_ops;
* separate class since they always nest. * separate class since they always nest.
*/ */
static struct lock_class_key nr_netdev_xmit_lock_key; static struct lock_class_key nr_netdev_xmit_lock_key;
static struct lock_class_key nr_netdev_addr_lock_key;
static void nr_set_lockdep_one(struct net_device *dev, static void nr_set_lockdep_one(struct net_device *dev,
struct netdev_queue *txq, struct netdev_queue *txq,
...@@ -83,6 +84,7 @@ static void nr_set_lockdep_one(struct net_device *dev, ...@@ -83,6 +84,7 @@ static void nr_set_lockdep_one(struct net_device *dev,
static void nr_set_lockdep_key(struct net_device *dev) static void nr_set_lockdep_key(struct net_device *dev)
{ {
lockdep_set_class(&dev->addr_list_lock, &nr_netdev_addr_lock_key);
netdev_for_each_tx_queue(dev, nr_set_lockdep_one, NULL); netdev_for_each_tx_queue(dev, nr_set_lockdep_one, NULL);
} }
......
...@@ -74,6 +74,7 @@ ax25_address rose_callsign; ...@@ -74,6 +74,7 @@ ax25_address rose_callsign;
* separate class since they always nest. * separate class since they always nest.
*/ */
static struct lock_class_key rose_netdev_xmit_lock_key; static struct lock_class_key rose_netdev_xmit_lock_key;
static struct lock_class_key rose_netdev_addr_lock_key;
static void rose_set_lockdep_one(struct net_device *dev, static void rose_set_lockdep_one(struct net_device *dev,
struct netdev_queue *txq, struct netdev_queue *txq,
...@@ -84,6 +85,7 @@ static void rose_set_lockdep_one(struct net_device *dev, ...@@ -84,6 +85,7 @@ static void rose_set_lockdep_one(struct net_device *dev,
static void rose_set_lockdep_key(struct net_device *dev) static void rose_set_lockdep_key(struct net_device *dev)
{ {
lockdep_set_class(&dev->addr_list_lock, &rose_netdev_addr_lock_key);
netdev_for_each_tx_queue(dev, rose_set_lockdep_one, NULL); netdev_for_each_tx_queue(dev, rose_set_lockdep_one, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment