Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp153313rdb; Thu, 30 Nov 2023 00:39:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIJLO1eowj4xymSwRwASW5y5ln5o2DCRjuOhCfl7I27gQ2S4OmcKl/1vKrenWAHwzYG8kh X-Received: by 2002:a05:6a21:2d87:b0:187:71f7:bb26 with SMTP id ty7-20020a056a212d8700b0018771f7bb26mr23541854pzb.54.1701333567855; Thu, 30 Nov 2023 00:39:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701333567; cv=none; d=google.com; s=arc-20160816; b=Q8CADfBBwUirxwQRd9du3RdSa+jlj75HJixlT7P2fuTk2XAFYjnBr8IangQzSiHMPi xpobc1CvnCCfa++Hr/4Jb/3/satV/2FV+Cewl/1cqPJP+oUzM1Thw5y+aZwp7h0Gfo/m 8kK/Xez+0w/BLtVdgXytJOX7LVdPXH+Mw2tlOTvELFYotWu1moGt+2alHzHAr25FPDIn H+FDX+CfwrDpuJ0B0BXaW0VBGYaA+j5M2EvyRokMtMH3+4AkUH/vGvQJqsHFymY5jM00 2jWxAD6yomduisbpADceZ7hO0IlgKeC/VEsx1FhAYzc5v43QbkQDXxUxf0M/kI+wgvOo Hvdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AuNrzCx4xahsS/7j/jwf4UTh/OtxU2ehfXj/9UH3fEA=; fh=JEq7ZyqHwnKMAbPjHbEHIOO1u1YxTWxtQlCbJmwG+xw=; b=fWCy17lBad6a/2pzoU0zOU4uEYLNMfrTdoyLknNwe3FbEqlYKS1UDc+txztRMWm5UG Wmlv9bmG3PbXQmAZipNPIqQqMS11U3cYKfwOUwg2AmCuYH1QP7P8G5wVclYvlhjn+p5Z y1fW+BB8hxMzJlhL2DPLqYTVYk9emy7wopQ0dGvPKNGMC0cPUlTOSMTgEufjdC7mWwlf dMjgkNW6GRFcw8Ddq56WmZA5Zow6GfHqmTxQHKIVXSSc75zmYYKulkU89DJet3hT3Yo0 jk9EhsXlOoK55AYF/iou31LLmtM3JkyPtXho/J+uPpZMQBPQpVkS77jIjWXA/dCtRdBk e4hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DLjkV28t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e22-20020a17090ac21600b002859d51fafcsi948061pjt.41.2023.11.30.00.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DLjkV28t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EAB918029579; Thu, 30 Nov 2023 00:39:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344983AbjK3IjI (ORCPT + 99 others); Thu, 30 Nov 2023 03:39:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345007AbjK3Ii6 (ORCPT ); Thu, 30 Nov 2023 03:38:58 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CDAF10D1 for ; Thu, 30 Nov 2023 00:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701333543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AuNrzCx4xahsS/7j/jwf4UTh/OtxU2ehfXj/9UH3fEA=; b=DLjkV28tpkpl9aK8LMmiTMlbzqGfcv0yU+zLSpe2H9TCyzD7iiw2vpZQAPyiXF6kGkZrZi xr3XY8UYswOuSvsCsWtumdehDW+RR4e8SXpcLeZWAKOGZbJ4brzcOxcPc4SORX+G/o9+0/ zsbdVv+MgXWYDxEJbUt2iPdTbbI+X1Y= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-y74GAt-mOmOQvrKXNc6fcQ-1; Thu, 30 Nov 2023 03:39:01 -0500 X-MC-Unique: y74GAt-mOmOQvrKXNc6fcQ-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c8749e1c2dso7226741fa.0 for ; Thu, 30 Nov 2023 00:39:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333540; x=1701938340; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AuNrzCx4xahsS/7j/jwf4UTh/OtxU2ehfXj/9UH3fEA=; b=DnH/JLE03SI1OuDaPGUrs6IxmpAptFBcp9yghpQo3l4FhPkfrcLtSA++vkHsq5Wist qVsuJnADCPIwGUCXfn9y10nGAzs0jK4ARvEe01rSy9/cyOc7qTWC8tbn7nOhpVFB34au tXrrO511jS6/89qxd695C5PuaS+OLvNJ4q+C2rseO+Si/Gjd3iY3/lvrtz9tp325n266 AbgaEKAYzYHU84rjMwVqlUkg0x3Vg4LNmjWXGPlhjGt6wDuSswpIRh1awJ61IXOKyl00 XJIAv8itoG5BNUQFIyEPSJeRMYbf8oOoZdQ6r8dFimNJKOb7uVesMBSrpRZwXBCSfRro hztg== X-Gm-Message-State: AOJu0Yy/XcrVI1/sjg3yYKqu3pqlIemUoBnDKanDsZq1Jn6d+3BOD5IY ldUEtx+qMhol5leFd5mlh7Sjw0gVvXkYRES5wi/KRU+C2LkB9gJ8HKXctH5rDmDSX0nuoA5cBE2 OrvSdmfqcqgwjdS3RFZRHxuO7 X-Received: by 2002:a2e:9954:0:b0:2c9:ba2f:ac73 with SMTP id r20-20020a2e9954000000b002c9ba2fac73mr3934579ljj.16.1701333540460; Thu, 30 Nov 2023 00:39:00 -0800 (PST) X-Received: by 2002:a2e:9954:0:b0:2c9:ba2f:ac73 with SMTP id r20-20020a2e9954000000b002c9ba2fac73mr3934567ljj.16.1701333540119; Thu, 30 Nov 2023 00:39:00 -0800 (PST) Received: from sgarzare-redhat (host-79-46-200-199.retail.telecomitalia.it. [79.46.200.199]) by smtp.gmail.com with ESMTPSA id v13-20020adfedcd000000b003331bd6f58esm869261wro.69.2023.11.30.00.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:38:59 -0800 (PST) Date: Thu, 30 Nov 2023 09:38:54 +0100 From: Stefano Garzarella To: Arseniy Krasnov Cc: Stefan Hajnoczi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@sberdevices.ru, oxffffaa@gmail.com Subject: Re: [RFC PATCH v4 2/3] virtio/vsock: send credit update during setting SO_RCVLOWAT Message-ID: References: <20231129212519.2938875-1-avkrasnov@salutedevices.com> <20231129212519.2938875-3-avkrasnov@salutedevices.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20231129212519.2938875-3-avkrasnov@salutedevices.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 30 Nov 2023 00:39:25 -0800 (PST) On Thu, Nov 30, 2023 at 12:25:18AM +0300, Arseniy Krasnov wrote: >Send credit update message when SO_RCVLOWAT is updated and it is bigger >than number of bytes in rx queue. It is needed, because 'poll()' will >wait until number of bytes in rx queue will be not smaller than >SO_RCVLOWAT, so kick sender to send more data. Otherwise mutual hungup >for tx/rx is possible: sender waits for free space and receiver is >waiting data in 'poll()'. > >Signed-off-by: Arseniy Krasnov >--- > Changelog: > v1 -> v2: > * Update commit message by removing 'This patch adds XXX' manner. > * Do not initialize 'send_update' variable - set it directly during > first usage. > v3 -> v4: > * Fit comment in 'virtio_transport_notify_set_rcvlowat()' to 80 chars. > > drivers/vhost/vsock.c | 3 ++- > include/linux/virtio_vsock.h | 1 + > net/vmw_vsock/virtio_transport.c | 3 ++- > net/vmw_vsock/virtio_transport_common.c | 27 +++++++++++++++++++++++++ > net/vmw_vsock/vsock_loopback.c | 3 ++- > 5 files changed, 34 insertions(+), 3 deletions(-) > >diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c >index f75731396b7e..c5e58a60a546 100644 >--- a/drivers/vhost/vsock.c >+++ b/drivers/vhost/vsock.c >@@ -449,8 +449,9 @@ static struct virtio_transport vhost_transport = { > .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, >+ .notify_set_rcvlowat = virtio_transport_notify_set_rcvlowat, > >- .read_skb = virtio_transport_read_skb, >+ .read_skb = virtio_transport_read_skb I think it is better to avoid this change, so when we will need to add new callbacks, we don't need to edit this line again. Please avoid it also in the other place in this patch. The rest LGTM. Thanks, Stefano > }, > > .send_pkt = vhost_transport_send_pkt, >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h >index ebb3ce63d64d..c82089dee0c8 100644 >--- a/include/linux/virtio_vsock.h >+++ b/include/linux/virtio_vsock.h >@@ -256,4 +256,5 @@ void virtio_transport_put_credit(struct >virtio_vsock_sock *vvs, u32 credit); > void virtio_transport_deliver_tap_pkt(struct sk_buff *skb); > int virtio_transport_purge_skbs(void *vsk, struct sk_buff_head *list); > int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t read_actor); >+int virtio_transport_notify_set_rcvlowat(struct vsock_sock *vsk, int val); > #endif /* _LINUX_VIRTIO_VSOCK_H */ >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c >index af5bab1acee1..8b7bb7ca8ea5 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -537,8 +537,9 @@ static struct virtio_transport virtio_transport = { > .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, >+ .notify_set_rcvlowat = virtio_transport_notify_set_rcvlowat, > >- .read_skb = virtio_transport_read_skb, >+ .read_skb = virtio_transport_read_skb > }, > > .send_pkt = virtio_transport_send_pkt, >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index f6dc896bf44c..1cb556ad4597 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -1684,6 +1684,33 @@ int virtio_transport_read_skb(struct vsock_sock >*vsk, skb_read_actor_t recv_acto > } > EXPORT_SYMBOL_GPL(virtio_transport_read_skb); > >+int virtio_transport_notify_set_rcvlowat(struct vsock_sock *vsk, int val) >+{ >+ struct virtio_vsock_sock *vvs = vsk->trans; >+ bool send_update; >+ >+ spin_lock_bh(&vvs->rx_lock); >+ >+ /* If number of available bytes is less than new SO_RCVLOWAT value, >+ * kick sender to send more data, because sender may sleep in its >+ * 'send()' syscall waiting for enough space at our side. >+ */ >+ send_update = vvs->rx_bytes < val; >+ >+ spin_unlock_bh(&vvs->rx_lock); >+ >+ if (send_update) { >+ int err; >+ >+ err = virtio_transport_send_credit_update(vsk); >+ if (err < 0) >+ return err; >+ } >+ >+ return 0; >+} >+EXPORT_SYMBOL_GPL(virtio_transport_notify_set_rcvlowat); >+ > MODULE_LICENSE("GPL v2"); > MODULE_AUTHOR("Asias He"); > MODULE_DESCRIPTION("common code for virtio vsock"); >diff --git a/net/vmw_vsock/vsock_loopback.c b/net/vmw_vsock/vsock_loopback.c >index 048640167411..454f69838c2a 100644 >--- a/net/vmw_vsock/vsock_loopback.c >+++ b/net/vmw_vsock/vsock_loopback.c >@@ -96,8 +96,9 @@ static struct virtio_transport loopback_transport = { > .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, >+ .notify_set_rcvlowat = virtio_transport_notify_set_rcvlowat, > >- .read_skb = virtio_transport_read_skb, >+ .read_skb = virtio_transport_read_skb > }, > > .send_pkt = vsock_loopback_send_pkt, >-- >2.25.1 >