public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Eugenio Perez Martin <eperezma@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top, jasowang@redhat.com
Subject: Re: [RFC v2 08/11] tap: add tap_free_old_xmit
Date: Mon, 28 Jul 2025 18:45:18 +0200	[thread overview]
Message-ID: <CAJaqyWfnXer2QM2ANyH2GEgzRmUpd2Of_2MPRJHMV7bHP6njuQ@mail.gmail.com> (raw)
In-Reply-To: <aIF_Ipj5YQVyNqVt@zatzit>

On Thu, Jul 24, 2025 at 2:51 AM David Gibson
<david@gibson.dropbear.id.au> wrote:
>
> On Wed, Jul 09, 2025 at 07:47:45PM +0200, Eugenio Pérez 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 until
> > pasta can override the buffers.  We can add async cleaning on top.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> >  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 avoid
> > +      * 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, int kick_fd) {
> >               eventfd_write(kick_fd, 1);
> >  }
> >
> > +/* n = 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 = 0;
> > +
> > +     while (r < n) {
> > +             uint16_t used_idx = vqs[1].last_used_idx;
> > +             if (vqs[1].shadow_used_idx == used_idx) {
> > +                    vqs[1].shadow_used_idx = le16toh(*(volatile uint16_t*)&vring_used_1.used.idx);
> > +
> > +                    if (vqs[1].shadow_used_idx == used_idx)
> > +                            continue;
> > +             }
> > +
> > +             /* assert in-order */
> > +             assert(vring_used_1.used.ring[used_idx % VHOST_NDESCS].id == vring_avail_1.avail.ring[used_idx % VHOST_NDESCS]);
> > +             vqs[1].num_free += vqs[1].ndescs[used_idx % VHOST_NDESCS];
> > +             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 *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,
>
> --
> 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


  reply	other threads:[~2025-07-28 16:45 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 17:47 [RFC v2 00/11] Add vhost-net kernel support Eugenio Pérez
2025-07-09 17:47 ` [RFC v2 01/11] tap: implement vhost_call_cb Eugenio Pérez
2025-07-23  6:56   ` David Gibson
2025-07-28 16:33     ` Eugenio Perez Martin
2025-07-29  0:11       ` David Gibson
2025-07-09 17:47 ` [RFC v2 02/11] tap: add die() on vhost error Eugenio Pérez
2025-07-23  6:58   ` David Gibson
2025-07-09 17:47 ` [RFC v2 03/11] tap: replace tx tap hdr with virtio_nethdr_mrg_rxbuf Eugenio Pérez
2025-07-24  0:17   ` David Gibson
2025-07-28 16:37     ` Eugenio Perez Martin
2025-07-09 17:47 ` [RFC v2 04/11] tcp: export memory regions to vhost Eugenio Pérez
2025-07-23  7:06   ` David Gibson
2025-07-28 16:41     ` Eugenio Perez Martin
2025-07-29  0:25       ` David Gibson
2025-07-09 17:47 ` [RFC v2 05/11] virtio: Fill .next in tx queue Eugenio Pérez
2025-07-23  7:07   ` David Gibson
2025-07-28 16:44     ` Eugenio Perez Martin
2025-07-09 17:47 ` [RFC v2 06/11] tap: move static iov_sock to tcp_buf_data_from_sock Eugenio Pérez
2025-07-23  7:09   ` David Gibson
2025-07-28 16:43     ` Eugenio Perez Martin
2025-07-29  0:28       ` David Gibson
2025-07-09 17:47 ` [RFC v2 07/11] tap: support tx through vhost Eugenio Pérez
2025-07-24  0:24   ` David Gibson
2025-07-24 14:30     ` Stefano Brivio
2025-07-25  0:23       ` David Gibson
2025-07-09 17:47 ` [RFC v2 08/11] tap: add tap_free_old_xmit Eugenio Pérez
2025-07-24  0:32   ` David Gibson
2025-07-28 16:45     ` Eugenio Perez Martin [this message]
2025-07-09 17:47 ` [RFC v2 09/11] tcp: start conversion to circular buffer Eugenio Pérez
2025-07-24  1:03   ` David Gibson
2025-07-28 16:55     ` Eugenio Perez Martin
2025-07-29  0:30       ` David Gibson
2025-07-09 17:47 ` [RFC v2 10/11] tap: add poll(2) to used_idx Eugenio Pérez
2025-07-24  1:20   ` David Gibson
2025-07-28 17:03     ` Eugenio Perez Martin
2025-07-29  0:32       ` David Gibson
2025-07-29  7:04         ` Eugenio Perez Martin
2025-07-30  0:32           ` David Gibson
2025-07-09 17:47 ` [RFC v2 11/11] tcp_buf: adding TCP tx circular buffer Eugenio Pérez
2025-07-24  1:33   ` David Gibson
2025-07-28 17:04     ` Eugenio Perez Martin
2025-07-10  9:46 ` [RFC v2 00/11] Add vhost-net kernel support Eugenio Perez Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJaqyWfnXer2QM2ANyH2GEgzRmUpd2Of_2MPRJHMV7bHP6njuQ@mail.gmail.com \
    --to=eperezma@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=jasowang@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).