Re: [PATCH net 4/4] virtio/vsock: Put vsock_connected_sockets_vsk() to use

2024-11-07 Thread Michal Luczaj
On 11/7/24 11:22, Stefano Garzarella wrote: > On Wed, Nov 06, 2024 at 06:51:21PM +0100, Michal Luczaj wrote: >> Macro vsock_connected_sockets_vsk() has been unused since its introduction. >> Instead of removing it, utilise it in vsock_insert_connected() where it's >> been open-coded. >> >> No funct

[PATCH net v2 0/3] virtio/vsock: Fix memory leaks

2024-11-07 Thread Michal Luczaj
Short series fixing some memory leaks that I've stumbled upon while toying with the selftests. Signed-off-by: Michal Luczaj --- Changes in v2: - Remove the refactoring patch from the series [Stefano] - PATCH 2: Drop "virtio" from the commit title [Stefano] - Collect Reviewed-by [Stefano] - Link t

Re: [PATCH net 2/4] virtio/vsock: Fix sk_error_queue memory leak

2024-11-07 Thread Michal Luczaj
6 +836,9 @@ static void vsock_sk_destruct(struct sock *sk) >> { >> struct vsock_sock *vsk = vsock_sk(sk); >> >> +/* Flush MSG_ZEROCOPY leftovers. */ >> +__skb_queue_purge(&sk->sk_error_queue); >> + > > It is true that for now this is su

[PATCH net v2 1/3] virtio/vsock: Fix accept_queue memory leak

2024-11-07 Thread Michal Luczaj
As the final stages of socket destruction may be delayed, it is possible that virtio_transport_recv_listen() will be called after the accept_queue has been flushed, but before the SOCK_DONE flag has been set. As a result, sockets enqueued after the flush would remain unremoved, leading to a memory

[PATCH net v2 3/3] virtio/vsock: Improve MSG_ZEROCOPY error handling

2024-11-07 Thread Michal Luczaj
Add a missing kfree_skb() to prevent memory leaks. Fixes: 581512a6dc93 ("vsock/virtio: MSG_ZEROCOPY flag support") Reviewed-by: Stefano Garzarella Signed-off-by: Michal Luczaj --- net/vmw_vsock/virtio_transport_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vmw_vsock/virtio_tr

[PATCH net v2 2/3] vsock: Fix sk_error_queue memory leak

2024-11-07 Thread Michal Luczaj
Kernel queues MSG_ZEROCOPY completion notifications on the error queue. Where they remain, until explicitly recv()ed. To prevent memory leaks, clean up the queue when the socket is destroyed. unreferenced object 0x8881028beb00 (size 224): comm "vsock_test", pid 1218, jiffies 4294694897 hex

Re: [PATCH net 4/4] virtio/vsock: Put vsock_connected_sockets_vsk() to use

2024-11-07 Thread Stefano Garzarella
On Wed, Nov 06, 2024 at 06:51:21PM +0100, Michal Luczaj wrote: Macro vsock_connected_sockets_vsk() has been unused since its introduction. Instead of removing it, utilise it in vsock_insert_connected() where it's been open-coded. No functional change intended. Fixes: d021c344051a ("VSOCK: Intro

Re: [PATCH net 3/4] virtio/vsock: Improve MSG_ZEROCOPY error handling

2024-11-07 Thread Stefano Garzarella
On Wed, Nov 06, 2024 at 06:51:20PM +0100, Michal Luczaj wrote: Add a missing kfree_skb() to prevent memory leaks. Fixes: 581512a6dc93 ("vsock/virtio: MSG_ZEROCOPY flag support") Signed-off-by: Michal Luczaj --- net/vmw_vsock/virtio_transport_common.c | 1 + 1 file changed, 1 insertion(+) Revie

Re: [PATCH net 2/4] virtio/vsock: Fix sk_error_queue memory leak

2024-11-07 Thread Stefano Garzarella
On Wed, Nov 06, 2024 at 06:51:19PM +0100, Michal Luczaj wrote: Kernel queues MSG_ZEROCOPY completion notifications on the error queue. Where they remain, until explicitly recv()ed. To prevent memory leaks, clean up the queue when the socket is destroyed. unreferenced object 0x8881028beb00 (s

Re: [PATCH net 1/4] virtio/vsock: Fix accept_queue memory leak

2024-11-07 Thread Stefano Garzarella
On Wed, Nov 06, 2024 at 06:51:18PM +0100, Michal Luczaj wrote: As the final stages of socket destruction may be delayed, it is possible that virtio_transport_recv_listen() will be called after the accept_queue has been flushed, but before the SOCK_DONE flag has been set. As a result, sockets enqu

[PATCH net-next v3 04/13] virtio_ring: perform premapped operations based on per-buffer

2024-11-07 Thread Xuan Zhuo
The current configuration sets the virtqueue (vq) to premapped mode, implying that all buffers submitted to this queue must be mapped ahead of time. This presents a challenge for the virtnet send queue (sq): the virtnet driver would be required to keep track of dma information for vq size * 17, whi

[PATCH net-next v3 07/13] virtio_ring: remove API virtqueue_set_dma_premapped

2024-11-07 Thread Xuan Zhuo
Now, this API is useless. remove it. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 13 -- drivers/virtio/virtio_ring.c | 48 include/linux/virtio.h | 2 -- 3 files changed, 63 deletions(-) diff --git a/drive

[PATCH net-next v3 03/13] virtio_ring: packed: record extras for indirect buffers

2024-11-07 Thread Xuan Zhuo
The subsequent commit needs to know whether every indirect buffer is premapped or not. So we need to introduce an extra struct for every indirect buffer to record this info. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 60 +--- 1 file changed, 36 in

[PATCH net-next v3 00/13] virtio-net: support AF_XDP zero copy (tx)

2024-11-07 Thread Xuan Zhuo
v3: 1. use sg_dma_address/length api to set the premapped sg 2. remove 'premapped' parameter from the new APIs 3. tweak the comment of commit #2,#3 v2: 1. use new api to submit premapped buffer instead of using sgs to pass this info 2. some small fixes for http://lore.kernel.

[PATCH net-next v3 13/13] virtio_net: xdp_features add NETDEV_XDP_ACT_XSK_ZEROCOPY

2024-11-07 Thread Xuan Zhuo
Now, we support AF_XDP(xsk). Add NETDEV_XDP_ACT_XSK_ZEROCOPY to xdp_features. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7cd6f1d74710..

[PATCH net-next v3 12/13] virtio_net: update tx timeout record

2024-11-07 Thread Xuan Zhuo
If send queue sent some packets, we update the tx timeout record to prevent the tx timeout. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 67d33cc913c

[PATCH net-next v3 11/13] virtio_net: xsk: tx: support xmit xsk buffer

2024-11-07 Thread Xuan Zhuo
The driver's tx napi is very important for XSK. It is responsible for obtaining data from the XSK queue and sending it out. At the beginning, we need to trigger tx napi. virtnet_free_old_xmit distinguishes three type ptr(skb, xdp frame, xsk buffer) by the last bits of the pointer. Signed-off-by:

[PATCH net-next v3 10/13] virtio_net: xsk: prevent disable tx napi

2024-11-07 Thread Xuan Zhuo
Since xsk's TX queue is consumed by TX NAPI, if sq is bound to xsk, then we must stop tx napi from being disabled. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/

[PATCH net-next v3 09/13] virtio_net: xsk: bind/unbind xsk for tx

2024-11-07 Thread Xuan Zhuo
This patch implement the logic of bind/unbind xsk pool to sq and rq. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 53 1 file changed, 53 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index

[PATCH net-next v3 06/13] virtio-net: rq submits premapped per-buffer

2024-11-07 Thread Xuan Zhuo
virtio-net rq submits premapped per-buffer by setting sg page to NULL; Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 4b27ded8fc16..862bea

[PATCH net-next v3 08/13] virtio_net: refactor the xmit type

2024-11-07 Thread Xuan Zhuo
Because the af-xdp will introduce a new xmit type, so I refactor the xmit type mechanism first. We know both xdp_frame and sk_buff are at least 4 bytes aligned. For the xdp tx, we do not pass any pointer to virtio core as data, we just need to pass the len of the packet. So we will push len to the

[PATCH net-next v3 05/13] virtio_ring: introduce add api for premapped

2024-11-07 Thread Xuan Zhuo
Two APIs are introduced to submit premapped per-buffers. int virtqueue_add_inbuf_premapped(struct virtqueue *vq, struct scatterlist *sg, unsigned int num, void *data, void *ctx,

[PATCH net-next v3 01/13] virtio_ring: introduce vring_need_unmap_buffer

2024-11-07 Thread Xuan Zhuo
To make the code readable, introduce vring_need_unmap_buffer() to replace do_unmap. use_dma_api premapped -> vring_need_unmap_buffer() 1. false falsefalse 2. truefalsetrue 3. truetrue false Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drive

[PATCH net-next v3 02/13] virtio_ring: split: record extras for indirect buffers

2024-11-07 Thread Xuan Zhuo
The subsequent commit needs to know whether every indirect buffer is premapped or not. So we need to introduce an extra struct for every indirect buffer to record this info. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 112 --- 1 file changed, 52 in