Commit 6febfca9 authored by Changli Gao's avatar Changli Gao Committed by David S. Miller

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: default avatarChangli Gao <xiaosuo@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 65040c33
...@@ -2343,7 +2343,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, ...@@ -2343,7 +2343,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
struct rps_dev_flow **rflowp) struct rps_dev_flow **rflowp)
{ {
struct netdev_rx_queue *rxqueue; struct netdev_rx_queue *rxqueue;
struct rps_map *map; struct rps_map *map = NULL;
struct rps_dev_flow_table *flow_table; struct rps_dev_flow_table *flow_table;
struct rps_sock_flow_table *sock_flow_table; struct rps_sock_flow_table *sock_flow_table;
int cpu = -1; int cpu = -1;
...@@ -2361,8 +2361,17 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, ...@@ -2361,8 +2361,17 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
} else } else
rxqueue = dev->_rx; rxqueue = dev->_rx;
if (!rxqueue->rps_map && !rxqueue->rps_flow_table) if (rxqueue->rps_map) {
map = rcu_dereference(rxqueue->rps_map);
if (map && map->len == 1) {
tcpu = map->cpus[0];
if (cpu_online(tcpu))
cpu = tcpu;
goto done;
}
} else if (!rxqueue->rps_flow_table) {
goto done; goto done;
}
skb_reset_network_header(skb); skb_reset_network_header(skb);
if (!skb_get_rxhash(skb)) if (!skb_get_rxhash(skb))
...@@ -2407,7 +2416,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, ...@@ -2407,7 +2416,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
} }
} }
map = rcu_dereference(rxqueue->rps_map);
if (map) { if (map) {
tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32]; tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment