Re: [PATCH PATCH net-next v2 2/2] vsock/virtio: avoid enqueue packets when work queue is empty

2024-07-01 Thread Luigi Leonardi
Hi all, > + /* Inside RCU, can't sleep! */ > + ret = mutex_trylock(&vsock->tx_lock); > + if (unlikely(ret == 0)) > + goto out_worker; I just realized that here I don't release the tx_lock and that the email subject is "PATCH PATCH". I will

Re: [PATCH net-next v3 2/2] vsock/virtio: avoid queuing packets when work queue is empty

2024-07-15 Thread Luigi Leonardi
Hi Stefano, Thanks for your review! > On Thu, Jul 11, 2024 at 04:58:47PM GMT, Luigi Leonardi via B4 Relay wrote: > >From: Luigi Leonardi > > > >Introduce an optimization in virtio_transport_send_pkt: > >when the work queue (send_pkt_queue) is empty the packet is >

Re: [PATCH net-next v4 0/2] vsock: avoid queuing on intermediate queue if possible

2024-08-29 Thread Luigi Leonardi
Hi All, It has been a while since the last email and this patch has not been merged yet. This is just a gentle ping :) Thanks, Luigi >Hi Michael, >this series is marked as "Not Applicable" for the net-next tree: >https://patchwork.kernel.org/project/netdevbpf/patch/20240730-pinna-v4-2-5c9179164.

Re: [PATCH] vsock/virtio: use GFP_ATOMIC under RCU read lock

2024-10-02 Thread Luigi Leonardi
> Link: > https://lore.kernel.org/all/hfcr2aget2zojmqpr4uhlzvnep4vgskblx5b6xf2ddosbsrke7@nt34bxgp7j2x > Fixes: efcd71af38be ("vsock/virtio: avoid queuing packets when intermediate > queue is empty") > Reported-by: Christian Brauner > Cc: Stefano Garzarella > Cc:

Re: [PATCH net v2 5/5] vsock: prevent null-ptr-deref in vsock_*[has_data|has_space]

2025-01-10 Thread Luigi Leonardi
turn 0; + return vsk->transport->stream_has_space(vsk); } EXPORT_SYMBOL_GPL(vsock_stream_has_space); -- 2.47.1 Reviewed-by: Luigi Leonardi Thanks! Luigi

Re: [PATCH net 1/2] vsock/virtio: discard packets if the transport changes

