Trivial loopback optimization for 2.6.7
PATCH 1/1 Trivial loopback optimization for 2.6.7
This patch is for the network loopback driver:
1: Removes unnecessary include with misleading comment.
2: Optimizes device stats update in the transmit routine (saves 2 loads, one add, one increment per packet sent.)
Why is there no stats counting in the TSO code inemulate_large_send_offload()?
Signed-off-by Chuck Ebbert <[email protected]>
drivers/net/loopback.c 2004-06-21 16:16:20.000000000 -0400 renamed from drivers/net/loopback.c 2004-06-21 16:09:45.000000000 -0400 +8 -5
@@ -51,7 +51,6 @@ #include <linux/skbuff.h> #include <net/sock.h> #include <net/checksum.h> -#include <linux/if_ether.h> /* For the statistics structure. */ #include <linux/if_arp.h> /* For ARPHRD_ETHER */ #include <linux/ip.h> #include <linux/tcp.h>
@@ -143,10 +142,14 @@ static int loopback_xmit(struct sk_buff dev->last_rx = jiffies; if (likely(stats)) { - stats->rx_bytes+=skb->len; - stats->tx_bytes+=skb->len; - stats->rx_packets++; - stats->tx_packets++; + /* + * Transmit/receive stats are identical; + * rx_packets is first in struct. + */ + stats->tx_packets = ++stats->rx_packets; + + stats->rx_bytes += skb->len; + stats->tx_bytes = stats->rx_bytes; } netif_rx(skb);