public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v8 7/8] vhost-user: add vhost-user
Date: Thu, 14 Nov 2024 11:20:09 +0100	[thread overview]
Message-ID: <880fe7a3-4925-49a0-8253-e130f976039e@redhat.com> (raw)
In-Reply-To: <20241017021034.437f3757@elisabeth>

On 17/10/2024 02:10, Stefano Brivio wrote:
>> +		if (frame_size == 0)
>> +			first = &iov_vu[i + 1];
>> +
>> +		if (iov_vu[i + 1].iov_len > (size_t)len)
>> +			iov_vu[i + 1].iov_len = len;
>> +
>> +		len -= iov_vu[i + 1].iov_len;
>> +		iov_used++;
>> +
>> +		frame_size += iov_vu[i + 1].iov_len;
>> +		num_buffers++;
>> +
>> +		if (frame_size >= mss || len == 0 ||
>> +		    i + 1 == iov_cnt || !vu_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) {
>> +			if (i + 1 == iov_cnt)
>> +				check = NULL;
>> +
>> +			/* restore first iovec base: point to vnet header */
>> +			vu_set_vnethdr(vdev, first, num_buffers, l2_hdrlen);
>> +
>> +			tcp_vu_prepare(c, conn, first, frame_size, &check);
>> +			if (*c->pcap)  {
>> +				tcp_vu_update_check(tapside, first, num_buffers);
>> +				pcap_iov(first, num_buffers,
>> +					 sizeof(struct virtio_net_hdr_mrg_rxbuf));
>> +			}
>> +
>> +			conn->seq_to_tap += frame_size;
> We always increase this, even if, later...
> 
>> +
>> +			frame_size = 0;
>> +			num_buffers = 0;
>> +		}
>> +	}
>> +
>> +	/* release unused buffers */
>> +	vu_queue_rewind(vq, iov_cnt - iov_used);
>> +
>> +	/* send packets */
>> +	vu_flush(vdev, vq, elem, iov_used);
> we fail to send packets, that is, even if vu_queue_fill_by_index()
> returns early because (!vq->vring.avail).

vring.avail is a pointer to a structure. vring.avail is NULL if there is something wrong 
during the initialization. It's imported code, I think it's only a sanity check.
So in theory vu_flush() cannot fail.

> 
> We had this same issue on the non-vhost-user path until commit
> a469fc393fa1 ("tcp, tap: Don't increase tap-side sequence counter for
> dropped frames") (completely reworked with time). There, it was pretty
> bad with small (default) values for wmem_max and rmem_max.
> 
> Now, I_guess_ with vhost-user it won't be so easy to hit that, because
> virtqueue buffers are (altogether) bigger, so we can probably fix this
> later, but if it's not exceedingly complicated, we should consider
> fixing it now. If we hit something like that, the behaviour is pretty
> bad, with constant retransmissions and stalls.
> 
> The mapping between queued frames and connections is done in
> tcp_data_to_tap(), where tcp4_frame_conns[] and tcp6_frame_conns[]
> items are set to the current (highest) value of tcp4_payload_used and
> tcp6_payload_used.
> 
> Then, if we fail to transmit some frames, tcp_revert_seq() uses those
> arrays to revert the seq_to_tap values.
> 
> I guess you could make vu_queue_fill_by_index() return an error,
> propagate it, and make vu_flush() call something like tcp_revert_seq()
> in case.

Thanks,
Laurent


  parent reply	other threads:[~2024-11-14 10:20 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 12:28 [PATCH v8 0/8] Add vhost-user support to passt. (part 3) Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 1/8] packet: replace struct desc by struct iovec Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 2/8] vhost-user: introduce virtio API Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 3/8] vhost-user: introduce vhost-user API Laurent Vivier
2024-10-10 12:28 ` [PATCH v8 4/8] udp: Prepare udp.c to be shared with vhost-user Laurent Vivier
2024-10-14  4:29   ` David Gibson
2024-10-10 12:28 ` [PATCH v8 5/8] tcp: Export headers functions Laurent Vivier
2024-10-14  4:29   ` David Gibson
2024-10-10 12:29 ` [PATCH v8 6/8] passt: rename tap_sock_init() to tap_backend_init() Laurent Vivier
2024-10-14  4:30   ` David Gibson
2024-10-14 22:38   ` Stefano Brivio
2024-10-10 12:29 ` [PATCH v8 7/8] vhost-user: add vhost-user Laurent Vivier
2024-10-15  3:23   ` David Gibson
2024-10-16 10:07     ` Laurent Vivier
2024-10-16 16:26       ` Stefano Brivio
2024-10-15 19:54   ` Stefano Brivio
2024-10-16  0:41     ` David Gibson
2024-10-17  0:10       ` Stefano Brivio
2024-10-17 11:25         ` Stefano Brivio
2024-10-17 11:54           ` Laurent Vivier
2024-10-17 17:18           ` Laurent Vivier
2024-10-17 17:25             ` Laurent Vivier
2024-10-17 17:33             ` Stefano Brivio
2024-10-17 21:21               ` Stefano Brivio
2024-10-22 12:59         ` Laurent Vivier
2024-10-22 13:19           ` Stefano Brivio
2024-10-22 18:19             ` Stefano Brivio
2024-10-22 18:22               ` Stefano Brivio
2024-10-23 15:27           ` Laurent Vivier
2024-10-23 16:23             ` Stefano Brivio
2024-10-17  0:10   ` Stefano Brivio
2024-10-17  7:28     ` Laurent Vivier
2024-10-17  8:33       ` Stefano Brivio
2024-11-14 10:20     ` Laurent Vivier [this message]
2024-11-14 14:23       ` Stefano Brivio
2024-11-14 15:16         ` Laurent Vivier
2024-11-14 15:38           ` Stefano Brivio
2024-11-14 10:23     ` Laurent Vivier
2024-11-14 14:23       ` Stefano Brivio
2024-11-15  8:30         ` Laurent Vivier
2024-11-15 10:08           ` Stefano Brivio
2024-11-14 10:29     ` Laurent Vivier
2024-11-14 14:23       ` Stefano Brivio
2024-11-15 11:13         ` Laurent Vivier
2024-11-15 11:23           ` Stefano Brivio
2024-10-10 12:29 ` [PATCH v8 8/8] test: Add tests for passt in vhost-user mode Laurent Vivier
2024-10-15  3:40   ` David Gibson
2024-10-15 19:54   ` Stefano Brivio
2024-10-16  8:06     ` Laurent Vivier
2024-10-16  9:47       ` Stefano Brivio

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=880fe7a3-4925-49a0-8253-e130f976039e@redhat.com \
    --to=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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).