2025-01-21 Thread Luigi Leonardi
On Thu, Jan 09, 2025 at 02:34:28PM +0100, Michal Luczaj wrote: FWIW, I've tried simplifying Hyunwoo's repro to toy with some tests. Ended up with ``` from threading import * from socket import * from signal import * def listener(tid): while True: s = socket(AF_VSOCK, SO

Re: [PATCH net v2 3/5] vsock/virtio: cancel close work in the destructor

2025-01-10 Thread Luigi Leonardi
sk->sk_state = TCP_CLOSING; + sk->sk_state_change(sk); + + virtio_transport_cancel_close_work(vsk, cancel_timeout); +} + static void virtio_transport_close_timeout(struct work_struct *work) { struct vsock_sock *vsk = -- 2.47.1 Thanks! Reviewed-by: Luigi Leonardi

Re: [PATCH net v2 4/5] vsock: reset socket state when de-assigning the transport

2025-01-10 Thread Luigi Leonardi
nt the transport unloading -- 2.47.1 Hi Stefano, I spent some time investigating what would happen if the scheduled work ran before `virtio_transport_cancel_close_work`. IIUC that should do no harm and all the fields are reset correctly. Thank you, Luigi Reviewed-by: Luigi Leonardi

Re: [PATCH net 2/2] vsock/bpf: return early if transport is not assigned

2025-01-09 Thread Luigi Leonardi
release_sock(sk); sk_psock_put(sk, psock); -- 2.47.1 LGTM! Reviewed-By: Luigi Leonardi

Re: [Patch net v3] vsock/virtio: fix variables initialization during resuming

2025-02-14 Thread Luigi Leonardi
mutex_init(&vsock->tx_lock); mutex_init(&vsock->rx_lock); -- 2.34.1 Reviewed-by: Luigi Leonardi

[PATCH net-next 2/2] vsock/test: Add test for null ptr deref when transport changes

2025-03-06 Thread Luigi Leonardi
within the timeout period. If there is a G2H transport loaded in the system, the bug is not triggered and this test will always pass. [1]https://lore.kernel.org/netdev/Z2LvdTTQR7dBmPb5@v4bel-B760M-AORUS-ELITE-AX/ Suggested-by: Michal Luczaj Signed-off-by: Luigi Leonardi --- tools/testing

[PATCH net-next 0/2] vsock/test: check for null-ptr-deref when transport changes

2025-03-06 Thread Luigi Leonardi
Michal's python reproducer[3]. [1]https://lore.kernel.org/netdev/Z2LvdTTQR7dBmPb5@v4bel-B760M-AORUS-ELITE-AX/ [2]https://lore.kernel.org/netdev/20250110083511.30419-1-sgarz...@redhat.com/ [3]https://lore.kernel.org/netdev/2b3062e3-bdaa-4c94-a3c0-2930595b9...@rbox.co/ Signed-off-by: Luigi Leo

[PATCH net-next 1/2] vsock/test: Add new function to check for timeout

2025-03-06 Thread Luigi Leonardi
Add `timeout_check_expired` function that returns true if the timeout counter has expired. This is useful in situations where a timeout does not necessarily mean a failure. Signed-off-by: Luigi Leonardi --- tools/testing/vsock/timeout.c | 7 ++- tools/testing/vsock/timeout.h | 3 +++ 2

[PATCH net-next v2] vsock/test: Add test for null ptr deref when transport changes

2025-03-14 Thread Luigi Leonardi
.run_client = test_stream_transport_change_client, + .run_server = test_stream_transport_change_server, + }, {}, }; --- base-commit: 4d872d51bc9d7b899c1f61534e3dbde72613f627 change-id: 20250306-test_vsock-3e77a9c7a245 Best regards, -- Luigi Leonardi

Re: [PATCH net-next v2] vsock/test: Add test for null ptr deref when transport changes

2025-03-26 Thread Luigi Leonardi
Hi Michal, On Wed, Mar 19, 2025 at 01:27:35AM +0100, Michal Luczaj wrote: On 3/14/25 10:27, Luigi Leonardi wrote: Add a new test to ensure that when the transport changes a null pointer dereference does not occur[1]. Note that this test does not fail, but it may hang on the client side if it

[PATCH net-next v3 0/3] ioctl support for AF_VSOCK and virtio-based transports

2024-06-26 Thread Luigi Leonardi via B4 Relay
27;s suggestions: - vsock_do_ioctl has been rewritten - ioctl(SIOCOUTQ) test is skipped when it is not supported - Minor variable/function name changes - rebased to latest net-next Signed-off-by: Luigi Leonardi --- Luigi Leonardi (3): vsock: add support for SIOCOUTQ ioctl for

[PATCH net-next v3 1/3] vsock: add support for SIOCOUTQ ioctl for all vsock socket types.

2024-06-26 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Add support for ioctl(s) for SOCK_STREAM SOCK_SEQPACKET and SOCK_DGRAM in AF_VSOCK. The only ioctl available is SIOCOUTQ/TIOCOUTQ, which returns the number of unsent bytes in the socket. This information is transport-specific and is delegated to them using a callback

[PATCH net-next v3 2/3] vsock/virtio: add SIOCOUTQ support for all virtio based transports

2024-06-26 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Introduce support for stream_bytes_unsent and seqpacket_bytes_unsent ioctl for virtio_transport, vhost_vsock and vsock_loopback. For all transports the unsent bytes counter is incremented in virtio_transport_get_credit. In the virtio_transport (G2H) the counter is

[PATCH net-next v3 3/3] test/vsock: add ioctl unsent bytes test

2024-06-26 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Introduce two tests, one for SOCK_STREAM and one for SOCK_SEQPACKET, which checks after a packet is delivered, that the number of unsent bytes is zero, using ioctl SIOCOUTQ. Signed-off-by: Luigi Leonardi --- tools/testing/vsock/util.c | 6 +-- tools/testing/vsock

[PATCH PATCH net-next v2 1/2] vsock/virtio: refactor virtio_transport_send_pkt_work

2024-07-01 Thread Luigi Leonardi via B4 Relay
From: Marco Pinna Preliminary patch to introduce an optimization to the enqueue system. All the code used to enqueue a packet into the virtqueue is removed from virtio_transport_send_pkt_work() and moved to the new virtio_transport_send_skb() function. Co-developed-by: Luigi Leonardi Signed

[PATCH PATCH net-next v2 2/2] vsock/virtio: avoid enqueue packets when work queue is empty

2024-07-01 Thread Luigi Leonardi via B4 Relay
Before (Linux 6.8.11) G2H 28.7 Gb/s After G2H 40.8 Gb/s The performance improvement is related to this optimization, I checked that each packet was put directly on the vq avoiding the work queue. Co-developed-by: Luigi Leonardi Signed-off-by: Luigi Leonardi Signed-off-by: Marco Pinna --- net

[PATCH net-next v2 0/2] vsock: avoid queuing on workqueue if possible

2024-07-01 Thread Luigi Leonardi via B4 Relay
ext Signed-off-by: Luigi Leonardi --- Marco Pinna (2): vsock/virtio: refactor virtio_transport_send_pkt_work vsock/virtio: avoid enqueue packets when work queue is empty net/vmw_vsock/virtio_transport.c | 171 +-- 1 file changed, 109 insertion

[PATCH net-next v3 0/2] vsock: avoid queuing on workqueue if possible

2024-07-11 Thread Luigi Leonardi via B4 Relay
o: Paolo Abeni Cc: k...@vger.kernel.org Cc: virtualizat...@lists.linux.dev Cc: net...@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luigi Leonardi --- Luigi Leonardi (1): vsock/virtio: avoid queuing packets when work queue is empty Marco Pinna (1): v

[PATCH net-next v3 2/2] vsock/virtio: avoid queuing packets when work queue is empty

2024-07-11 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Introduce an optimization in virtio_transport_send_pkt: when the work queue (send_pkt_queue) is empty the packet is put directly in the virtqueue increasing the throughput. In the following benchmark (pingpong mode) the host sends a payload to the guest and waits for the

[PATCH net-next v3 1/2] vsock/virtio: refactor virtio_transport_send_pkt_work

2024-07-11 Thread Luigi Leonardi via B4 Relay
From: Marco Pinna Preliminary patch to introduce an optimization to the enqueue system. All the code used to enqueue a packet into the virtqueue is removed from virtio_transport_send_pkt_work() and moved to the new virtio_transport_send_skb() function. Co-developed-by: Luigi Leonardi Signed

[PATCH net-next v4 0/3] ioctl support for AF_VSOCK and virtio-based transports

2024-07-30 Thread Luigi Leonardi via B4 Relay
ano's suggestions: - vsock_do_ioctl has been rewritten - ioctl(SIOCOUTQ) test is skipped when it is not supported - Minor variable/function name changes - rebased to latest net-next Signed-off-by: Luigi Leonardi --- Luigi Leonardi (3): vsock: add support for SIOCOUTQ ioctl vsoc

[PATCH net-next v4 2/3] vsock/virtio: add SIOCOUTQ support for all virtio based transports

2024-07-30 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Introduce support for virtio_transport_unsent_bytes ioctl for virtio_transport, vhost_vsock and vsock_loopback. For all transports the unsent bytes counter is incremented in virtio_transport_get_credit. In virtio_transport (G2H) and in vhost-vsock (H2G) the counter is

[PATCH net-next v4 3/3] test/vsock: add ioctl unsent bytes test

2024-07-30 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Introduce two tests, one for SOCK_STREAM and one for SOCK_SEQPACKET, which use SIOCOUTQ ioctl to check that the number of unsent bytes is zero after delivering a packet. vsock_connect and vsock_accept are no longer static: this is to create more generic tests, allowing code

[PATCH net-next v4 1/3] vsock: add support for SIOCOUTQ ioctl

2024-07-30 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi Add support for ioctl(s) in AF_VSOCK. The only ioctl available is SIOCOUTQ/TIOCOUTQ, which returns the number of unsent bytes in the socket. This information is transport-specific and is delegated to them using a callback. Suggested-by: Daan De Meyer Signed-off-by: Luigi

[PATCH net-next v4 0/2] vsock: avoid queuing on intermediate queue if possible

2024-07-30 Thread Luigi Leonardi via B4 Relay
all the packets go directly to the vq (Matias' suggestion) - Used iperf3 to see if there is any improvement in overall throughput from guest to host - Pinned the vhost process to a pCPU. - Run fio using 512B payload Rebased on latest net-next --- Luigi Leonardi (1): vso

[PATCH net-next v4 1/2] vsock/virtio: refactor virtio_transport_send_pkt_work

2024-07-30 Thread Luigi Leonardi via B4 Relay
From: Marco Pinna Preliminary patch to introduce an optimization to the enqueue system. All the code used to enqueue a packet into the virtqueue is removed from virtio_transport_send_pkt_work() and moved to the new virtio_transport_send_skb() function. Co-developed-by: Luigi Leonardi Signed

[PATCH net-next v4 2/2] vsock/virtio: avoid queuing packets when intermediate queue is empty

2024-07-30 Thread Luigi Leonardi via B4 Relay
From: Luigi Leonardi When the driver needs to send new packets to the device, it always queues the new sk_buffs into an intermediate queue (send_pkt_queue) and schedules a worker (send_pkt_work) to then queue them into the virtqueue exposed to the device. This increases the chance of batching