Commit 3df97ba8 authored by Jason Wang's avatar Jason Wang Committed by David S. Miller

tuntap: calculate rps hash only when needed

There's no need to calculate rps hash if it was not enabled. So this
patch export rps_needed and check it before trying to get rps
hash. Tests (using pktgen to inject packets to guest) shows this can
improve pps about 13% (when rps is disabled).

Before:
~1150000 pps
After:
~1300000 pps

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
----
Changes from V1:
- Fix build when CONFIG_RPS is not set
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f345c9a5
...@@ -833,7 +833,8 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -833,7 +833,8 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
if (txq >= numqueues) if (txq >= numqueues)
goto drop; goto drop;
if (numqueues == 1) { #ifdef CONFIG_RPS
if (numqueues == 1 && static_key_false(&rps_needed)) {
/* Select queue was not called for the skbuff, so we extract the /* Select queue was not called for the skbuff, so we extract the
* RPS hash and save it into the flow_table here. * RPS hash and save it into the flow_table here.
*/ */
...@@ -848,6 +849,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -848,6 +849,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
tun_flow_save_rps_rxhash(e, rxhash); tun_flow_save_rps_rxhash(e, rxhash);
} }
} }
#endif
tun_debug(KERN_INFO, tun, "tun_net_xmit %d\n", skb->len); tun_debug(KERN_INFO, tun, "tun_net_xmit %d\n", skb->len);
......
...@@ -3469,6 +3469,7 @@ u32 rps_cpu_mask __read_mostly; ...@@ -3469,6 +3469,7 @@ u32 rps_cpu_mask __read_mostly;
EXPORT_SYMBOL(rps_cpu_mask); EXPORT_SYMBOL(rps_cpu_mask);
struct static_key rps_needed __read_mostly; struct static_key rps_needed __read_mostly;
EXPORT_SYMBOL(rps_needed);
static struct rps_dev_flow * static struct rps_dev_flow *
set_rps_cpu(struct net_device *dev, struct sk_buff *skb, set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
......
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