aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-05-03 17:43:10 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-03 17:43:10 -0400
commit513de11bba246b7a67df4c314d9fc936b6a75d0e (patch)
tree773f446b9a609e771ff75ebd9bfacd4d3d52f99f
parentaccc5b4f902b0ba83b2c6c48f2d9e7c204cef4a8 (diff)
net: Avoid modulus in skb_tx_hash() for forwarding case.
Based almost entirely upon a patch by Eric Dumazet. The common case is to have num-tx-queues <= num_rx_queues and even if num_tx_queues is larger it will not be significantly larger. Therefore, a subtraction loop is always going to be faster than modulus. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/dev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 81442957c5c2..3c8073fe970a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1735,8 +1735,12 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb)
1735{ 1735{
1736 u32 hash; 1736 u32 hash;
1737 1737
1738 if (skb_rx_queue_recorded(skb)) 1738 if (skb_rx_queue_recorded(skb)) {
1739 return skb_get_rx_queue(skb) % dev->real_num_tx_queues; 1739 hash = skb_get_rx_queue(skb);
1740 while (unlikely (hash >= dev->real_num_tx_queues))
1741 hash -= dev->real_num_tx_queues;
1742 return hash;
1743 }
1740 1744
1741 if (skb->sk && skb->sk->sk_hash) 1745 if (skb->sk && skb->sk->sk_hash)
1742 hash = skb->sk->sk_hash; 1746 hash = skb->sk->sk_hash;