RE: [PATCH net-next 07/14] vsock: handle buffer_size sockopts in the core

2019-10-30 Thread Jorgen Hansen via Virtualization
> From: Stefano Garzarella [mailto:sgarz...@redhat.com]
> Sent: Wednesday, October 23, 2019 11:56 AM
> Subject: [PATCH net-next 07/14] vsock: handle buffer_size sockopts in the
> core
> 
> virtio_transport and vmci_transport handle the buffer_size sockopts in a
> very similar way.
> 
> In order to support multiple transports, this patch moves this handling in the
> core to allow the user to change the options also if the socket is not yet
> assigned to any transport.
> 
> This patch also adds the '.notify_buffer_size' callback in the 'struct
> virtio_transport' in order to inform the transport, when the buffer_size is
> changed by the user. It is also useful to limit the 'buffer_size' requested 
> (e.g.
> virtio transports).
> 
> Acked-by: Dexuan Cui 
> Signed-off-by: Stefano Garzarella 
> ---
> RFC -> v1:
> - changed .notify_buffer_size return to void (Stefan)
> - documented that .notify_buffer_size is called with sk_lock held (Stefan)
> ---
>  drivers/vhost/vsock.c   |  7 +-
>  include/linux/virtio_vsock.h| 15 +
>  include/net/af_vsock.h  | 15 ++---
>  net/vmw_vsock/af_vsock.c| 43 ++---
>  net/vmw_vsock/hyperv_transport.c| 36 ---
>  net/vmw_vsock/virtio_transport.c|  8 +--
>  net/vmw_vsock/virtio_transport_common.c | 79 ---
>  net/vmw_vsock/vmci_transport.c  | 86 +++--
>  net/vmw_vsock/vmci_transport.h  |  3 -
>  9 files changed, 65 insertions(+), 227 deletions(-)
> 
> diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index
> 92ab3852c954..6d7e4f022748 100644
> --- a/drivers/vhost/vsock.c
> +++ b/drivers/vhost/vsock.c
> @@ -418,13 +418,8 @@ static struct virtio_transport vhost_transport = {
>   .notify_send_pre_block=
> virtio_transport_notify_send_pre_block,
>   .notify_send_pre_enqueue  =
> virtio_transport_notify_send_pre_enqueue,
>   .notify_send_post_enqueue =
> virtio_transport_notify_send_post_enqueue,
> + .notify_buffer_size   = virtio_transport_notify_buffer_size,
> 
> - .set_buffer_size  = virtio_transport_set_buffer_size,
> - .set_min_buffer_size  =
> virtio_transport_set_min_buffer_size,
> - .set_max_buffer_size  =
> virtio_transport_set_max_buffer_size,
> - .get_buffer_size  = virtio_transport_get_buffer_size,
> - .get_min_buffer_size  =
> virtio_transport_get_min_buffer_size,
> - .get_max_buffer_size  =
> virtio_transport_get_max_buffer_size,
>   },
> 
>   .send_pkt = vhost_transport_send_pkt,
> diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h index
> 96d8132acbd7..b79befd2a5a4 100644
> --- a/include/linux/virtio_vsock.h
> +++ b/include/linux/virtio_vsock.h
> @@ -7,9 +7,6 @@
>  #include 
>  #include 
> 
> -#define VIRTIO_VSOCK_DEFAULT_MIN_BUF_SIZE128
> -#define VIRTIO_VSOCK_DEFAULT_BUF_SIZE(1024 * 256)
> -#define VIRTIO_VSOCK_DEFAULT_MAX_BUF_SIZE(1024 * 256)
>  #define VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE (1024 * 4)
>  #define VIRTIO_VSOCK_MAX_BUF_SIZE0xUL
>  #define VIRTIO_VSOCK_MAX_PKT_BUF_SIZE(1024 * 64)
> @@ -25,11 +22,6 @@ enum {
>  struct virtio_vsock_sock {
>   struct vsock_sock *vsk;
> 
> - /* Protected by lock_sock(sk_vsock(trans->vsk)) */
> - u32 buf_size;
> - u32 buf_size_min;
> - u32 buf_size_max;
> -
>   spinlock_t tx_lock;
>   spinlock_t rx_lock;
> 
> @@ -93,12 +85,6 @@ s64 virtio_transport_stream_has_space(struct
> vsock_sock *vsk);
> 
>  int virtio_transport_do_socket_init(struct vsock_sock *vsk,
>struct vsock_sock *psk);
> -u64 virtio_transport_get_buffer_size(struct vsock_sock *vsk);
> -u64 virtio_transport_get_min_buffer_size(struct vsock_sock *vsk);
> -u64 virtio_transport_get_max_buffer_size(struct vsock_sock *vsk); -void
> virtio_transport_set_buffer_size(struct vsock_sock *vsk, u64 val); -void
> virtio_transport_set_min_buffer_size(struct vsock_sock *vsk, u64 val); -void
> virtio_transport_set_max_buffer_size(struct vsock_sock *vs, u64 val);  int
> virtio_transport_notify_poll_in(struct vsock_sock *vsk,
>   size_t target,
> @@ -125,6 +111,7 @@ int
> virtio_transport_notify_send_pre_enqueue(struct vsock_sock *vsk,
>   struct vsock_transport_send_notify_data *data);  int
> virtio_transport_notify_send_post_enqueue(struct vsock_sock *vsk,
>   ssize_t written, struct vsock_transport_send_notify_data *data);
> +void virtio_transport_notify_buffer_size(struct vsock_sock *vsk, u64
> +*val);
> 
>  u64 virtio_transport_stream_rcvhiwat(struct vsock_sock *vsk);  bool
> virtio_transport_stream_is_active(struct vsock_sock *vsk); diff --git
> a/include/net/af_vsock.h b/include/net/af_vsock.h index
> 2ca67d048de4..4b5d16840fd4 100644
> --- a/include/net/af_vsock.h
> +++ 

Re: [PATCH net-next 07/14] vsock: handle buffer_size sockopts in the core

2019-10-27 Thread Stefan Hajnoczi
On Wed, Oct 23, 2019 at 11:55:47AM +0200, Stefano Garzarella wrote:
> virtio_transport and vmci_transport handle the buffer_size
> sockopts in a very similar way.
> 
> In order to support multiple transports, this patch moves this
> handling in the core to allow the user to change the options
> also if the socket is not yet assigned to any transport.
> 
> This patch also adds the '.notify_buffer_size' callback in the
> 'struct virtio_transport' in order to inform the transport,
> when the buffer_size is changed by the user. It is also useful
> to limit the 'buffer_size' requested (e.g. virtio transports).
> 
> Acked-by: Dexuan Cui 
> Signed-off-by: Stefano Garzarella 
> ---
> RFC -> v1:
> - changed .notify_buffer_size return to void (Stefan)
> - documented that .notify_buffer_size is called with sk_lock held (Stefan)
> ---
>  drivers/vhost/vsock.c   |  7 +-
>  include/linux/virtio_vsock.h| 15 +
>  include/net/af_vsock.h  | 15 ++---
>  net/vmw_vsock/af_vsock.c| 43 ++---
>  net/vmw_vsock/hyperv_transport.c| 36 ---
>  net/vmw_vsock/virtio_transport.c|  8 +--
>  net/vmw_vsock/virtio_transport_common.c | 79 ---
>  net/vmw_vsock/vmci_transport.c  | 86 +++--
>  net/vmw_vsock/vmci_transport.h  |  3 -
>  9 files changed, 65 insertions(+), 227 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization