[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231011092728.105904-21-xuanzhuo@linux.alibaba.com>
Date: Wed, 11 Oct 2023 17:27:26 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: virtualization@...ts.linux-foundation.org
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
netdev@...r.kernel.org,
bpf@...r.kernel.org
Subject: [PATCH vhost 20/22] virtio_net: xsk: rx: virtnet_rq_free_unused_buf() check xsk buffer
Since this will be called in other circumstances(freeze), we must check
whether it is xsk's buffer in this function. It cannot be judged outside
this function.
Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
---
drivers/net/virtio/main.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c
index 61be5a353ff3..60b5bd21fcc6 100644
--- a/drivers/net/virtio/main.c
+++ b/drivers/net/virtio/main.c
@@ -3910,8 +3910,21 @@ void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
void virtnet_rq_free_unused_buf(struct virtqueue *vq, void *buf)
{
struct virtnet_info *vi = vq->vdev->priv;
+ struct xsk_buff_pool *pool;
int i = vq2rxq(vq);
+ rcu_read_lock();
+ pool = rcu_dereference(vi->rq[i].xsk.pool);
+ if (pool) {
+ struct xdp_buff *xdp;
+
+ xdp = (struct xdp_buff *)buf;
+ xsk_buff_free(xdp);
+ rcu_read_unlock();
+ return;
+ }
+ rcu_read_unlock();
+
if (vi->mergeable_rx_bufs)
put_page(virt_to_head_page(buf));
else if (vi->big_packets)
--
2.32.0.3.g01195cf9f
Powered by blists - more mailing lists