netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tun: compute the RFS hash only if needed.
@ 2018-11-07  9:34 Paolo Abeni
  2018-11-07 13:33 ` Jason Wang
  2018-11-08  6:23 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2018-11-07  9:34 UTC (permalink / raw)
  To: netdev; +Cc: Jason Wang, David S. Miller

The tun XDP sendmsg code path, unconditionally computes the symmetric
hash of each packet for RFS's sake, even when we could skip it. e.g.
when the device has a single queue.

This change adds the check already in-place for the skb sendmsg path
to avoid unneeded hashing.

The above gives small, but measurable, performance gain for VM xmit
path when zerocopy is not enabled.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/tun.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 060135ceaf0e..a65779c6d72f 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2448,7 +2448,8 @@ static int tun_xdp_one(struct tun_struct *tun,
 			goto out;
 	}
 
-	if (!rcu_dereference(tun->steering_prog))
+	if (!rcu_dereference(tun->steering_prog) && tun->numqueues > 1 &&
+	    !tfile->detached)
 		rxhash = __skb_get_hash_symmetric(skb);
 
 	netif_receive_skb(skb);
-- 
2.17.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tun: compute the RFS hash only if needed.
  2018-11-07  9:34 [PATCH net-next] tun: compute the RFS hash only if needed Paolo Abeni
@ 2018-11-07 13:33 ` Jason Wang
  2018-11-08  6:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Wang @ 2018-11-07 13:33 UTC (permalink / raw)
  To: Paolo Abeni, netdev; +Cc: David S. Miller


On 2018/11/7 下午5:34, Paolo Abeni wrote:
> The tun XDP sendmsg code path, unconditionally computes the symmetric
> hash of each packet for RFS's sake, even when we could skip it. e.g.
> when the device has a single queue.
>
> This change adds the check already in-place for the skb sendmsg path
> to avoid unneeded hashing.
>
> The above gives small, but measurable, performance gain for VM xmit
> path when zerocopy is not enabled.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
>   drivers/net/tun.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 060135ceaf0e..a65779c6d72f 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -2448,7 +2448,8 @@ static int tun_xdp_one(struct tun_struct *tun,
>   			goto out;
>   	}
>   
> -	if (!rcu_dereference(tun->steering_prog))
> +	if (!rcu_dereference(tun->steering_prog) && tun->numqueues > 1 &&
> +	    !tfile->detached)
>   		rxhash = __skb_get_hash_symmetric(skb);
>   
>   	netif_receive_skb(skb);


Acked-by: Jason Wang <jasowang@redhat.com>

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tun: compute the RFS hash only if needed.
  2018-11-07  9:34 [PATCH net-next] tun: compute the RFS hash only if needed Paolo Abeni
  2018-11-07 13:33 ` Jason Wang
@ 2018-11-08  6:23 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-11-08  6:23 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, jasowang

From: Paolo Abeni <pabeni@redhat.com>
Date: Wed,  7 Nov 2018 10:34:36 +0100

> The tun XDP sendmsg code path, unconditionally computes the symmetric
> hash of each packet for RFS's sake, even when we could skip it. e.g.
> when the device has a single queue.
> 
> This change adds the check already in-place for the skb sendmsg path
> to avoid unneeded hashing.
> 
> The above gives small, but measurable, performance gain for VM xmit
> path when zerocopy is not enabled.
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-08 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07  9:34 [PATCH net-next] tun: compute the RFS hash only if needed Paolo Abeni
2018-11-07 13:33 ` Jason Wang
2018-11-08  6:23 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).