Skip to content

Commit 6febfca

Browse files
xiaosuodavem330
authored andcommitted
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>
1 parent 65040c3 commit 6febfca

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎net/core/dev.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
23432343
struct rps_dev_flow **rflowp)
23442344
{
23452345
struct netdev_rx_queue *rxqueue;
2346-
struct rps_map *map;
2346+
struct rps_map *map = NULL;
23472347
struct rps_dev_flow_table *flow_table;
23482348
struct rps_sock_flow_table *sock_flow_table;
23492349
int cpu = -1;
@@ -2361,8 +2361,17 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
23612361
} else
23622362
rxqueue = dev->_rx;
23632363

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) {
23652373
goto done;
2374+
}
23662375

23672376
skb_reset_network_header(skb);
23682377
if (!skb_get_rxhash(skb))
@@ -2407,7 +2416,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
24072416
}
24082417
}
24092418

2410-
map = rcu_dereference(rxqueue->rps_map);
24112419
if (map) {
24122420
tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
24132421

0 commit comments

Comments
 (0)