Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2686732yba; Mon, 8 Apr 2019 02:27:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwp3CNL6tkXxTCyCoJFmACBAseezZI/Sp6cwRGGjnR6mYfulCbXHikNkmofoLb9+7SHTdYP X-Received: by 2002:a65:6201:: with SMTP id d1mr26375889pgv.28.1554715665109; Mon, 08 Apr 2019 02:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554715665; cv=none; d=google.com; s=arc-20160816; b=ifSsfvHNeVbRe/xIr4+GFUVuvxRzaeZoOmQy8gzeI7j2Y/F5gF0SH4scZUBQ4Bts6S u+LjuKsbtU2Uxnb7eWjXhvGTNthCeU5f1UjbUeLXy760XdMpun0208XWonTQWxGWjVM2 Ez05zD0tqvU/SgrbpXLlJqe0cUSeUwnhduqnhCgq3+A3OroiCeVQ7jXpSPWPd4IFVv3b IDLXMel2yMkyRv8Pwr7ttjKMNh71AlzIcDHhKPLo7kHaNsdHL4HQJP/Dcvu8lnH9knlc o3uHRTG6/+jnbR6jaTUFKu2LbzWJb1UWsaGhQJKekLoDsirvxuQ7/LrwqqEwiATSu9Xw kzHg== 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=Zb+yq2KFOsjmav7CAss/Y8jWgCaxEQTjz0ybwumKZGs=; b=qVXfSX6fyXWwqgi/8J/gLtFGRdKtdzchvO2DSfEZw5K83kX/dq2p7vmEwghGJklwmh /TXaDSnEaiHo3BKa62hSJQtOyISQeAmWfepW+h0rab82itxGYepEASzFmJy43oN2PTz+ reOjG8i592TFch7QQwYlD7YbfSJxso0Ku2BqnRGJzmZ/o+enIf6ZHmK66v3DgaOB0zCY EfWgHcXkZi2jyyOpZjaTCINELas8ndtH8OWw2XoKv80eD0XnSumtxcQ10NETOx27MFjO MD6k4gccNqUGxDt4OGri4rVPhCmUmt/jo1Nxhm0aLXIPsJusRUIyJgc12qw9UUC+C6WW BGEQ== 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 x4si26002994plo.203.2019.04.08.02.27.29; Mon, 08 Apr 2019 02:27:45 -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 S1726554AbfDHJZo (ORCPT + 99 others); Mon, 8 Apr 2019 05:25:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58920 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbfDHJZn (ORCPT ); Mon, 8 Apr 2019 05:25:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9754B308FC5E; Mon, 8 Apr 2019 09:25:43 +0000 (UTC) Received: from localhost (ovpn-116-217.ams2.redhat.com [10.36.116.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 004775D9C9; Mon, 8 Apr 2019 09:25:40 +0000 (UTC) Date: Mon, 8 Apr 2019 10:25:39 +0100 From: Stefan Hajnoczi To: Stefano Garzarella Cc: Stefan Hajnoczi , netdev@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" , 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: <20190408092539.GN15001@stefanha-x1.localdomain> References: <20190404105838.101559-1-sgarzare@redhat.com> <20190404105838.101559-2-sgarzare@redhat.com> <20190404191539.GB25152@stefanha-x1.localdomain> <20190405081648.2zflr7gxknk4q3a2@steredhat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="K4LMwn8CgX2KMboP" Content-Disposition: inline In-Reply-To: <20190405081648.2zflr7gxknk4q3a2@steredhat> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 08 Apr 2019 09:25:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --K4LMwn8CgX2KMboP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 05, 2019 at 10:16:48AM +0200, Stefano Garzarella wrote: > On Thu, Apr 04, 2019 at 08:15:39PM +0100, Stefan Hajnoczi wrote: > > On Thu, Apr 04, 2019 at 12:58:35PM +0200, Stefano Garzarella wrote: > > > 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); > >=20 > > Locking? These fields should be accessed under tx_lock. > >=20 >=20 > Yes, we need a lock, but looking in the code, vvs->fwd_cnd is written > taking rx_lock (virtio_transport_dec_rx_pkt) and it is read with the > tx_lock (virtio_transport_inc_tx_pkt). >=20 > Maybe we should use another spin_lock shared between RX and TX for those > fields or use atomic variables. >=20 > What do you suggest? Or make vvs->fwd_cnt atomic if it's the only field that needs to be accessed in this manner. Stefan --K4LMwn8CgX2KMboP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJcqxOTAAoJEJykq7OBq3PIZMYH/1TEHAKZjxIg1G2ajVhnFTbZ OFodA0ipnYIhsKDvhulux8zPhKa/dHkxBcWAKyBmMHdQ7CuwGAGSmXl8+wvQJt91 AGkSXajUCMjW7ZBL0BLGtapphp/Rjam/9udW9YjTPHiOfOgc55h7oAHmNatTSDFF o9vRzFlJnqvAOA+06XB4ss3hALFebZjF50+c+yk/2d6UiMLADwjjqDANmJ9e8Vbl W4nTbFwpdLRkMn+VU8MtdJqFk+rvgvPPBRARV9wHVWS8CET8wJseU3zgDfTlajK9 /22u/jzh++RQiHJ4nExEj9o93xWEatPblEPOmhvgR633SOjouPAeAwkDQFi9gRA= =hXkx -----END PGP SIGNATURE----- --K4LMwn8CgX2KMboP--