* [PATCH][net-next] virtio_net: skip RCU read lock by checking xdp_enabled of vi
@ 2021-10-09 9:32 Li RongQing
2021-10-10 10:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Li RongQing @ 2021-10-09 9:32 UTC (permalink / raw)
To: netdev, bpf, virtualization
networking benchmark shows that __rcu_read_lock and
__rcu_read_unlock takes some cpu cycles, and we can avoid
calling them partially in virtio rx path by check xdp_enabled
of vi, and xdp is disabled most of time
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/net/virtio_net.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 2ed49884565f..74d2be438180 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -734,6 +734,12 @@ static struct sk_buff *receive_small(struct net_device *dev,
dev->stats.rx_length_errors++;
goto err_len;
}
+
+ if (likely(!vi->xdp_enabled)) {
+ xdp_prog = NULL;
+ goto skip_xdp;
+ }
+
rcu_read_lock();
xdp_prog = rcu_dereference(rq->xdp_prog);
if (xdp_prog) {
@@ -816,6 +822,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
}
rcu_read_unlock();
+skip_xdp:
skb = build_skb(buf, buflen);
if (!skb) {
put_page(page);
@@ -897,6 +904,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
dev->stats.rx_length_errors++;
goto err_skb;
}
+
+ if (likely(!vi->xdp_enabled)) {
+ xdp_prog = NULL;
+ goto skip_xdp;
+ }
+
rcu_read_lock();
xdp_prog = rcu_dereference(rq->xdp_prog);
if (xdp_prog) {
@@ -1024,6 +1037,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
}
rcu_read_unlock();
+skip_xdp:
head_skb = page_to_skb(vi, rq, page, offset, len, truesize, !xdp_prog,
metasize, headroom);
curr_skb = head_skb;
--
2.33.0.69.gc420321.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][net-next] virtio_net: skip RCU read lock by checking xdp_enabled of vi
2021-10-09 9:32 [PATCH][net-next] virtio_net: skip RCU read lock by checking xdp_enabled of vi Li RongQing
@ 2021-10-10 10:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-10 10:40 UTC (permalink / raw)
To: Li RongQing; +Cc: netdev, bpf, virtualization
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 9 Oct 2021 17:32:43 +0800 you wrote:
> networking benchmark shows that __rcu_read_lock and
> __rcu_read_unlock takes some cpu cycles, and we can avoid
> calling them partially in virtio rx path by check xdp_enabled
> of vi, and xdp is disabled most of time
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
>
> [...]
Here is the summary with links:
- [net-next] virtio_net: skip RCU read lock by checking xdp_enabled of vi
https://git.kernel.org/netdev/net-next/c/6213f07cb542
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-10 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-09 9:32 [PATCH][net-next] virtio_net: skip RCU read lock by checking xdp_enabled of vi Li RongQing
2021-10-10 10:40 ` patchwork-bot+netdevbpf
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).