aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-05 03:11:22 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-05 03:21:57 -0400
commit0bfbedb14a8a96c529341bec88991a92b41fac72 (patch)
treed52ccb4758fd58cbf74c7a9001e6885275d3ddc8
parent16c6cf8bb471392fd09b48b7c27e7d83a446b4bc (diff)
tunnels: Optimize tx path
We currently dirty a cache line to update tunnel device stats (tx_packets/tx_bytes). We better use the txq->tx_bytes/tx_packets counters that already are present in cpu cache, in the cache line shared with txq->_xmit_lock This patch extends IPTUNNEL_XMIT() macro to use txq pointer provided by the caller. Also &tunnel->dev->stats can be replaced by &dev->stats Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ipip.h6
-rw-r--r--net/ipv4/ip_gre.c5
-rw-r--r--net/ipv4/ipip.c5
-rw-r--r--net/ipv6/sit.c5
4 files changed, 12 insertions, 9 deletions
diff --git a/include/net/ipip.h b/include/net/ipip.h
index 87acf8f3a155..0159221a8509 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -42,9 +42,9 @@ struct ip_tunnel_prl_entry
42 ip_select_ident(iph, &rt->u.dst, NULL); \ 42 ip_select_ident(iph, &rt->u.dst, NULL); \
43 \ 43 \
44 err = ip_local_out(skb); \ 44 err = ip_local_out(skb); \
45 if (net_xmit_eval(err) == 0) { \ 45 if (likely(net_xmit_eval(err) == 0)) { \
46 stats->tx_bytes += pkt_len; \ 46 txq->tx_bytes += pkt_len; \
47 stats->tx_packets++; \ 47 txq->tx_packets++; \
48 } else { \ 48 } else { \
49 stats->tx_errors++; \ 49 stats->tx_errors++; \
50 stats->tx_aborted_errors++; \ 50 stats->tx_aborted_errors++; \
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 41ada9904d31..89ff9d5b1500 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -662,7 +662,8 @@ drop_nolock:
662static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 662static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
663{ 663{
664 struct ip_tunnel *tunnel = netdev_priv(dev); 664 struct ip_tunnel *tunnel = netdev_priv(dev);
665 struct net_device_stats *stats = &tunnel->dev->stats; 665 struct net_device_stats *stats = &dev->stats;
666 struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
666 struct iphdr *old_iph = ip_hdr(skb); 667 struct iphdr *old_iph = ip_hdr(skb);
667 struct iphdr *tiph; 668 struct iphdr *tiph;
668 u8 tos; 669 u8 tos;
@@ -810,7 +811,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
810 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); 811 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
811 if (!new_skb) { 812 if (!new_skb) {
812 ip_rt_put(rt); 813 ip_rt_put(rt);
813 stats->tx_dropped++; 814 txq->tx_dropped++;
814 dev_kfree_skb(skb); 815 dev_kfree_skb(skb);
815 return NETDEV_TX_OK; 816 return NETDEV_TX_OK;
816 } 817 }
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 08ccd344de7a..6a5539236ab3 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -390,7 +390,8 @@ static int ipip_rcv(struct sk_buff *skb)
390static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 390static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
391{ 391{
392 struct ip_tunnel *tunnel = netdev_priv(dev); 392 struct ip_tunnel *tunnel = netdev_priv(dev);
393 struct net_device_stats *stats = &tunnel->dev->stats; 393 struct net_device_stats *stats = &dev->stats;
394 struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
394 struct iphdr *tiph = &tunnel->parms.iph; 395 struct iphdr *tiph = &tunnel->parms.iph;
395 u8 tos = tunnel->parms.iph.tos; 396 u8 tos = tunnel->parms.iph.tos;
396 __be16 df = tiph->frag_off; 397 __be16 df = tiph->frag_off;
@@ -478,7 +479,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
478 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); 479 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
479 if (!new_skb) { 480 if (!new_skb) {
480 ip_rt_put(rt); 481 ip_rt_put(rt);
481 stats->tx_dropped++; 482 txq->tx_dropped++;
482 dev_kfree_skb(skb); 483 dev_kfree_skb(skb);
483 return NETDEV_TX_OK; 484 return NETDEV_TX_OK;
484 } 485 }
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index dbd19a78ca73..99da272951dc 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -555,7 +555,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
555 struct net_device *dev) 555 struct net_device *dev)
556{ 556{
557 struct ip_tunnel *tunnel = netdev_priv(dev); 557 struct ip_tunnel *tunnel = netdev_priv(dev);
558 struct net_device_stats *stats = &tunnel->dev->stats; 558 struct net_device_stats *stats = &dev->stats;
559 struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
559 struct iphdr *tiph = &tunnel->parms.iph; 560 struct iphdr *tiph = &tunnel->parms.iph;
560 struct ipv6hdr *iph6 = ipv6_hdr(skb); 561 struct ipv6hdr *iph6 = ipv6_hdr(skb);
561 u8 tos = tunnel->parms.iph.tos; 562 u8 tos = tunnel->parms.iph.tos;
@@ -688,7 +689,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
688 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); 689 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
689 if (!new_skb) { 690 if (!new_skb) {
690 ip_rt_put(rt); 691 ip_rt_put(rt);
691 stats->tx_dropped++; 692 txq->tx_dropped++;
692 dev_kfree_skb(skb); 693 dev_kfree_skb(skb);
693 return NETDEV_TX_OK; 694 return NETDEV_TX_OK;
694 } 695 }