Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1512875yba; Thu, 4 Apr 2019 12:17:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWfPZ0lFwfjIr5cOUVccS77C3nWl5DpoqAfyAinoJRKlmbuo/+TAGOiSkY6ensl95Z3XSs X-Received: by 2002:a63:5a47:: with SMTP id k7mr7626080pgm.174.1554405476455; Thu, 04 Apr 2019 12:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554405476; cv=none; d=google.com; s=arc-20160816; b=nMfBhuo8GQDFzlsbbDcFbscSJW5wIlsaIhLfelN1ZT7haOojRKSY8UmxA7T/Elo0tb epWJfT4kjURUczjxfRXEjwaHV4BCvEoNWQjV5fuw2Rtc8mJQzT5QjwZXxC+rRkohIkSJ R8uir6SCygg8eUHOJq1Ez0LRRPUg3CHnMuFGdCxarPmVD9E4R7aZ0eGcBQk3II9gsRUY Oe2YVE3UaIqivSmn38SDiZiHlH2/lucCE79I04oCLig47M032SJTGCA9GTRBpXR6F29l 2CkI+54RZhkCZ04L23cE7fC6qUWBZjtGoB2cYW8tLwzTPhfqKMnDmaxYils3Rc+t959J bNSg== 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:dkim-signature; bh=BqpfFvICUg1IPmvDH1zD8aD1L9qHqmlYKJ8+16JkwxA=; b=Ak5lzPPyfX9izSPWnwODY5eyjOJdEUukDuKpgluf1/DGZdtaucCN0YZeFSq0WrnjSX yYU1fXSRj3gDuLs0dEan/YXJCxm55XXH4+ZriZeCyn+WG848KO+mL2U3ljmI75TSOleZ GR1BCPqrmhDpWlqNSQBeRiICTHu0lnGI/rQuAwK1xVe219Rkqig9+J0pLOzfb/hMe0Gu uht8ef5/L/OQE26XEOyIl66MAL+fEBGIMxw0bFKmVfZDDGWbjotQMnZoaIFYE9XK5keZ J9XxDsfn29hhkB4KnHwm/meZCTN/rTvVAP6TLt/28Wp2j04lz6XHqGSPuLFWNnJsf7NH meew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Im6isl7r; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si17518244plw.242.2019.04.04.12.17.40; Thu, 04 Apr 2019 12:17:56 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Im6isl7r; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730248AbfDDTPn (ORCPT + 99 others); Thu, 4 Apr 2019 15:15:43 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54715 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730103AbfDDTPn (ORCPT ); Thu, 4 Apr 2019 15:15:43 -0400 Received: by mail-wm1-f66.google.com with SMTP id c1so4289634wml.4; Thu, 04 Apr 2019 12:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BqpfFvICUg1IPmvDH1zD8aD1L9qHqmlYKJ8+16JkwxA=; b=Im6isl7rDhepK7w97jdSjBFF8PkuilsscG5Ekmtqhq+/HKNo9nZzq5I+7oQwxv5N3h bzPf6bi2DWtl4vkumiMX+5xh5pLnFjo4eyGdX3TF8Xqlcnc8Ky+HDJ6VOgXcazsgujOF 2KZunFHIKND3x7eXsH97QRMm3mqWiXjyx6PHk8xQloLcTdeOFKyIev6gr1rWs1Gm/ZmV QZDGphHIi4QY6ZqO5OEPlv6CP7GoiHQxQLAGY71nXsO+y8rkvmwu7mvqSfynJrFPsSuZ bVVqRbMyFm3fS4ziK/g8bHGN1zqCvp7xM+W0XdIH8YsZ0sykV1Jffj9XaODTssLyPiim YNog== 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=BqpfFvICUg1IPmvDH1zD8aD1L9qHqmlYKJ8+16JkwxA=; b=iXuLnrLVBtjdiUR4rksSlwa1yaAu/fFy2YmDPETl1UChPsbutYyHBETz0yssfWqrfN 7k/Y2V0efn65A82KidxNmLBx3/GqWiCsvtGpnCDbBdzpX9LERd4H0syfNI4gfvVOwPNK bSnrVqhhU6q2+69k/ZT0nCoOBNtTVqEVjcPgeb6E1MS8HzC21GGZ9Iwotg7Ds8CcL4yM v9p/bVIbE9IAz+k4oUW0wic4ZleKdDzfDPBaEavG0ovwJArut4Lr5sR/G/SndHVGu0dm tHEMdCAJ9OR+PF5cF/z44ArNha9OKOd0MB40W06QxgLQczzjheXBaReINl/qA+l0XLE6 hRUg== X-Gm-Message-State: APjAAAW+EBKXsSxolAs8rY/eMckpl9QB9v9ZUNXyvbdyVy9ytkXnIyjJ 0TeU1dFsdQPetzvv2kbD+Bg= X-Received: by 2002:a1c:1b45:: with SMTP id b66mr5335460wmb.77.1554405341290; Thu, 04 Apr 2019 12:15:41 -0700 (PDT) Received: from localhost ([51.15.41.238]) by smtp.gmail.com with ESMTPSA id z8sm18068861wrh.80.2019.04.04.12.15.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2019 12:15:40 -0700 (PDT) Date: Thu, 4 Apr 2019 20:15:39 +0100 From: Stefan Hajnoczi To: Stefano Garzarella Cc: netdev@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" , Stefan Hajnoczi , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, "David S. Miller" Subject: Re: [PATCH RFC 1/4] vsock/virtio: reduce credit update messages Message-ID: <20190404191539.GB25152@stefanha-x1.localdomain> References: <20190404105838.101559-1-sgarzare@redhat.com> <20190404105838.101559-2-sgarzare@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aM3YZ0Iwxop3KEKx" Content-Disposition: inline In-Reply-To: <20190404105838.101559-2-sgarzare@redhat.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --aM3YZ0Iwxop3KEKx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 04, 2019 at 12:58:35PM +0200, Stefano Garzarella wrote: > @@ -256,6 +257,7 @@ virtio_transport_stream_do_dequeue(struct vsock_sock = *vsk, > struct virtio_vsock_sock *vvs =3D vsk->trans; > struct virtio_vsock_pkt *pkt; > size_t bytes, total =3D 0; > + s64 free_space; Why s64? buf_alloc, fwd_cnt, and last_fwd_cnt are all u32. fwd_cnt - last_fwd_cnt <=3D buf_alloc is always true. > int err =3D -EFAULT; > =20 > spin_lock_bh(&vvs->rx_lock); > @@ -288,9 +290,15 @@ virtio_transport_stream_do_dequeue(struct vsock_sock= *vsk, > } > spin_unlock_bh(&vvs->rx_lock); > =20 > - /* 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 > + */ > + free_space =3D vvs->buf_alloc - (vvs->fwd_cnt - vvs->last_fwd_cnt); Locking? These fields should be accessed under tx_lock. > + if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) { > + virtio_transport_send_credit_update(vsk, > + VIRTIO_VSOCK_TYPE_STREAM, > + NULL); > + } --aM3YZ0Iwxop3KEKx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJcplfbAAoJEJykq7OBq3PI2uYIALQfLRpQHKb7GaCRjoDssVSe XlSjQ47uP6LdmnzrkmFy2QtA0UCQS8fZdFbvu4wReh9dcDk+jQAno2Xzuwv6sTzu cJ+uknZzmMmZarWh3m4w5ooIM4p7GO8HFWbCr9Sq6nS9aAw1N1YpGjB6JvtAZJuE vIOHRa3rZ/aQ/Xil907cKLWyXwYMWEfeAnD+ujUr5zkyQyuUrYlck7YW9gPas3c+ ClvvF+uYnvq9tf1exel6NwPvnjmtG+1aTDtIuqrv0Af/QqryUuD64UDkybOHGRlZ 4rIsRIsRZHTsyleB/oJPANE/L0bNzDfCpxvyfSBps6b5bIR4rJ8AqvRrDE+82uI= =9/y/ -----END PGP SIGNATURE----- --aM3YZ0Iwxop3KEKx--