Commit 43da55cb authored by Andi Kleen's avatar Andi Kleen Committed by Patrick McHardy

[NET]: Do less atomic count changes in dev_queue_xmit.

With suggestions from Herbert Xu
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb402627
...@@ -1249,17 +1249,17 @@ int __skb_linearize(struct sk_buff *skb, int gfp_mask) ...@@ -1249,17 +1249,17 @@ int __skb_linearize(struct sk_buff *skb, int gfp_mask)
return 0; return 0;
} }
#define HARD_TX_LOCK_BH(dev, cpu) { \ #define HARD_TX_LOCK(dev, cpu) { \
if ((dev->features & NETIF_F_LLTX) == 0) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \
spin_lock_bh(&dev->xmit_lock); \ spin_lock(&dev->xmit_lock); \
dev->xmit_lock_owner = cpu; \ dev->xmit_lock_owner = cpu; \
} \ } \
} }
#define HARD_TX_UNLOCK_BH(dev) { \ #define HARD_TX_UNLOCK(dev) { \
if ((dev->features & NETIF_F_LLTX) == 0) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \
dev->xmit_lock_owner = -1; \ dev->xmit_lock_owner = -1; \
spin_unlock_bh(&dev->xmit_lock); \ spin_unlock(&dev->xmit_lock); \
} \ } \
} }
...@@ -1313,7 +1313,12 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1313,7 +1313,12 @@ int dev_queue_xmit(struct sk_buff *skb)
if (skb_checksum_help(&skb, 0)) if (skb_checksum_help(&skb, 0))
goto out_kfree_skb; goto out_kfree_skb;
rcu_read_lock();
/* Disable soft irqs for various locks below. Also
* stops preemption for RCU.
*/
local_bh_disable();
/* Updates of qdisc are serialized by queue_lock. /* Updates of qdisc are serialized by queue_lock.
* The struct Qdisc which is pointed to by qdisc is now a * The struct Qdisc which is pointed to by qdisc is now a
* rcu structure - it may be accessed without acquiring * rcu structure - it may be accessed without acquiring
...@@ -1332,18 +1337,16 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1332,18 +1337,16 @@ int dev_queue_xmit(struct sk_buff *skb)
#endif #endif
if (q->enqueue) { if (q->enqueue) {
/* Grab device queue */ /* Grab device queue */
spin_lock_bh(&dev->queue_lock); spin_lock(&dev->queue_lock);
rc = q->enqueue(skb, q); rc = q->enqueue(skb, q);
qdisc_run(dev); qdisc_run(dev);
spin_unlock_bh(&dev->queue_lock); spin_unlock(&dev->queue_lock);
rcu_read_unlock();
rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc; rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc;
goto out; goto out;
} }
rcu_read_unlock();
/* The device has no queue. Common case for software devices: /* The device has no queue. Common case for software devices:
loopback, all the sorts of tunnels... loopback, all the sorts of tunnels...
...@@ -1358,12 +1361,11 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1358,12 +1361,11 @@ int dev_queue_xmit(struct sk_buff *skb)
Either shot noqueue qdisc, it is even simpler 8) Either shot noqueue qdisc, it is even simpler 8)
*/ */
if (dev->flags & IFF_UP) { if (dev->flags & IFF_UP) {
int cpu = get_cpu(); int cpu = smp_processor_id(); /* ok because BHs are off */
if (dev->xmit_lock_owner != cpu) { if (dev->xmit_lock_owner != cpu) {
HARD_TX_LOCK_BH(dev, cpu); HARD_TX_LOCK(dev, cpu);
put_cpu();
if (!netif_queue_stopped(dev)) { if (!netif_queue_stopped(dev)) {
if (netdev_nit) if (netdev_nit)
...@@ -1371,17 +1373,16 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1371,17 +1373,16 @@ int dev_queue_xmit(struct sk_buff *skb)
rc = 0; rc = 0;
if (!dev->hard_start_xmit(skb, dev)) { if (!dev->hard_start_xmit(skb, dev)) {
HARD_TX_UNLOCK_BH(dev); HARD_TX_UNLOCK(dev);
goto out; goto out;
} }
} }
HARD_TX_UNLOCK_BH(dev); HARD_TX_UNLOCK(dev);
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_CRIT "Virtual device %s asks to " printk(KERN_CRIT "Virtual device %s asks to "
"queue packet!\n", dev->name); "queue packet!\n", dev->name);
goto out_enetdown; goto out_enetdown;
} else { } else {
put_cpu();
/* Recursion is detected! It is possible, /* Recursion is detected! It is possible,
* unfortunately */ * unfortunately */
if (net_ratelimit()) if (net_ratelimit())
...@@ -1394,6 +1395,7 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1394,6 +1395,7 @@ int dev_queue_xmit(struct sk_buff *skb)
out_kfree_skb: out_kfree_skb:
kfree_skb(skb); kfree_skb(skb);
out: out:
local_bh_enable();
return rc; return rc;
} }
......
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