From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202506 header.b=mupRchZj; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id B586F5A0271 for ; Thu, 24 Jul 2025 02:51:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202506; t=1753318097; bh=4Xj+/Q+9/mfYhxt6DWyrst6anOz6XiPU90jJSMirba4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mupRchZjGOUb1q/ykaps4jAOx9byZ52oV2UTexKlOvlE9U/4tHUZ5NIztc4LTZY5B 05rkMZeKa8id40PT80Eywb4sTwzf5DrMueLZ9zSpfRhNHQl6yB5I+m7nZMlViKpS4n ACaCMWVm+fQWUo02VffDzfcv0HCTJTyPLur/e7hpGJssHvD0PO5ifv3vMFXFCJBHQQ KxQ5K5eauno7VIN815DK4F2JXUdGMVh3/BuwT+yA5tF//Fc2UCOPlX0xBEoEHzpXP2 rs+YH2iva9QDg3upZ7Cca2KhkoOIgqS9bSsi0kqWDcBkWXKokjs+RPacQdVXqo6ukg 2SpoiF+A8+ybw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4bnXRj2QrYz4xSQ; Thu, 24 Jul 2025 10:48:17 +1000 (AEST) Date: Thu, 24 Jul 2025 10:32:34 +1000 From: David Gibson To: Eugenio =?iso-8859-1?Q?P=E9rez?= Subject: Re: [RFC v2 08/11] tap: add tap_free_old_xmit Message-ID: References: <20250709174748.3514693-1-eperezma@redhat.com> <20250709174748.3514693-9-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w+ygBZVPovfRyeEA" Content-Disposition: inline In-Reply-To: <20250709174748.3514693-9-eperezma@redhat.com> Message-ID-Hash: W4BXEQJBZQJJ3RDJP35FBU74CUZJHPDX X-Message-ID-Hash: W4BXEQJBZQJJ3RDJP35FBU74CUZJHPDX X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, jasowang@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --w+ygBZVPovfRyeEA Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 09, 2025 at 07:47:45PM +0200, Eugenio P=E9rez wrote: > As pasta cannot modify the TCP sent buffers until vhost-kernel does not > use them anymore, we need a way to report the caller the buffers that > can be overriden. >=20 > Let's start by following the same pattern as in tap write(2): wait until > pasta can override the buffers. We can add async cleaning on top. >=20 > Signed-off-by: Eugenio P=E9rez > --- > tap.c | 26 ++++++++++++++++++++++++++ > tap.h | 1 + > 2 files changed, 27 insertions(+) >=20 > diff --git a/tap.c b/tap.c > index 7ccac86..55357e3 100644 > --- a/tap.c > +++ b/tap.c > @@ -128,6 +128,11 @@ static struct { > /* Number of free descriptors */ > uint16_t num_free; > =20 > + /* Last used_idx in the used ring. > + * Duplicate here allows to check for proper vhost usage, and avoid > + * false sharing between pasta and kernel. */ > + uint16_t shadow_used_idx; > + > /* Last used idx processed */ > uint16_t last_used_idx; > =20 > @@ -467,6 +472,27 @@ static void vhost_kick(struct vring_used *used, int = kick_fd) { > eventfd_write(kick_fd, 1); > } > =20 > +/* n =3D target */ > +void tap_free_old_xmit(size_t n) This function is introduced without either a caller or a descriptive comment. That makes it pretty hard to review - I'm not sure what it is supposed to be doing. > +{ > + size_t r =3D 0; > + > + while (r < n) { > + uint16_t used_idx =3D vqs[1].last_used_idx; > + if (vqs[1].shadow_used_idx =3D=3D used_idx) { > + vqs[1].shadow_used_idx =3D le16toh(*(volatile uint16_t*)&vring_= used_1.used.idx); > + > + if (vqs[1].shadow_used_idx =3D=3D used_idx) > + continue; > + } > + > + /* assert in-order */ > + assert(vring_used_1.used.ring[used_idx % VHOST_NDESCS].id =3D=3D vring= _avail_1.avail.ring[used_idx % VHOST_NDESCS]); > + vqs[1].num_free +=3D vqs[1].ndescs[used_idx % VHOST_NDESCS]; > + vqs[1].last_used_idx++; > + r++; > + } > +} > =20 > /** > * tap_send_frames_vhost() - Send multiple frames to the pasta tap > diff --git a/tap.h b/tap.h > index e924dfb..7ca0fb0 100644 > --- a/tap.h > +++ b/tap.h > @@ -112,6 +112,7 @@ void tap_icmp6_send(const struct ctx *c, > const struct in6_addr *src, const struct in6_addr *dst, > const void *in, size_t l4len); > void tap_send_single(const struct ctx *c, const void *data, size_t l2len= , bool vhost); > +void tap_free_old_xmit(size_t n); > size_t tap_send_frames(const struct ctx *c, const struct iovec *iov, > size_t bufs_per_frame, size_t nframes, bool vhost); > void eth_update_mac(struct ethhdr *eh, --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --w+ygBZVPovfRyeEA Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiBfyEACgkQzQJF27ox 2GeTVA/7BzMMJDdWAN9J/F0MUlzscBvKWGRdYc7Kd+WRjAXcr20Fdw48WmwbfQzO eN4AWku605L2yrs9FtcX2Ea679eSQLyeq7JWGnwp2x/sKWAZbSo3QIk3pdqLYC/t jpRy/8t89tkbl1Pfo2qMIcVP1KskgASjbaqiN62EmekmlDjG+caqWIUBiFhsZVU3 ydUn+jhLc8p/q3FFgMFgfee2SGIZW3SNJZp8MRL7sUn6IMVOaFz2YIxETyBuNy8a 0z8NmUofW8CVl64MF8idbC+vLFpZwO/CPcQeOIFNFq/5Pcxn+4CNIq3yw1Mb010U 4JFzGnsxOh9BopWvLnIrlYTX6zuMgKkCC4sBs5/LqCTB6iMU90/prc2LByyUF4Wb 4D9f1czCj/9umTNbdQZPkMSzUMQ0pA/xBCGBLnWeSdp/YiZzb5SYA3PyTtpCLET3 /3z+od3fuW5Sw8w6ujmBNg7oeJqpgTmPPZV3aQ9XAdA9hVWadNYSnishteAgRNmh qpj1KPMatpTgsSFYeBrjHuJ6R7gaw+7jb+dtAdvzK98Oo+jjnMk/KgqYlc3usf7V I8oVzXvD8j/t6ER5pezk2A/DBkCBWDsVec6ZD2bEdphgjCzJfgdCKVTHQyHe15c1 aVU5260T9GFc18yVpCKc5u5n1uR2In76sucM58am2ldSz1nmbcc= =Ht2i -----END PGP SIGNATURE----- --w+ygBZVPovfRyeEA--