Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1609909ybe; Tue, 3 Sep 2019 00:32:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAro1QyeY6dz4GDCsLiZpCjozwidGd0wgteEVfMrp7rZHYyDle7XUoHgz+8C8tv5Mjg2vS X-Received: by 2002:a17:90a:fe0e:: with SMTP id ck14mr17183947pjb.78.1567495953249; Tue, 03 Sep 2019 00:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567495953; cv=none; d=google.com; s=arc-20160816; b=LJm3fw5g3GwWyN7HjOVLJTJtCdk2bsmsLY/0HfjmcEzJCqstBuvkTRt+em6RQsClBk kZFxa6f2ZY81s5cDvBFNYnnp3ozvOe5oI+BGNpIsPC+i+1k1czheRYzxuqt0NPhDZigv 8uYslnZsgSjbpZW+Xtadzu9oqbnUs3tl/Gfq+C/dXPG2d7ip6t+gZ79Ymnc3QK8YzLiM 1wGPy9F2F7a5ejwQwMJX1NlNv3KLc2WXOVsetpphPpdSxi71pRr+0Ko8JzbLEiV+Swht TWOhTFHO3hIrkJGHE2O+JooaoYhK1UHH3ydrJNO99YKkIhDm23LXmoP3UNBA4HJPmUe7 z8Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vIdlVo3wzaAg7+E51hvuCmhSjy3lqZ2GvkawXNng+DY=; b=wqC7rJldkO6BG5VT3jxYuK9JkVL3Ow+OdOkESQ2xRr2TmSXkI1+kJ7LssMwbBDjMh6 46l7CDcXYyz6l0hcphb2AEHuXOWiyQRQuQEclGNK+170/tpR9HCsDiOyhod112YHowZv iUIoCPj4pPOZSB1bVlduiPF5nrQFOSeL07ivcyR0PchloxKMSk3wrhzRWUcKi2zxwXm3 l3t1Vabsp+8f/oGprNtcfPXj/cbXm0zQjn4Sb8CEDMaq4nDmqRsPhTT8/4xhWXPPNYJQ glNjZiCkzBeSm4tjQoz/p1wEpv1rvjpU6hMGYDz4m8VeGSm8p/7jwsOEWKIFPfZGTzbL jxNA== 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 h1si4486567pje.44.2019.09.03.00.32.17; Tue, 03 Sep 2019 00:32:33 -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 S1727894AbfICHb0 (ORCPT + 99 others); Tue, 3 Sep 2019 03:31:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37262 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727505AbfICHb0 (ORCPT ); Tue, 3 Sep 2019 03:31:26 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (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 D3047C04BD33 for ; Tue, 3 Sep 2019 07:31:25 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id n3so840367wmf.3 for ; Tue, 03 Sep 2019 00:31:25 -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:user-agent; bh=vIdlVo3wzaAg7+E51hvuCmhSjy3lqZ2GvkawXNng+DY=; b=Gp1ZY1GPi2r4FXuvgTjI6sPeas/mW3zSSr5QzyeHCkLG2y3/IMeKf153TqvusnTCLb bp4yVRtNovxC962MhUzjUphIC53gR80rNNnRL+VRc3H2vrvL8SfJoHjoLVIWHJlPntzp 2lnU03VI8mH0ynEqYbgVipwWh+DtgHCbxMwmnC8ObKGEy+dJawGj7gdjqAGVTa75APlU UydsxI16CFzT0Cgk3gZSoCeSvBqGByxBHTzhH6H2aDdevaB9tsuXwY+Lv6Hppitwlq39 niLj7Fs3YLTrShBsLun2Fiy9jJbs/tc1zICuxBUupjBn8YS7MOyLunmNolsHVIE5hzvn d4Og== X-Gm-Message-State: APjAAAXI60TFzjq4YuqjwCgS5a6lrDzK7vnaC79ZwDTLyhvNJ0+/iokU pGamw7DXqlp8ly+vxAaeEh8rRwiVW0cwLd8Kior8JJgvPmcPUQ0dHV+6HTH0OuedgwLyX2rm/Vs 0QQp7yUfVVFAnq1U0BPHCMXSr X-Received: by 2002:adf:8043:: with SMTP id 61mr35027591wrk.115.1567495884505; Tue, 03 Sep 2019 00:31:24 -0700 (PDT) X-Received: by 2002:adf:8043:: with SMTP id 61mr35027562wrk.115.1567495884199; Tue, 03 Sep 2019 00:31:24 -0700 (PDT) Received: from steredhat (host170-61-dynamic.36-79-r.retail.telecomitalia.it. [79.36.61.170]) by smtp.gmail.com with ESMTPSA id v8sm34676506wra.79.2019.09.03.00.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 00:31:23 -0700 (PDT) Date: Tue, 3 Sep 2019 09:31:20 +0200 From: Stefano Garzarella To: "Michael S. Tsirkin" 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: <20190903073120.kefllalytkvidcvh@steredhat> References: <20190717113030.163499-1-sgarzare@redhat.com> <20190717113030.163499-3-sgarzare@redhat.com> <20190903003050-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190903003050-mutt-send-email-mst@kernel.org> User-Agent: NeoMutt/20180716 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 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