Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1617786ybe; Tue, 3 Sep 2019 00:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuv1XXb4N4crsp5IjeANE8W00mFSGywfYHtQ1go+Mm5GngucBxWVFXkOtbCV0Zq4tgv0vO X-Received: by 2002:a17:902:ab8f:: with SMTP id f15mr34305774plr.301.1567496474238; Tue, 03 Sep 2019 00:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567496474; cv=none; d=google.com; s=arc-20160816; b=DJ4ugHtOu2nkqhiuDGG/gmoA/qeRJEskezNDDudMzVrEmCo+NdXVMNo6Ev667QdV0k 47PIocuiH4zJlnncW2/InmqbaAJyYqNtmozFrA3nhsCWlff3Hsd6xwJ0p2+EVTEo6GrR 1LZr2mseDdOqyyJ6OJvfBaX4p7WgTURJQ2JWUB9Tj0fqbg3iMgbH01TimVr4EhztyqCI WUpOtllKyr6SdbX/DwBiiIlepCnerG6QugrCctzk8mxs+c9AWnY10xSVFWL9BBV66dpO UoKWfRPoamXHN1DvRTVArT70iU1N1SnR4Ewft4lU/MzZlLERZe79H34OCIfD7yfeqrVL LeQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=dJ3ujh22A4KMEYrsGqSfrfiJ4zKfJp828Rn6w4xYjq8=; b=dUXk1hCOFyB1b6HVWLF456Mv4UvhAJvLJ4uCD1GmEq6fOjk/zdXwsUrDdkEWf+LuSr q658XeyS01DBLdBWC6kGxc+M0LUGQAftIHyBdLKTm4rA+GVmyTJCS8Efi5OlTFUTf/D9 IPg5jI45ZtQf7/vePujODtOpJyi0Z9TSIxv2gmS/ew830/iT5Idzk15q9YW+Cb4CFsUg UiSMys6ui5B4MyAx0S4YoHLCiHhmp4AjTawf5erOgfUZf12uZ1YvR7lew7KNa3gkE4oM Cs+830zWKnwoxMHMlPjRRKxa9xBXUvpqj6WgPTO082HduqyO+8IXqfHJj1ksofKrYuVb K/yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si747850pff.107.2019.09.03.00.40.58; Tue, 03 Sep 2019 00:41:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728049AbfICHir (ORCPT + 99 others); Tue, 3 Sep 2019 03:38:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36722 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbfICHip (ORCPT ); Tue, 3 Sep 2019 03:38:45 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F7D080F98 for ; Tue, 3 Sep 2019 07:38:44 +0000 (UTC) Received: by mail-qt1-f200.google.com with SMTP id i9so17075118qtj.2 for ; Tue, 03 Sep 2019 00:38:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dJ3ujh22A4KMEYrsGqSfrfiJ4zKfJp828Rn6w4xYjq8=; b=S9uM4rWrbDfCiIdxp/JRccf9+t3DFURSFg93QqV5Bfw/+Rer+RF0NFlgJl6nw+1eIC SjhDkh65YHrCeKCFg9xEBo79dNeGatLkyHWFk/xqO7UUNlfyjXfzZiN7y56ZmtY5m5Hs FUIBMzcps+ojE9rgAxaFkmAs8aPHN/aJyymhbhiLvCTSYT7DhUa91h002WI/4NsjMVa5 KqeXNcE/OkhFKlcU6+ITA/nk389+wSe0EyYx+V6piItg4qlMg00khljXbAeVV7MfLsQA I7Sh/0aCgPHpGeTlN5yKOoYJaGXFqCPQ2F67cTdg5p0gcNkbZ3BCGde6rqoV8WbiV/IO lz4w== X-Gm-Message-State: APjAAAXrvYhEH7jQvpboJ0B6deGUH9CN4OGTQOoNCMJGu+K/dW9sWEdx LUdkKktUNDeFz5i92NHr9A3JJDMa426KA6cEK2a9IVBJFxkXksbYkZ/Qx8rp4XKRCjxjd/jddZC rRtHdcy7Shv6glLw3bLa6mixN X-Received: by 2002:ac8:7186:: with SMTP id w6mr19355759qto.371.1567496323076; Tue, 03 Sep 2019 00:38:43 -0700 (PDT) X-Received: by 2002:ac8:7186:: with SMTP id w6mr19355740qto.371.1567496322915; Tue, 03 Sep 2019 00:38:42 -0700 (PDT) Received: from redhat.com (bzq-79-180-62-110.red.bezeqint.net. [79.180.62.110]) by smtp.gmail.com with ESMTPSA id m19sm8425732qke.22.2019.09.03.00.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 00:38:42 -0700 (PDT) Date: Tue, 3 Sep 2019 03:38:37 -0400 From: "Michael S. Tsirkin" To: Stefano Garzarella Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Hajnoczi , "David S. Miller" , virtualization@lists.linux-foundation.org, Jason Wang , kvm@vger.kernel.org Subject: Re: [PATCH v4 2/5] vsock/virtio: reduce credit update messages Message-ID: <20190903033344-mutt-send-email-mst@kernel.org> References: <20190717113030.163499-1-sgarzare@redhat.com> <20190717113030.163499-3-sgarzare@redhat.com> <20190903003050-mutt-send-email-mst@kernel.org> <20190903073120.kefllalytkvidcvh@steredhat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190903073120.kefllalytkvidcvh@steredhat> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 03, 2019 at 09:31:20AM +0200, Stefano Garzarella wrote: > On Tue, Sep 03, 2019 at 12:38:02AM -0400, Michael S. Tsirkin wrote: > > On Wed, Jul 17, 2019 at 01:30:27PM +0200, Stefano Garzarella wrote: > > > In order to reduce the number of credit update messages, > > > we send them only when the space available seen by the > > > transmitter is less than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE. > > > > > > Signed-off-by: Stefano Garzarella > > > --- > > > include/linux/virtio_vsock.h | 1 + > > > net/vmw_vsock/virtio_transport_common.c | 16 +++++++++++++--- > > > 2 files changed, 14 insertions(+), 3 deletions(-) > > > > > > diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h > > > index 7d973903f52e..49fc9d20bc43 100644 > > > --- a/include/linux/virtio_vsock.h > > > +++ b/include/linux/virtio_vsock.h > > > @@ -41,6 +41,7 @@ struct virtio_vsock_sock { > > > > > > /* Protected by rx_lock */ > > > u32 fwd_cnt; > > > + u32 last_fwd_cnt; > > > u32 rx_bytes; > > > struct list_head rx_queue; > > > }; > > > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c > > > index 095221f94786..a85559d4d974 100644 > > > --- a/net/vmw_vsock/virtio_transport_common.c > > > +++ b/net/vmw_vsock/virtio_transport_common.c > > > @@ -211,6 +211,7 @@ static void virtio_transport_dec_rx_pkt(struct virtio_vsock_sock *vvs, > > > void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct virtio_vsock_pkt *pkt) > > > { > > > spin_lock_bh(&vvs->tx_lock); > > > + vvs->last_fwd_cnt = vvs->fwd_cnt; > > > pkt->hdr.fwd_cnt = cpu_to_le32(vvs->fwd_cnt); > > > pkt->hdr.buf_alloc = cpu_to_le32(vvs->buf_alloc); > > > spin_unlock_bh(&vvs->tx_lock); > > > @@ -261,6 +262,7 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, > > > struct virtio_vsock_sock *vvs = vsk->trans; > > > struct virtio_vsock_pkt *pkt; > > > size_t bytes, total = 0; > > > + u32 free_space; > > > int err = -EFAULT; > > > > > > spin_lock_bh(&vvs->rx_lock); > > > @@ -291,11 +293,19 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, > > > virtio_transport_free_pkt(pkt); > > > } > > > } > > > + > > > + free_space = vvs->buf_alloc - (vvs->fwd_cnt - vvs->last_fwd_cnt); > > > + > > > spin_unlock_bh(&vvs->rx_lock); > > > > > > - /* Send a credit pkt to peer */ > > > - virtio_transport_send_credit_update(vsk, VIRTIO_VSOCK_TYPE_STREAM, > > > - NULL); > > > + /* We send a credit update only when the space available seen > > > + * by the transmitter is less than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE > > > > This is just repeating what code does though. > > Please include the *reason* for the condition. > > E.g. here's a better comment: > > > > /* To reduce number of credit update messages, > > * don't update credits as long as lots of space is available. > > * Note: the limit chosen here is arbitrary. Setting the limit > > * 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. > > */ > > > > Yes, it is better, sorry for that. I'll try to avoid unnecessary comments, > explaining the reason for certain changes. > > Since this patch is already queued in net-next, should I send another > patch to fix the comment? > > Thanks, > Stefano I just sent a patch like that, pls ack it. -- MST