From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MEDtWCzN; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id C7E1A5A027A for ; Mon, 28 Jul 2025 18:45:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753721157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MSp/+0j6TwxK3BBJUZ6BOg6Ynp9379gV6k+0rJSkydk=; b=MEDtWCzNGJCIywuA0/IkXZv+Xqgppbg/k7MQkHWVdWBRnS8Us0g9aeLEfcOzgiHBQg091Q EdA4hkhGoLX8dlekwgAYrZhxnWXmVk4/HcXNYijzIOzLIcOyc8DlaaatKdGdTupOdn4rYJ QtaHWb5NfMhGu3sqi70ExDLjxmgxKkc= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445-pzf0fYHINBGP2SkYhPbO9A-1; Mon, 28 Jul 2025 12:45:56 -0400 X-MC-Unique: pzf0fYHINBGP2SkYhPbO9A-1 X-Mimecast-MFC-AGG-ID: pzf0fYHINBGP2SkYhPbO9A_1753721155 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-235f77f86f6so48570445ad.2 for ; Mon, 28 Jul 2025 09:45:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753721155; x=1754325955; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MSp/+0j6TwxK3BBJUZ6BOg6Ynp9379gV6k+0rJSkydk=; b=PpbwDdGyv0DUznucOaAw5/auXFAlFNbE3HVjhFxoGZsbSWN2NRy4iWMaiRsljsAJ5m 3RMjPQ8bZnsiPa8ZKm4NoPgbDbvEZ+eSs/AE/EZsX/wjfWPsVEX0x6CIHpxNqyQyxyZD 2RvuzuSXQY/DHbFc1aSqqt1FXzBYo3EPvsaeCFg5Y58zux9V1UlLtVl/k2vy+du1dlMS kASQiCi+DfUfDug8fVQk3bZO+Efh+/XFNjT/IhzTo6cuNguw034j5HImNLQN1OG3rk3L yQczVZmVxyAc1XyeTSxBIbpAlPGnt9TVgI7R7olpPzAhHyikpy7ipMuzXbb2iscRmj2/ uInw== X-Gm-Message-State: AOJu0YzOdhJPcjp73bwrq5/q1cTeiyBehCx2iWVpmLWPnBkzL4nr1VzR NZGL+grvmJvmAix6mC1mEs3PnVHIjSu++xl4lzF96t1DWCVgfaU6lDiFEhdkqgw45yBGcRlpfTU q1QVW0Rfj7fX54b9nh8jjTJXlilzluff9+XFQFReqkMh6mSWocMI1A/Kdd88C65sAoVISPvg+Bp D4LnpwJcjC6+01afaiAbweqgREeXOL X-Gm-Gg: ASbGnctYXdKOcpWVMJPFr9XcMkglSROGMRbSWf2ruYkggQGy3hlyXZYE+LUL8rQpXUw l4BNLMjV26O0WP30MtUuvJg7CzMxyBgcF19sfestCmxqVD6+u22yKRuQiDpZ6DebN9JNhK7RirX +jOtjopCt3M5eIJJXrEpS3 X-Received: by 2002:a17:902:ea06:b0:237:d486:706a with SMTP id d9443c01a7336-23fb3179074mr169306175ad.48.1753721154987; Mon, 28 Jul 2025 09:45:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaXeCyLiFtufsipYIYH2UJHFrkW7fW7PQESDIoDghkSAMQxVFDvSSAkn7mLISLkAzjiJQdg1ubjGNoiNSxBx8= X-Received: by 2002:a17:902:ea06:b0:237:d486:706a with SMTP id d9443c01a7336-23fb3179074mr169305855ad.48.1753721154559; Mon, 28 Jul 2025 09:45:54 -0700 (PDT) MIME-Version: 1.0 References: <20250709174748.3514693-1-eperezma@redhat.com> <20250709174748.3514693-9-eperezma@redhat.com> In-Reply-To: From: Eugenio Perez Martin Date: Mon, 28 Jul 2025 18:45:18 +0200 X-Gm-Features: Ac12FXyDEZfUuPHwzosvMpIVUrGBrv4rvsnzmWfivQEc-cSVPI9POaKbzDLL-Hw Message-ID: Subject: Re: [RFC v2 08/11] tap: add tap_free_old_xmit To: David Gibson X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2bPusGs_6fiJtsp7EKxYuPQ1MPHgpbAKAE6iAt9DZfg_1753721155 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: P4RGXK54NAGWXOMYXNIWGDCKDMIL6AG6 X-Message-ID-Hash: P4RGXK54NAGWXOMYXNIWGDCKDMIL6AG6 X-MailFrom: eperezma@redhat.com 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: On Thu, Jul 24, 2025 at 2:51=E2=80=AFAM David Gibson wrote: > > On Wed, Jul 09, 2025 at 07:47:45PM +0200, Eugenio P=C3=A9rez 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. > > > > Let's start by following the same pattern as in tap write(2): wait unti= l > > pasta can override the buffers. We can add async cleaning on top. > > > > Signed-off-by: Eugenio P=C3=A9rez > > --- > > tap.c | 26 ++++++++++++++++++++++++++ > > tap.h | 1 + > > 2 files changed, 27 insertions(+) > > > > 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; > > > > + /* Last used_idx in the used ring. > > + * Duplicate here allows to check for proper vhost usage, and avo= id > > + * false sharing between pasta and kernel. */ > > + uint16_t shadow_used_idx; > > + > > /* Last used idx processed */ > > uint16_t last_used_idx; > > > > @@ -467,6 +472,27 @@ static void vhost_kick(struct vring_used *used, in= t kick_fd) { > > eventfd_write(kick_fd, 1); > > } > > > > +/* 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. > Documenting for the next version. > > +{ > > + 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 uint= 16_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_NDESC= S]; > > + vqs[1].last_used_idx++; > > + r++; > > + } > > +} > > > > /** > > * 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 *ds= t, > > const void *in, size_t l4len); > > void tap_send_single(const struct ctx *c, const void *data, size_t l2l= en, 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, > > -- > 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 wa= y > | around. > http://www.ozlabs.org/~dgibson