Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3924175rdb; Mon, 11 Dec 2023 04:15:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUnp2H2+d51Bdm03ycMq29xWLTbzKam3Eui8l0IVlJNFNQP71xcO4pHhFPytFdYrcg47RK X-Received: by 2002:a17:902:b405:b0:1d0:d312:bbfe with SMTP id x5-20020a170902b40500b001d0d312bbfemr3993552plr.15.1702296956169; Mon, 11 Dec 2023 04:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702296956; cv=none; d=google.com; s=arc-20160816; b=hQu4rMifyu6xVkbZg+aX4HbiH07DQUAV6wW4IMNKsFK8+KCIL8XjCAi5gaG4ws5YUV YJHOZmR66I+UvebHBpwUt0ODNfu0xmrdBEoZAe9wMTMq7YSUDJ8VHlSKQ0Z66prB32bE INyBiVqnxf8Nbqg6mu9BIQlCOc6a2QalIEA9yfVcOnEOUbUD0QtxtEq8EMNaI1EYT0fY ZylaI9SNlRS9S3sAnN1vCpjOgGFjR98qv6cNSDveXGP1mUCkKYUvzoCXXfe3MYVjSHD3 pKJRMgCBOaPedC2yPbR5IIPyFBXpqkof4OtPn0oiKaBmnFk8m7tPmpEE2/6J58qOoQ8P xpfw== 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=iD7SbymiWWK9UIngr+OU7k+vj/QXuQMXgXungJy+RzE=; fh=JEq7ZyqHwnKMAbPjHbEHIOO1u1YxTWxtQlCbJmwG+xw=; b=AfLrZQzrWU7HdGeK04CYlTH8iwVU0VnUut1QaPLjfkP1Bsa9JlueoiBgLhabPwv24L 5w4PBzfcToAbYG3X0Cerlh3nXu4WQAviYx3zxncpAqdl793YwZ5/iB4kdEpUzo31m3tU A68m57TJl5t1S0WMNnBAdLbok0+msBU9D8K7V8SbhozcU3dOblw8Lcv9vpTZH/N7DohO LPQ/fwf1I+mKGV7OdUHUJIgx6tLH9yQdlUif4/EYKYiWqQKqiskV5T70yB20vHLM609N T3Mq9LNughVXHElYsNqBHOe3/xt6nb+bEWThaFBZcoMDASwcNKmh+Hg7BdtHFoOHZ4xY 6U6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZedCdXuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s10-20020a170902ea0a00b001cf7ce5e6e0si6157350plg.330.2023.12.11.04.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:15:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZedCdXuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id D01798095816; Mon, 11 Dec 2023 04:15:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343500AbjLKMPE (ORCPT + 99 others); Mon, 11 Dec 2023 07:15:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234883AbjLKMO4 (ORCPT ); Mon, 11 Dec 2023 07:14:56 -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 2A81D100 for ; Mon, 11 Dec 2023 04:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702296895; 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=iD7SbymiWWK9UIngr+OU7k+vj/QXuQMXgXungJy+RzE=; b=ZedCdXukCR6IxGFfA/mpOcVOvG+QoK45qB4qhUwyalJUrsRF4jgx5c4o8Ml8BTBtwjeeE/ 29j9s4Hvi7Gyc7VMV98XY/Y9bKj6FWwu5bzX56fVf6hdBe+P+ad63l4o9iXBLP+2mhRNyc 2tGjRIadoe/kemXdgnZbVDZOGzYF73M= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-91-vW2U2Jt6OIip25ucveJxOA-1; Mon, 11 Dec 2023 07:14:53 -0500 X-MC-Unique: vW2U2Jt6OIip25ucveJxOA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-425a62f0997so42263831cf.0 for ; Mon, 11 Dec 2023 04:14:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702296591; x=1702901391; 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=iD7SbymiWWK9UIngr+OU7k+vj/QXuQMXgXungJy+RzE=; b=MfHhFsNp2wBx3Ey5w8qVkBKS7GvINm1CRWGyh1u/GFKtesyfQ4KNa5qpeC7YmskrGE Atc2kMdqsgrrqIv15PsK51Twr2lHGBnppMjxvNuHqxAXFksB+lmakVjppRR2w+gSACYu gp7+Af5sTI7rFl5FwD2DD8Jy54dtl91YC932kP36RU2adU8mt0mv9FnfS8ZIbk4hexY4 u7hwvA+lPN4en1vH1AJHVRY1lXc017ZwzYtUoKwmq9B6Ygq7jDETvR34Jz5vBRfD8xIj ZkPZ4Vc09OPpoXQHKBJCKGeGB+Hr/IRii1CtmFC02j+7D3t0RhxPnWy64YoQHQrJ6GSE 2AEA== X-Gm-Message-State: AOJu0Yx/SO2DK964+o8942IoGIUTWvHdX7O5wL+o1lWzCZKuTlQOMayd pUR0z/N4id56KIwu0SUCv/oHid/YImat/TvA7ncR8ii3EUHlFa4c6LT6Y+5pZy0+MTIjB1HZi5K vbH8u/utkqMJ5NnFCraXTve+J X-Received: by 2002:ac8:58c6:0:b0:425:a72b:9a69 with SMTP id u6-20020ac858c6000000b00425a72b9a69mr6644331qta.20.1702296591503; Mon, 11 Dec 2023 04:09:51 -0800 (PST) X-Received: by 2002:ac8:58c6:0:b0:425:a72b:9a69 with SMTP id u6-20020ac858c6000000b00425a72b9a69mr6644311qta.20.1702296591201; Mon, 11 Dec 2023 04:09:51 -0800 (PST) Received: from sgarzare-redhat ([95.131.45.143]) by smtp.gmail.com with ESMTPSA id j25-20020ac874d9000000b004257e4c5e21sm3124366qtr.28.2023.12.11.04.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:09:50 -0800 (PST) Date: Mon, 11 Dec 2023 13:09:32 +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: [PATCH net-next v7 2/4] virtio/vsock: send credit update during setting SO_RCVLOWAT Message-ID: <5b6duib6nre43ak5kzjgtfrnov5ogd4clka2hgf2xlgpm4jmw7@wbm4jxxslrm6> References: <20231206211849.2707151-1-avkrasnov@salutedevices.com> <20231206211849.2707151-3-avkrasnov@salutedevices.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20231206211849.2707151-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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 04:15:41 -0800 (PST) On Thu, Dec 07, 2023 at 12:18:47AM +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. > v4 -> v5: > * Do not change callbacks order in transport structures. > v5 -> v6: > * Reorder callbacks in transport structures. > * Do to send credit update when 'fwd_cnt' == 'last_fwd_cnt'. > > drivers/vhost/vsock.c | 1 + > include/linux/virtio_vsock.h | 1 + > net/vmw_vsock/virtio_transport.c | 1 + > net/vmw_vsock/virtio_transport_common.c | 30 +++++++++++++++++++++++++ > net/vmw_vsock/vsock_loopback.c | 1 + > 5 files changed, 34 insertions(+) Reviewed-by: Stefano Garzarella > >diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c >index f75731396b7e..ec20ecff85c7 100644 >--- a/drivers/vhost/vsock.c >+++ b/drivers/vhost/vsock.c >@@ -449,6 +449,7 @@ 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, > }, >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..f495b9e5186b 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -537,6 +537,7 @@ 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, > }, >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index f6dc896bf44c..e137d740804e 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -1684,6 +1684,36 @@ 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. Also >+ * don't send credit update when peer already knows actual value - >+ * such transmission will be useless. >+ */ >+ send_update = (vvs->rx_bytes < val) && >+ (vvs->fwd_cnt != vvs->last_fwd_cnt); >+ >+ 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..6dea6119f5b2 100644 >--- a/net/vmw_vsock/vsock_loopback.c >+++ b/net/vmw_vsock/vsock_loopback.c >@@ -96,6 +96,7 @@ 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, > }, >-- >2.25.1 >