diff options
author | David S. Miller <davem@davemloft.net> | 2008-07-09 02:13:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-09 02:13:53 -0400 |
commit | c773e847ea8f6812804e40f52399c6921a00eab1 (patch) | |
tree | 952e0e262cc0b0f2136bc2a62938ae1d186f896a /net | |
parent | eb6aafe3f843cb0e939546c03540a3b4911b6964 (diff) |
netdev: Move _xmit_lock and xmit_lock_owner into netdev_queue.
Accesses are mostly structured such that when there are multiple TX
queues the code transformations will be a little bit simpler.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/8021q/vlan_dev.c | 15 | ||||
-rw-r--r-- | net/core/dev.c | 28 | ||||
-rw-r--r-- | net/netrom/af_netrom.c | 12 | ||||
-rw-r--r-- | net/rose/af_rose.c | 12 | ||||
-rw-r--r-- | net/sched/sch_generic.c | 9 |
5 files changed, 59 insertions, 17 deletions
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 | */ |
628 | static struct lock_class_key vlan_netdev_xmit_lock_key; | 628 | static struct lock_class_key vlan_netdev_xmit_lock_key; |
629 | 629 | ||
630 | static 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 | |||
637 | static 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 | |||
630 | static const struct header_ops vlan_header_ops = { | 642 | static 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 | */ |
264 | static const unsigned short netdev_lock_type[] = | 264 | static 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 | ||
3764 | static 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 | |||
3772 | static 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 | */ |
75 | static struct lock_class_key nr_netdev_xmit_lock_key; | 75 | static struct lock_class_key nr_netdev_xmit_lock_key; |
76 | 76 | ||
77 | static void nr_set_lockdep_one(struct netdev_queue *txq) | ||
78 | { | ||
79 | lockdep_set_class(&txq->_xmit_lock, &nr_netdev_xmit_lock_key); | ||
80 | } | ||
81 | |||
82 | static 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 | */ |
76 | static struct lock_class_key rose_netdev_xmit_lock_key; | 76 | static struct lock_class_key rose_netdev_xmit_lock_key; |
77 | 77 | ||
78 | static void rose_set_lockdep_one(struct netdev_queue *txq) | ||
79 | { | ||
80 | lockdep_set_class(&txq->_xmit_lock, &rose_netdev_xmit_lock_key); | ||
81 | } | ||
82 | |||
83 | static 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; |