2023-11-15 11:08:53

by Stefano Garzarella

[permalink] [raw]
Subject: Re: [RFC PATCH v1 0/2] send credit update during setting SO_RCVLOWAT

On Wed, Nov 08, 2023 at 10:20:02AM +0300, Arseniy Krasnov wrote:
>Hello,
>
> DESCRIPTION
>
>This patchset fixes old problem with hungup of both rx/tx sides and adds
>test for it. This happens due to non-default SO_RCVLOWAT value and
>deferred credit update in virtio/vsock. Link to previous old patchset:
>https://lore.kernel.org/netdev/[email protected]/
>
>Here is what happens step by step:
>
> TEST
>
> INITIAL CONDITIONS
>
>1) Vsock buffer size is 128KB.
>2) Maximum packet size is also 64KB as defined in header (yes it is
> hardcoded, just to remind about that value).
>3) SO_RCVLOWAT is default, e.g. 1 byte.
>
>
> STEPS
>
> SENDER RECEIVER
>1) sends 128KB + 1 byte in a
> single buffer. 128KB will
> be sent, but for 1 byte
> sender will wait for free
> space at peer. Sender goes
> to sleep.
>
>
>2) reads 64KB, credit update not sent
>3) sets SO_RCVLOWAT to 64KB + 1
>4) poll() -> wait forever, there is
> only 64KB available to read.
>
>So in step 4) receiver also goes to sleep, waiting for enough data or
>connection shutdown message from the sender. Idea to fix it is that rx
>kicks tx side to continue transmission (and may be close connection)
>when rx changes number of bytes to be woken up (e.g. SO_RCVLOWAT) and
>this value is bigger than number of available bytes to read.
>
>I've added small test for this, but not sure as it uses hardcoded value

Thanks for adding the test!

>for maximum packet length, this value is defined in kernel header and
>used to control deferred credit update. And as this is not available to
>userspace, I can't control test parameters correctly (if one day this
>define will be changed - test may become useless).

I see, I'll leave a comment in the patch!

Thanks,
Stefano

>
>Head for this patchset is:
>https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=ff269e2cd5adce4ae14f883fc9c8803bc43ee1e9
>
>Arseniy Krasnov (2):
> virtio/vsock: send credit update during setting SO_RCVLOWAT
> vsock/test: SO_RCVLOWAT + deferred credit update test
>
> drivers/vhost/vsock.c | 2 +
> include/linux/virtio_vsock.h | 1 +
> net/vmw_vsock/virtio_transport.c | 2 +
> net/vmw_vsock/virtio_transport_common.c | 31 ++++++
> net/vmw_vsock/vsock_loopback.c | 2 +
> tools/testing/vsock/vsock_test.c | 131 ++++++++++++++++++++++++
> 6 files changed, 169 insertions(+)
>
>--
>2.25.1
>