linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1 00/16] Improve SOCK_SEQPACKET receive logic
@ 2021-06-28  9:59 Arseny Krasnov
  2021-06-28 10:01 ` [RFC PATCH v1 01/16] vhost/vsock: don't set 'seqpacket_has_data()' callback Arseny Krasnov
                   ` (15 more replies)
  0 siblings, 16 replies; 26+ messages in thread
From: Arseny Krasnov @ 2021-06-28  9:59 UTC (permalink / raw)
  To: Stefan Hajnoczi, Stefano Garzarella, Michael S. Tsirkin,
	Jason Wang, David S. Miller, Jakub Kicinski, Arseny Krasnov,
	Colin Ian King, Andra Paraschiv, Norbert Slusarek
  Cc: kvm, virtualization, netdev, linux-kernel, oxffffaa

	This patchset modifies receive logic for SOCK_SEQPACKET.
Difference between current implementation and this version is that
now reader is woken up when there is at least one RW packet in rx
queue of socket and data is copied to user's buffer, while merged
approach wake up user only when whole message is received and kept
in queue. New implementation has several advantages:
 1) There is no limit for message length. Merged approach requires
    that length must be smaller than 'peer_buf_alloc', otherwise
    transmission will stuck.
 2) There is no need to keep whole message in queue, thus no
    'kmalloc()' memory will be wasted until EOR is received.

    Also new approach has some feature: as fragments of message
are copied until EOR is received, it is possible that part of
message will be already in user's buffer, while rest of message
still not received. And if user will be interrupted by signal or
timeout with part of message in buffer, it will exit receive loop,
leaving rest of message in queue. To solve this problem special
callback was added to transport: it is called when user was forced
to leave exit loop and tells transport to drop any packet until
EOR met. When EOR is found, this mode is disabled and normal packet
processing started. Note, that when 'drop until EOR' mode is on,
incoming packets still inserted in queue, reader will be woken up,
tries to copy data, but nothing will be copied until EOR found.
It was possible to drain such unneeded packets it rx work without
kicking user, but implemented way is simplest. Anyway, i think
such cases are rare.

    New test also added - it tries to copy to invalid user's
buffer.

Arseny Krasnov (16):
 vhost/vsock: don't set 'seqpacket_has_data()' callback
 vsock/loopback: don't set 'seqpacket_has_data()' callback
 virtio/vsock: don't set 'seqpacket_has_data()' callback
 virtio/vsock: remove 'virtio_transport_seqpacket_has_data'
 af_vsock: use SOCK_STREAM function to check data
 vsock/virtio: remove record size limit for SEQPACKET
 virtio/vsock: don't count EORs on receive
 af_vsock: change SEQPACKET receive loop
 af_vsock/virtio: update dequeue callback interface
 virtio/vsock: update SEQPACKET dequeue logic
 afvsock: add 'seqpacket_drop()'
 virtio/vsock: add 'drop until EOR' logic
 vhost/vsock: enable 'seqpacket_drop' callback in transport
 virtio/vsock: enable 'seqpacket_drop' callback in transport
 vsock/loopback: enable 'seqpacket_drop' callback in transport
 vsock_test: SEQPACKET read to broken buffer

 drivers/vhost/vsock.c                   |   2 +-
 include/linux/virtio_vsock.h            |   7 +-
 include/net/af_vsock.h                  |   4 +-
 net/vmw_vsock/af_vsock.c                |  44 ++++----
 net/vmw_vsock/virtio_transport.c        |   2 +-
 net/vmw_vsock/virtio_transport_common.c | 103 +++++++-----------
 net/vmw_vsock/vsock_loopback.c          |   2 +-
 tools/testing/vsock/vsock_test.c        | 121 ++++++++++++++++++++++
 8 files changed, 194 insertions(+), 91 deletions(-)

Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>

-- 
2.25.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2021-06-30 17:48 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28  9:59 [RFC PATCH v1 00/16] Improve SOCK_SEQPACKET receive logic Arseny Krasnov
2021-06-28 10:01 ` [RFC PATCH v1 01/16] vhost/vsock: don't set 'seqpacket_has_data()' callback Arseny Krasnov
2021-06-28 10:01 ` [RFC PATCH v1 02/16] vsock/loopback: " Arseny Krasnov
2021-06-28 10:02 ` [RFC PATCH v1 03/16] virtio/vsock: " Arseny Krasnov
2021-06-28 10:02 ` [RFC PATCH v1 04/16] virtio/vsock: remove 'virtio_transport_seqpacket_has_data' Arseny Krasnov
2021-06-28 10:02 ` [RFC PATCH v1 05/16] af_vsock: use SOCK_STREAM function to check data Arseny Krasnov
2021-06-30 12:10   ` Stefano Garzarella
2021-06-30 17:47     ` [MASSMAIL KLMS] " Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 06/16] vsock/virtio: remove record size limit for SEQPACKET Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 07/16] virtio/vsock: don't count EORs on receive Arseny Krasnov
2021-06-30 12:11   ` Stefano Garzarella
2021-06-30 17:47     ` Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 08/16] af_vsock: change SEQPACKET receive loop Arseny Krasnov
2021-06-30 12:12   ` Stefano Garzarella
2021-06-30 17:47     ` Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 09/16] af_vsock/virtio: update dequeue callback interface Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 10/16] virtio/vsock: update SEQPACKET dequeue logic Arseny Krasnov
2021-06-28 10:04 ` [RFC PATCH v1 11/16] afvsock: add 'seqpacket_drop()' Arseny Krasnov
2021-06-30 12:12   ` Stefano Garzarella
2021-06-30 17:48     ` Arseny Krasnov
2021-06-28 10:04 ` [RFC PATCH v1 12/16] virtio/vsock: add 'drop until EOR' logic Arseny Krasnov
2021-06-28 10:04 ` [RFC PATCH v1 13/16] vhost/vsock: enable 'seqpacket_drop' callback in transport Arseny Krasnov
2021-06-28 10:05 ` [RFC PATCH v1 14/16] virtio/vsock: " Arseny Krasnov
2021-06-28 10:05 ` [RFC PATCH v1 15/16] vsock/loopback: " Arseny Krasnov
2021-06-28 10:05 ` [RFC PATCH v1 16/16] vsock_test: SEQPACKET read to broken buffer Arseny Krasnov
2021-06-30 12:17   ` Stefano Garzarella

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).