diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2014-08-23 14:58:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-08-23 15:21:21 -0400 |
commit | 8fc54f68919298ff9689d980efb495707ef43f30 (patch) | |
tree | c8a0c89621a9e670be02764a357bb6e73ed7ab6c /net/core | |
parent | 690e36e726d00d2528bc569809048adf61550d80 (diff) |
net: use reciprocal_scale() helper
Replace open codings of (((u64) <x> * <y>) >> 32) with reciprocal_scale().
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 3 | ||||
-rw-r--r-- | net/core/flow_dissector.c | 7 |
2 files changed, 4 insertions, 6 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index b65a5051361f..1421dad4cb29 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -3124,8 +3124,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, | |||
3124 | } | 3124 | } |
3125 | 3125 | ||
3126 | if (map) { | 3126 | if (map) { |
3127 | tcpu = map->cpus[((u64) hash * map->len) >> 32]; | 3127 | tcpu = map->cpus[reciprocal_scale(hash, map->len)]; |
3128 | |||
3129 | if (cpu_online(tcpu)) { | 3128 | if (cpu_online(tcpu)) { |
3130 | cpu = tcpu; | 3129 | cpu = tcpu; |
3131 | goto done; | 3130 | goto done; |
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 660c6492fb78..8ffcc97871c8 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c | |||
@@ -298,7 +298,7 @@ u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb, | |||
298 | qcount = dev->tc_to_txq[tc].count; | 298 | qcount = dev->tc_to_txq[tc].count; |
299 | } | 299 | } |
300 | 300 | ||
301 | return (u16) (((u64)skb_get_hash(skb) * qcount) >> 32) + qoffset; | 301 | return (u16) reciprocal_scale(skb_get_hash(skb), qcount) + qoffset; |
302 | } | 302 | } |
303 | EXPORT_SYMBOL(__skb_tx_hash); | 303 | EXPORT_SYMBOL(__skb_tx_hash); |
304 | 304 | ||
@@ -371,9 +371,8 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb) | |||
371 | if (map->len == 1) | 371 | if (map->len == 1) |
372 | queue_index = map->queues[0]; | 372 | queue_index = map->queues[0]; |
373 | else | 373 | else |
374 | queue_index = map->queues[ | 374 | queue_index = map->queues[reciprocal_scale(skb_get_hash(skb), |
375 | ((u64)skb_get_hash(skb) * map->len) >> 32]; | 375 | map->len)]; |
376 | |||
377 | if (unlikely(queue_index >= dev->real_num_tx_queues)) | 376 | if (unlikely(queue_index >= dev->real_num_tx_queues)) |
378 | queue_index = -1; | 377 | queue_index = -1; |
379 | } | 378 | } |