Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4502822rdb; Tue, 12 Dec 2023 00:57:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGysF8n2UiSQgSP2GFEvbhF8eEl39xYbqS8XZUUgYJvb9uyiB0Ud8oYCL/Eaci8XOxalMj X-Received: by 2002:a05:6358:7e44:b0:170:cc82:db41 with SMTP id p4-20020a0563587e4400b00170cc82db41mr4562834rwm.21.1702371444111; Tue, 12 Dec 2023 00:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702371444; cv=none; d=google.com; s=arc-20160816; b=z8wcXDbaWWdyoHmwXAyeB2l5DAJ/90I87yvC22JSqwaM9IZDJS479WN6gqCGYTX4hR IeiC+dq+LmOOlyv9iCtDKsJxeq9k+v8twmEgOowB05sdPXO4gXvwWWqP5dH096jOHfXS YyN0u2VYJBsnp3atUk5SkWOTPJJBzNy2Keu67/skvcYQG/qJV2TG4p2/ZqRzZ67uXOm5 Cm5G5yeY/xI3InIqA9VZ5ztxr/nW4LKPv0KvbVIfByXrySUXhoBV/5P+ZJmqJq/aOfx7 2KAkLA4KKDRdoqqbmQL2iGoLHHbTu/wL8kRv1EjD4jEWM8nz5w3LrWmIyomkLrvoU7r0 1buQ== 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=+DYsFoZHtER6WKTlmJtvh956H3bsUBDuNP4h+dQhswI=; fh=JEq7ZyqHwnKMAbPjHbEHIOO1u1YxTWxtQlCbJmwG+xw=; b=yd11g/nCsmwTyGu9bAuIO0DpOiATJ9Gbi88Y3tlgVci2E8yN7YSUN8dfyjz3X3rAt0 xrqTJ/3iWkG2lJyLO+7Nmk13jjc8tZyFBwI2/gvDhP/s8MmjQ+KPwFZ4tf2k0aKLNtxD IAZifzbkAw4wZ/xZB8JoMwlQyu8/DlFp+rggkOlMHycZ8PjtmTOmOJERVl/7/r5gU/nZ 0jw5A23QJUKohts+KnkAwdHncCmGLg0z36LOBDOEGVQf1Aq+SQ+w1q80ry5j8WuD27Fg tQcmvFSxQRxN5UbBdUqL9+CpcGFKKjrxdzM2cWwTNy8Ryc//iDg3hXOBUu7NmR1T9NMA 0eNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b5n7yADB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i3-20020a635403000000b005c1b5a2be77si7111853pgb.702.2023.12.12.00.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:57:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b5n7yADB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 2982C809A9A4; Tue, 12 Dec 2023 00:57:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231210AbjLLI47 (ORCPT + 99 others); Tue, 12 Dec 2023 03:56:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjLLI45 (ORCPT ); Tue, 12 Dec 2023 03:56:57 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C260EC3 for ; Tue, 12 Dec 2023 00:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702371423; 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=+DYsFoZHtER6WKTlmJtvh956H3bsUBDuNP4h+dQhswI=; b=b5n7yADBoDPIcN3mS/DJOo/9PTEPpZ1QO97GYXvK2mXvUtO34sEiE7HSaBF87MKIi9PIdM fcQW0JDyXvtMHxh0vKbmKS8yEbk2PyBpzRoDmCJNEXEoNGwkqEtvfGYSSPPhubfIwn2tPw tCujjUl+a/e7LmkfiiNWJ+pXCz1JYvE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-yzMAS6jsP8-go3E1HS9m_g-1; Tue, 12 Dec 2023 03:57:01 -0500 X-MC-Unique: yzMAS6jsP8-go3E1HS9m_g-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-40c33d8dfceso29176605e9.0 for ; Tue, 12 Dec 2023 00:57:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702371420; x=1702976220; 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=+DYsFoZHtER6WKTlmJtvh956H3bsUBDuNP4h+dQhswI=; b=cZgcO03Kdory4Yr32oSohBiyxM4WGN1e9sM+J4Sry8DlQvbp1pbP8EN6ByvXc12G34 FjoLNUtfIawznFqhtiRITVBJ4uQlrILMBVuiW5033MA+9I/5EPQv9PtjLMATOs9GiMXG de7L/x/ZygiuiE0c3wSEiQ0CBVAV4kDRik/q/Y7vpQavYWTnLe4/ND9dHc0MnJ8FiOR3 MjM/zn69o+5hvTjIa1a1Tv/Aj2mgphS99UuivejoBMSM2fbm5eQK7b56C2Xh1FqS4R4Q GX+QDHBF+BbqGouwi4s8AdG4yaDr9o2MADLHZjILg1nUPrkm8SR7Irsw9OoX8RUXb9PF meYw== X-Gm-Message-State: AOJu0YzaSDZ6cCRv9zn2kDcXqs0McyxuVyWOIjjLriVQI2mJVG37uOZU 8a3Nszze5Z3iBDM/m+4kgKivCLy76U8b31/PJfNc8BgpYDZIkFvQzAS4nj80n0RdrRpjqv23fEH gtnagsdYTTbNpWtvnL2W/TtoU X-Received: by 2002:a05:600c:3b26:b0:40c:224a:4450 with SMTP id m38-20020a05600c3b2600b0040c224a4450mr3229517wms.37.1702371420265; Tue, 12 Dec 2023 00:57:00 -0800 (PST) X-Received: by 2002:a05:600c:3b26:b0:40c:224a:4450 with SMTP id m38-20020a05600c3b2600b0040c224a4450mr3229507wms.37.1702371419828; Tue, 12 Dec 2023 00:56:59 -0800 (PST) Received: from sgarzare-redhat ([193.207.128.35]) by smtp.gmail.com with ESMTPSA id d13-20020a05600c34cd00b0040c496c64cfsm5430442wmq.12.2023.12.12.00.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 00:56:59 -0800 (PST) Date: Tue, 12 Dec 2023 09:56:45 +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 v8 3/4] virtio/vsock: fix logic which reduces credit update messages Message-ID: <5wewycputeafvvgehioon3j75hlwxeliyni6nt4qtw3ch5rlt4@o7yncdbcyoc4> References: <20231211211658.2904268-1-avkrasnov@salutedevices.com> <20231211211658.2904268-4-avkrasnov@salutedevices.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20231211211658.2904268-4-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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 00:57:14 -0800 (PST) On Tue, Dec 12, 2023 at 12:16:57AM +0300, Arseniy Krasnov wrote: >Add one more condition for sending credit update during dequeue from >stream socket: when number of bytes in the rx queue is smaller than >SO_RCVLOWAT value of the socket. This is actual for non-default value >of SO_RCVLOWAT (e.g. not 1) - idea is to "kick" peer to continue data >transmission, because we need at least SO_RCVLOWAT bytes in our rx >queue to wake up user for reading data (in corner case it is also >possible to stuck both tx and rx sides, this is why 'Fixes' is used). > >Fixes: b89d882dc9fc ("vsock/virtio: reduce credit update messages") >Signed-off-by: Arseniy Krasnov >--- > Changelog: > v6 -> v7: > * Handle wrap of 'fwd_cnt'. > * Do to send credit update when 'fwd_cnt' == 'last_fwd_cnt'. > v7 -> v8: > * Remove unneeded/wrong handling of wrap for 'fwd_cnt'. > > net/vmw_vsock/virtio_transport_common.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) Reviewed-by: Stefano Garzarella Thanks! Stefano > >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index e137d740804e..8572f94bba88 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -558,6 +558,8 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, > struct virtio_vsock_sock *vvs = vsk->trans; > size_t bytes, total = 0; > struct sk_buff *skb; >+ u32 fwd_cnt_delta; >+ bool low_rx_bytes; > int err = -EFAULT; > u32 free_space; > >@@ -601,7 +603,10 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, > } > } > >- free_space = vvs->buf_alloc - (vvs->fwd_cnt - vvs->last_fwd_cnt); >+ fwd_cnt_delta = vvs->fwd_cnt - vvs->last_fwd_cnt; >+ free_space = vvs->buf_alloc - fwd_cnt_delta; >+ low_rx_bytes = (vvs->rx_bytes < >+ sock_rcvlowat(sk_vsock(vsk), 0, INT_MAX)); > > spin_unlock_bh(&vvs->rx_lock); > >@@ -611,9 +616,11 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, > * too high causes extra messages. Too low causes transmitter > * stalls. As stalls are in theory more expensive than extra > * messages, we set the limit to a high value. TODO: experiment >- * with different values. >+ * with different values. Also send credit update message when >+ * number of bytes in rx queue is not enough to wake up reader. > */ >- if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) >+ if (fwd_cnt_delta && >+ (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE || low_rx_bytes)) > virtio_transport_send_credit_update(vsk); > > return total; >-- >2.25.1 >