aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/bonding/bond_main.c13
-rw-r--r--drivers/net/hamradio/bpqether.c12
-rw-r--r--drivers/net/macvlan.c14
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c12
-rw-r--r--include/linux/netdevice.h62
-rw-r--r--net/8021q/vlan_dev.c15
-rw-r--r--net/core/dev.c28
-rw-r--r--net/netrom/af_netrom.c12
-rw-r--r--net/rose/af_rose.c12
-rw-r--r--net/sched/sch_generic.c9
10 files changed, 145 insertions, 44 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index d57b65dc2c72..dc733d75a5e9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -5019,6 +5019,17 @@ static int bond_check_params(struct bond_params *params)
5019 5019
5020static struct lock_class_key bonding_netdev_xmit_lock_key; 5020static struct lock_class_key bonding_netdev_xmit_lock_key;
5021 5021
5022static void bond_set_lockdep_class_one(struct netdev_queue *txq)
5023{
5024 lockdep_set_class(&txq->_xmit_lock,
5025 &bonding_netdev_xmit_lock_key);
5026}
5027
5028static void bond_set_lockdep_class(struct net_device *dev)
5029{
5030 bond_set_lockdep_class_one(&dev->tx_queue);
5031}
5032
5022/* Create a new bond based on the specified name and bonding parameters. 5033/* Create a new bond based on the specified name and bonding parameters.
5023 * If name is NULL, obtain a suitable "bond%d" name for us. 5034 * If name is NULL, obtain a suitable "bond%d" name for us.
5024 * Caller must NOT hold rtnl_lock; we need to release it here before we 5035 * Caller must NOT hold rtnl_lock; we need to release it here before we
@@ -5076,7 +5087,7 @@ int bond_create(char *name, struct bond_params *params)
5076 goto out_bond; 5087 goto out_bond;
5077 } 5088 }
5078 5089
5079 lockdep_set_class(&bond_dev->_xmit_lock, &bonding_netdev_xmit_lock_key); 5090 bond_set_lockdep_class(bond_dev);
5080 5091
5081 netif_carrier_off(bond_dev); 5092 netif_carrier_off(bond_dev);
5082 5093
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 5f4b4c6c9f76..fb186b8c3d4d 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -124,6 +124,16 @@ static LIST_HEAD(bpq_devices);
124 */ 124 */
125static struct lock_class_key bpq_netdev_xmit_lock_key; 125static struct lock_class_key bpq_netdev_xmit_lock_key;
126 126
127static void bpq_set_lockdep_class_one(struct netdev_queue *txq)
128{
129 lockdep_set_class(&txq->_xmit_lock, &bpq_netdev_xmit_lock_key);
130}
131
132static void bpq_set_lockdep_class(struct net_device *dev)
133{
134 bpq_set_lockdep_class_one(&dev->tx_queue);
135}
136
127/* ------------------------------------------------------------------------ */ 137/* ------------------------------------------------------------------------ */
128 138
129 139
@@ -523,7 +533,7 @@ static int bpq_new_device(struct net_device *edev)
523 err = register_netdevice(ndev); 533 err = register_netdevice(ndev);
524 if (err) 534 if (err)
525 goto error; 535 goto error;
526 lockdep_set_class(&ndev->_xmit_lock, &bpq_netdev_xmit_lock_key); 536 bpq_set_lockdep_class(ndev);
527 537
528 /* List protected by RTNL */ 538 /* List protected by RTNL */
529 list_add_rcu(&bpq->bpq_list, &bpq_devices); 539 list_add_rcu(&bpq->bpq_list, &bpq_devices);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index c36a03ae9bfb..c02ceaa4a216 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -277,6 +277,17 @@ static struct lock_class_key macvlan_netdev_xmit_lock_key;
277#define MACVLAN_STATE_MASK \ 277#define MACVLAN_STATE_MASK \
278 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT)) 278 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
279 279
280static void macvlan_set_lockdep_class_one(struct netdev_queue *txq)
281{
282 lockdep_set_class(&txq->_xmit_lock,
283 &macvlan_netdev_xmit_lock_key);
284}
285
286static void macvlan_set_lockdep_class(struct net_device *dev)
287{
288 macvlan_set_lockdep_class_one(&dev->tx_queue);
289}
290
280static int macvlan_init(struct net_device *dev) 291static int macvlan_init(struct net_device *dev)
281{ 292{
282 struct macvlan_dev *vlan = netdev_priv(dev); 293 struct macvlan_dev *vlan = netdev_priv(dev);
@@ -287,7 +298,8 @@ static int macvlan_init(struct net_device *dev)
287 dev->features = lowerdev->features & MACVLAN_FEATURES; 298 dev->features = lowerdev->features & MACVLAN_FEATURES;
288 dev->iflink = lowerdev->ifindex; 299 dev->iflink = lowerdev->ifindex;
289 300
290 lockdep_set_class(&dev->_xmit_lock, &macvlan_netdev_xmit_lock_key); 301 macvlan_set_lockdep_class(dev);
302
291 return 0; 303 return 0;
292} 304}
293 305
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 09004a632ae7..c1f4bb005d92 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -3102,6 +3102,16 @@ static void prism2_clear_set_tim_queue(local_info_t *local)
3102 */ 3102 */
3103static struct lock_class_key hostap_netdev_xmit_lock_key; 3103static struct lock_class_key hostap_netdev_xmit_lock_key;
3104 3104
3105static void prism2_set_lockdep_class_one(struct netdev_queue *txq)
3106{
3107 lockdep_set_class(&txq->_xmit_lock,
3108 &hostap_netdev_xmit_lock_key);
3109}
3110
3111static void prism2_set_lockdep_class(struct net_device *dev)
3112{
3113 prism2_set_lockdep_class_one(&dev->tx_queue);
3114}
3105 3115
3106static struct net_device * 3116static struct net_device *
3107prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx, 3117prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
@@ -3268,7 +3278,7 @@ while (0)
3268 if (ret >= 0) 3278 if (ret >= 0)
3269 ret = register_netdevice(dev); 3279 ret = register_netdevice(dev);
3270 3280
3271 lockdep_set_class(&dev->_xmit_lock, &hostap_netdev_xmit_lock_key); 3281 prism2_set_lockdep_class(dev);
3272 rtnl_unlock(); 3282 rtnl_unlock();
3273 if (ret < 0) { 3283 if (ret < 0) {
3274 printk(KERN_WARNING "%s: register netdevice failed!\n", 3284 printk(KERN_WARNING "%s: register netdevice failed!\n",
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 28aa8e77cee9..c8d5f128858d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -453,6 +453,8 @@ struct netdev_queue {
453 struct net_device *dev; 453 struct net_device *dev;
454 struct Qdisc *qdisc; 454 struct Qdisc *qdisc;
455 struct sk_buff *gso_skb; 455 struct sk_buff *gso_skb;
456 spinlock_t _xmit_lock;
457 int xmit_lock_owner;
456 struct Qdisc *qdisc_sleeping; 458 struct Qdisc *qdisc_sleeping;
457 struct list_head qdisc_list; 459 struct list_head qdisc_list;
458 struct netdev_queue *next_sched; 460 struct netdev_queue *next_sched;
@@ -639,12 +641,6 @@ struct net_device
639/* 641/*
640 * One part is mostly used on xmit path (device) 642 * One part is mostly used on xmit path (device)
641 */ 643 */
642 /* hard_start_xmit synchronizer */
643 spinlock_t _xmit_lock ____cacheline_aligned_in_smp;
644 /* cpu id of processor entered to hard_start_xmit or -1,
645 if nobody entered there.
646 */
647 int xmit_lock_owner;
648 void *priv; /* pointer to private data */ 644 void *priv; /* pointer to private data */
649 int (*hard_start_xmit) (struct sk_buff *skb, 645 int (*hard_start_xmit) (struct sk_buff *skb,
650 struct net_device *dev); 646 struct net_device *dev);
@@ -1402,52 +1398,72 @@ static inline void netif_rx_complete(struct net_device *dev,
1402 * 1398 *
1403 * Get network device transmit lock 1399 * Get network device transmit lock
1404 */ 1400 */
1405static inline void __netif_tx_lock(struct net_device *dev, int cpu) 1401static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
1406{ 1402{
1407 spin_lock(&dev->_xmit_lock); 1403 spin_lock(&txq->_xmit_lock);
1408 dev->xmit_lock_owner = cpu; 1404 txq->xmit_lock_owner = cpu;
1409} 1405}
1410 1406
1411static inline void netif_tx_lock(struct net_device *dev) 1407static inline void netif_tx_lock(struct net_device *dev)
1412{ 1408{
1413 __netif_tx_lock(dev, smp_processor_id()); 1409 __netif_tx_lock(&dev->tx_queue, smp_processor_id());
1410}
1411
1412static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
1413{
1414 spin_lock_bh(&txq->_xmit_lock);
1415 txq->xmit_lock_owner = smp_processor_id();
1414} 1416}
1415 1417
1416static inline void netif_tx_lock_bh(struct net_device *dev) 1418static inline void netif_tx_lock_bh(struct net_device *dev)
1417{ 1419{
1418 spin_lock_bh(&dev->_xmit_lock); 1420 __netif_tx_lock_bh(&dev->tx_queue);
1419 dev->xmit_lock_owner = smp_processor_id();
1420} 1421}
1421 1422
1422static inline int netif_tx_trylock(struct net_device *dev) 1423static inline int __netif_tx_trylock(struct netdev_queue *txq)
1423{ 1424{
1424 int ok = spin_trylock(&dev->_xmit_lock); 1425 int ok = spin_trylock(&txq->_xmit_lock);
1425 if (likely(ok)) 1426 if (likely(ok))
1426 dev->xmit_lock_owner = smp_processor_id(); 1427 txq->xmit_lock_owner = smp_processor_id();
1427 return ok; 1428 return ok;
1428} 1429}
1429 1430
1431static inline int netif_tx_trylock(struct net_device *dev)
1432{
1433 return __netif_tx_trylock(&dev->tx_queue);
1434}
1435
1436static inline void __netif_tx_unlock(struct netdev_queue *txq)
1437{
1438 txq->xmit_lock_owner = -1;
1439 spin_unlock(&txq->_xmit_lock);
1440}
1441
1430static inline void netif_tx_unlock(struct net_device *dev) 1442static inline void netif_tx_unlock(struct net_device *dev)
1431{ 1443{
1432 dev->xmit_lock_owner = -1; 1444 __netif_tx_unlock(&dev->tx_queue);
1433 spin_unlock(&dev->_xmit_lock); 1445}
1446
1447static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
1448{
1449 txq->xmit_lock_owner = -1;
1450 spin_unlock_bh(&txq->_xmit_lock);
1434} 1451}
1435 1452
1436static inline void netif_tx_unlock_bh(struct net_device *dev) 1453static inline void netif_tx_unlock_bh(struct net_device *dev)
1437{ 1454{
1438 dev->xmit_lock_owner = -1; 1455 __netif_tx_unlock_bh(&dev->tx_queue);
1439 spin_unlock_bh(&dev->_xmit_lock);
1440} 1456}
1441 1457
1442#define HARD_TX_LOCK(dev, cpu) { \ 1458#define HARD_TX_LOCK(dev, txq, cpu) { \
1443 if ((dev->features & NETIF_F_LLTX) == 0) { \ 1459 if ((dev->features & NETIF_F_LLTX) == 0) { \
1444 __netif_tx_lock(dev, cpu); \ 1460 __netif_tx_lock(txq, cpu); \
1445 } \ 1461 } \
1446} 1462}
1447 1463
1448#define HARD_TX_UNLOCK(dev) { \ 1464#define HARD_TX_UNLOCK(dev, txq) { \
1449 if ((dev->features & NETIF_F_LLTX) == 0) { \ 1465 if ((dev->features & NETIF_F_LLTX) == 0) { \
1450 netif_tx_unlock(dev); \ 1466 __netif_tx_unlock(txq); \
1451 } \ 1467 } \
1452} 1468}
1453 1469
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index b6e52c025fd8..8efa399823e3 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -627,6 +627,18 @@ static void vlan_dev_set_rx_mode(struct net_device *vlan_dev)
627 */ 627 */
628static struct lock_class_key vlan_netdev_xmit_lock_key; 628static struct lock_class_key vlan_netdev_xmit_lock_key;
629 629
630static void vlan_dev_set_lockdep_one(struct netdev_queue *txq,
631 int subclass)
632{
633 lockdep_set_class_and_subclass(&txq->_xmit_lock,
634 &vlan_netdev_xmit_lock_key, subclass);
635}
636
637static void vlan_dev_set_lockdep_class(struct net_device *dev, int subclass)
638{
639 vlan_dev_set_lockdep_one(&dev->tx_queue, subclass);
640}
641
630static const struct header_ops vlan_header_ops = { 642static const struct header_ops vlan_header_ops = {
631 .create = vlan_dev_hard_header, 643 .create = vlan_dev_hard_header,
632 .rebuild = vlan_dev_rebuild_header, 644 .rebuild = vlan_dev_rebuild_header,
@@ -668,8 +680,7 @@ static int vlan_dev_init(struct net_device *dev)
668 if (is_vlan_dev(real_dev)) 680 if (is_vlan_dev(real_dev))
669 subclass = 1; 681 subclass = 1;
670 682
671 lockdep_set_class_and_subclass(&dev->_xmit_lock, 683 vlan_dev_set_lockdep_class(dev, subclass);
672 &vlan_netdev_xmit_lock_key, subclass);
673 return 0; 684 return 0;
674} 685}
675 686
diff --git a/net/core/dev.c b/net/core/dev.c
index 0218b0b9be80..a29a359b15d1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -258,7 +258,7 @@ DEFINE_PER_CPU(struct softnet_data, softnet_data);
258 258
259#ifdef CONFIG_DEBUG_LOCK_ALLOC 259#ifdef CONFIG_DEBUG_LOCK_ALLOC
260/* 260/*
261 * register_netdevice() inits dev->_xmit_lock and sets lockdep class 261 * register_netdevice() inits txq->_xmit_lock and sets lockdep class
262 * according to dev->type 262 * according to dev->type
263 */ 263 */
264static const unsigned short netdev_lock_type[] = 264static const unsigned short netdev_lock_type[] =
@@ -1758,19 +1758,19 @@ gso:
1758 if (dev->flags & IFF_UP) { 1758 if (dev->flags & IFF_UP) {
1759 int cpu = smp_processor_id(); /* ok because BHs are off */ 1759 int cpu = smp_processor_id(); /* ok because BHs are off */
1760 1760
1761 if (dev->xmit_lock_owner != cpu) { 1761 if (txq->xmit_lock_owner != cpu) {
1762 1762
1763 HARD_TX_LOCK(dev, cpu); 1763 HARD_TX_LOCK(dev, txq, cpu);
1764 1764
1765 if (!netif_queue_stopped(dev) && 1765 if (!netif_queue_stopped(dev) &&
1766 !netif_subqueue_stopped(dev, skb)) { 1766 !netif_subqueue_stopped(dev, skb)) {
1767 rc = 0; 1767 rc = 0;
1768 if (!dev_hard_start_xmit(skb, dev)) { 1768 if (!dev_hard_start_xmit(skb, dev)) {
1769 HARD_TX_UNLOCK(dev); 1769 HARD_TX_UNLOCK(dev, txq);
1770 goto out; 1770 goto out;
1771 } 1771 }
1772 } 1772 }
1773 HARD_TX_UNLOCK(dev); 1773 HARD_TX_UNLOCK(dev, txq);
1774 if (net_ratelimit()) 1774 if (net_ratelimit())
1775 printk(KERN_CRIT "Virtual device %s asks to " 1775 printk(KERN_CRIT "Virtual device %s asks to "
1776 "queue packet!\n", dev->name); 1776 "queue packet!\n", dev->name);
@@ -3761,6 +3761,20 @@ static void rollback_registered(struct net_device *dev)
3761 dev_put(dev); 3761 dev_put(dev);
3762} 3762}
3763 3763
3764static void __netdev_init_queue_locks_one(struct netdev_queue *dev_queue,
3765 struct net_device *dev)
3766{
3767 spin_lock_init(&dev_queue->_xmit_lock);
3768 netdev_set_lockdep_class(&dev_queue->_xmit_lock, dev->type);
3769 dev_queue->xmit_lock_owner = -1;
3770}
3771
3772static void netdev_init_queue_locks(struct net_device *dev)
3773{
3774 __netdev_init_queue_locks_one(&dev->tx_queue, dev);
3775 __netdev_init_queue_locks_one(&dev->rx_queue, dev);
3776}
3777
3764/** 3778/**
3765 * register_netdevice - register a network device 3779 * register_netdevice - register a network device
3766 * @dev: device to register 3780 * @dev: device to register
@@ -3795,9 +3809,7 @@ int register_netdevice(struct net_device *dev)
3795 BUG_ON(!dev_net(dev)); 3809 BUG_ON(!dev_net(dev));
3796 net = dev_net(dev); 3810 net = dev_net(dev);
3797 3811
3798 spin_lock_init(&dev->_xmit_lock); 3812 netdev_init_queue_locks(dev);
3799 netdev_set_lockdep_class(&dev->_xmit_lock, dev->type);
3800 dev->xmit_lock_owner = -1;
3801 3813
3802 dev->iflink = -1; 3814 dev->iflink = -1;
3803 3815
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 74884f4a6255..819afc449e1e 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -74,6 +74,16 @@ static const struct proto_ops nr_proto_ops;
74 */ 74 */
75static struct lock_class_key nr_netdev_xmit_lock_key; 75static struct lock_class_key nr_netdev_xmit_lock_key;
76 76
77static void nr_set_lockdep_one(struct netdev_queue *txq)
78{
79 lockdep_set_class(&txq->_xmit_lock, &nr_netdev_xmit_lock_key);
80}
81
82static void nr_set_lockdep_key(struct net_device *dev)
83{
84 nr_set_lockdep_one(&dev->tx_queue);
85}
86
77/* 87/*
78 * Socket removal during an interrupt is now safe. 88 * Socket removal during an interrupt is now safe.
79 */ 89 */
@@ -1430,7 +1440,7 @@ static int __init nr_proto_init(void)
1430 free_netdev(dev); 1440 free_netdev(dev);
1431 goto fail; 1441 goto fail;
1432 } 1442 }
1433 lockdep_set_class(&dev->_xmit_lock, &nr_netdev_xmit_lock_key); 1443 nr_set_lockdep_key(dev);
1434 dev_nr[i] = dev; 1444 dev_nr[i] = dev;
1435 } 1445 }
1436 1446
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 46461a69cd0f..7dbbc0891623 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -75,6 +75,16 @@ ax25_address rose_callsign;
75 */ 75 */
76static struct lock_class_key rose_netdev_xmit_lock_key; 76static struct lock_class_key rose_netdev_xmit_lock_key;
77 77
78static void rose_set_lockdep_one(struct netdev_queue *txq)
79{
80 lockdep_set_class(&txq->_xmit_lock, &rose_netdev_xmit_lock_key);
81}
82
83static void rose_set_lockdep_key(struct net_device *dev)
84{
85 rose_set_lockdep_one(&dev->tx_queue);
86}
87
78/* 88/*
79 * Convert a ROSE address into text. 89 * Convert a ROSE address into text.
80 */ 90 */
@@ -1576,7 +1586,7 @@ static int __init rose_proto_init(void)
1576 free_netdev(dev); 1586 free_netdev(dev);
1577 goto fail; 1587 goto fail;
1578 } 1588 }
1579 lockdep_set_class(&dev->_xmit_lock, &rose_netdev_xmit_lock_key); 1589 rose_set_lockdep_key(dev);
1580 dev_rose[i] = dev; 1590 dev_rose[i] = dev;
1581 } 1591 }
1582 1592
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index fcc7533f0bcc..b6a36d394663 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -92,10 +92,9 @@ static inline int handle_dev_cpu_collision(struct sk_buff *skb,
92 struct netdev_queue *dev_queue, 92 struct netdev_queue *dev_queue,
93 struct Qdisc *q) 93 struct Qdisc *q)
94{ 94{
95 struct net_device *dev = dev_queue->dev;
96 int ret; 95 int ret;
97 96
98 if (unlikely(dev->xmit_lock_owner == smp_processor_id())) { 97 if (unlikely(dev_queue->xmit_lock_owner == smp_processor_id())) {
99 /* 98 /*
100 * Same CPU holding the lock. It may be a transient 99 * Same CPU holding the lock. It may be a transient
101 * configuration error, when hard_start_xmit() recurses. We 100 * configuration error, when hard_start_xmit() recurses. We
@@ -105,7 +104,7 @@ static inline int handle_dev_cpu_collision(struct sk_buff *skb,
105 kfree_skb(skb); 104 kfree_skb(skb);
106 if (net_ratelimit()) 105 if (net_ratelimit())
107 printk(KERN_WARNING "Dead loop on netdevice %s, " 106 printk(KERN_WARNING "Dead loop on netdevice %s, "
108 "fix it urgently!\n", dev->name); 107 "fix it urgently!\n", dev_queue->dev->name);
109 ret = qdisc_qlen(q); 108 ret = qdisc_qlen(q);
110 } else { 109 } else {
111 /* 110 /*
@@ -155,10 +154,10 @@ static inline int qdisc_restart(struct netdev_queue *txq)
155 154
156 dev = txq->dev; 155 dev = txq->dev;
157 156
158 HARD_TX_LOCK(dev, smp_processor_id()); 157 HARD_TX_LOCK(dev, txq, smp_processor_id());
159 if (!netif_subqueue_stopped(dev, skb)) 158 if (!netif_subqueue_stopped(dev, skb))
160 ret = dev_hard_start_xmit(skb, dev); 159 ret = dev_hard_start_xmit(skb, dev);
161 HARD_TX_UNLOCK(dev); 160 HARD_TX_UNLOCK(dev, txq);
162 161
163 spin_lock(&txq->lock); 162 spin_lock(&txq->lock);
164 q = txq->qdisc; 163 q = txq->qdisc;