Message ID | 49FAC112.6090808@cosmosbay.com |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
From: Eric Dumazet <dada1@cosmosbay.com> Date: Fri, 01 May 2009 11:29:54 +0200 > - } else if (skb->sk && skb->sk->sk_hash) { > + /* > + * Try to avoid an expensive divide, for symmetric setups : > + * number of tx queues of output device == > + * number of rx queues of incoming device > + */ > + if (hash >= dev->real_num_tx_queues) > + hash %= dev->real_num_tx_queues; > + return hash; > + } Subtraction in a while() loop is almost certainly a lot faster. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/core/dev.c b/net/core/dev.c index 308a7d0..b3acb51 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1737,9 +1737,19 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb) if (skb_rx_queue_recorded(skb)) { hash = skb_get_rx_queue(skb); - } else if (skb->sk && skb->sk->sk_hash) { + /* + * Try to avoid an expensive divide, for symmetric setups : + * number of tx queues of output device == + * number of rx queues of incoming device + */ + if (hash >= dev->real_num_tx_queues) + hash %= dev->real_num_tx_queues; + return hash; + } + + if (skb->sk && skb->sk->sk_hash) hash = skb->sk->sk_hash; - } else + else hash = skb->protocol; hash = jhash_1word(hash, skb_tx_hashrnd);