diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-09-03 19:12:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-09-08 16:10:53 -0400 |
commit | 6febfca98f25c7ee5c3ff7fc85e048bf82230ad5 (patch) | |
tree | f9eb98d11c62db1ba18a73d225526ac8975b87f8 | |
parent | 65040c33ee8d0199ab7686402bffdbf9e1e26cbe (diff) |
net: rps: add the shortcut for one rps_cpus
When there is only one rps_cpus, skb_get_rxhash() can be eliminated.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/dev.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index efd318db11ab..cdbbea39c549 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2343,7 +2343,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, | |||
2343 | struct rps_dev_flow **rflowp) | 2343 | struct rps_dev_flow **rflowp) |
2344 | { | 2344 | { |
2345 | struct netdev_rx_queue *rxqueue; | 2345 | struct netdev_rx_queue *rxqueue; |
2346 | struct rps_map *map; | 2346 | struct rps_map *map = NULL; |
2347 | struct rps_dev_flow_table *flow_table; | 2347 | struct rps_dev_flow_table *flow_table; |
2348 | struct rps_sock_flow_table *sock_flow_table; | 2348 | struct rps_sock_flow_table *sock_flow_table; |
2349 | int cpu = -1; | 2349 | int cpu = -1; |
@@ -2361,8 +2361,17 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, | |||
2361 | } else | 2361 | } else |
2362 | rxqueue = dev->_rx; | 2362 | rxqueue = dev->_rx; |
2363 | 2363 | ||
2364 | if (!rxqueue->rps_map && !rxqueue->rps_flow_table) | 2364 | if (rxqueue->rps_map) { |
2365 | map = rcu_dereference(rxqueue->rps_map); | ||
2366 | if (map && map->len == 1) { | ||
2367 | tcpu = map->cpus[0]; | ||
2368 | if (cpu_online(tcpu)) | ||
2369 | cpu = tcpu; | ||
2370 | goto done; | ||
2371 | } | ||
2372 | } else if (!rxqueue->rps_flow_table) { | ||
2365 | goto done; | 2373 | goto done; |
2374 | } | ||
2366 | 2375 | ||
2367 | skb_reset_network_header(skb); | 2376 | skb_reset_network_header(skb); |
2368 | if (!skb_get_rxhash(skb)) | 2377 | if (!skb_get_rxhash(skb)) |
@@ -2407,7 +2416,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, | |||
2407 | } | 2416 | } |
2408 | } | 2417 | } |
2409 | 2418 | ||
2410 | map = rcu_dereference(rxqueue->rps_map); | ||
2411 | if (map) { | 2419 | if (map) { |
2412 | tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32]; | 2420 | tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32]; |
2413 | 2421 | ||