vlan: use struct netdev_queue counters instead of dev->stats
authorEric Dumazet <dada1@cosmosbay.com>
Mon, 18 May 2009 00:35:38 +0000 (00:35 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 May 2009 22:15:06 +0000 (15:15 -0700)
We can update netdev_queue tx_bytes/tx_packets/tx_dropped counters instead
of dev->stats ones, to reduce number of cache lines dirtied in xmit path.

This fixes a performance problem on SMP when many different cpus take
vlan tx path.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/8021q/vlan_dev.c
net/8021q/vlanproc.c

index 25ba41e35338d1fbf8993bb9b45493c79bb39a22..8faacee686336cfac9fcdf78fe90eec52c5c2bcc 100644 (file)
@@ -290,7 +290,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
 
 static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-       struct net_device_stats *stats = &dev->stats;
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
        struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);
 
        /* Handle non-VLAN frames if they are sent to us, for example by DHCP.
@@ -309,7 +309,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
                vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
                skb = __vlan_put_tag(skb, vlan_tci);
                if (!skb) {
-                       stats->tx_dropped++;
+                       txq->tx_dropped++;
                        return NETDEV_TX_OK;
                }
 
@@ -317,8 +317,8 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        vlan_dev_info(dev)->cnt_inc_headroom_on_tx++;
        }
 
-       stats->tx_packets++;
-       stats->tx_bytes += skb->len;
+       txq->tx_packets++;
+       txq->tx_bytes += skb->len;
 
        skb->dev = vlan_dev_info(dev)->real_dev;
        dev_queue_xmit(skb);
@@ -328,15 +328,15 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 static int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
                                            struct net_device *dev)
 {
-       struct net_device_stats *stats = &dev->stats;
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
        u16 vlan_tci;
 
        vlan_tci = vlan_dev_info(dev)->vlan_id;
        vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
        skb = __vlan_hwaccel_put_tag(skb, vlan_tci);
 
-       stats->tx_packets++;
-       stats->tx_bytes += skb->len;
+       txq->tx_packets++;
+       txq->tx_bytes += skb->len;
 
        skb->dev = vlan_dev_info(dev)->real_dev;
        dev_queue_xmit(skb);
index 3628e0a81b40f5e5cd3c4e1523923df2645287ca..b55a091a33dfb98fa0110c45df263772ce58c763 100644 (file)
@@ -279,13 +279,14 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
 {
        struct net_device *vlandev = (struct net_device *) seq->private;
        const struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
-       struct net_device_stats *stats = &vlandev->stats;
+       const struct net_device_stats *stats;
        static const char fmt[] = "%30s %12lu\n";
        int i;
 
        if (!is_vlan_dev(vlandev))
                return 0;
 
+       stats = dev_get_stats(vlandev);
        seq_printf(seq,
                   "%s  VID: %d  REORDER_HDR: %i  dev->priv_flags: %hx\n",
                   vlandev->name, dev_info->vlan_id,