From: "Ammar Yasser" <aerosound161@gmail.com>
To: "David Gibson" <david@gibson.dropbear.id.au>,
"Ammar Yasser" <aerosound161@gmail.com>
Cc: passt-dev@passt.top, eperezma@redhat.com
Subject: Re: [RFC v3 4/8] virtio: Define the pasta vhost interface
Date: Sun, 16 Aug 2026 20:39:29 +0300 [thread overview]
Message-ID: <DKQJVS33DTA0.23SG2ARN7TLWQ@gmail.com> (raw)
In-Reply-To: <an0a4b4BkRPiKbNX@zatzit>
On Thu Aug 13, 2026 at 4:16 AM EEST, David Gibson wrote:
> On Wed, Aug 12, 2026 at 08:17:19PM +0300, Ammar Yasser wrote:
>> On Mon Aug 10, 2026 at 5:06 AM EEST, David Gibson wrote:
>> >>
>> >> /* Large enough for ~128 maximum size frames */
>> >> -#define PKT_BUF_BYTES (8UL << 20)
>> >> +#define PKT_BUF_BYTES ((8UL << 20) + 1536) /* 128 * sizeof(virtio_net_hdr_mrg_rxbuf) */
>> >
>> > I think the rationale for this change needs to be clearer (granted,
>> > the comment here beforehand is also kind of confusing). IIRC - and
>> > based on the "~" in the comment, I don't think there's a strict
>> > requirement that this can hold 128 full frames - that's just setting a
>> > reasonable sense of scale, and then a round number was picked near it:
>> > ~64kiB * ~64 ~= 8MiB
>> >
>> > So, I'm not sure if this change is necessary - if it really is, we
>> > need a clearer analysis of why.
>>
>> Because pkt_buf is now going to be the buffer where vhost guest->pasta
>> data but with the added size of the virtio_net_hdr_mrg_rxbuf for every
>> frame. So this is accounting for the worst case where the guest wants to
>> send a full 128 frames at maximum size at a time.
>
> Right, but that's not enough. AFAICT pkt_buf is sized to allow
> *roughly* 128 full packets, but it doesn't strictly have to be able to
> contain that many. If there's a reason it *must* have room for 128
> full frames with vhost-kernel, that needs to be pointed out
> explicitly.
Are you saying the size is not enough or the explanation is not ?
Also no, there's no explicit reason why it needs to have that many
packets in vhost-kernel. I saw that this was how pkt_buf was sized
before the vhost-kernel changes so i only added acounting for the virtio
net header
>> >> +#define VHOST_NDESCS (PKT_BUF_BYTES / 65520)
>> >
>> > I'm not sure 65520 is the right number here. That's the max MTU at
>> > the IP level, but the packet buffer will also hold the 14 byte L2
>> > header. I think you probably want one of the L2_MAX_LEN_* constants
>> > (or to define a new one for vhost-kernel).
>>
>> My line of reasoning here is that "we typically expect, in the majority
>> of cases for an ethernet frame to span a single descriptor". evident by
>> how we eventually consume descriptors as we return the pointer into the
>> pkt_buf past the virtio_net header as the beginning of an ethernet
>> header. and this buffer should handle 128 frames (from the definition
>> of PKT_BUF_BYTES) and so we want a denominator that yields a value as
>> close as possible to 128. Let me know if this isn't very sound. I will
>> investiagate the constants you mentioned anyways
>
> If the fundamental property you want is that you can fit 128
> descriptors, then you should just define NDESCS as 128, and derive the
> buffer size and other things from that. If the basic property you
> want is something else, define that first and the rest in terms of it.
Fair enough, can do that
next prev parent reply other threads:[~2026-08-16 17:39 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 13:21 [RFC v3 0/8] Add vhost-net kernel support to pasta Ammar Yasser
2026-08-02 13:21 ` [RFC v3 1/8] tap: Move the tap_hdr file to a separate file Ammar Yasser
2026-08-07 5:40 ` David Gibson
2026-08-02 13:21 ` [RFC v3 2/8] udp,tcp: Make protocol specific buffers public Ammar Yasser
2026-08-07 5:56 ` David Gibson
2026-08-12 16:29 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 3/8] conf: Add context fields, epoll types and the --vhost flag to pasta Ammar Yasser
2026-08-10 1:11 ` David Gibson
2026-08-12 16:36 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 4/8] virtio: Define the pasta vhost interface Ammar Yasser
2026-08-10 2:06 ` David Gibson
2026-08-12 17:17 ` Ammar Yasser
2026-08-13 1:16 ` David Gibson
2026-08-16 17:39 ` Ammar Yasser [this message]
2026-08-17 0:30 ` David Gibson
2026-08-02 13:21 ` [RFC v3 5/8] virtio: Implement the pasta vhost functions Ammar Yasser
2026-08-10 6:34 ` David Gibson
2026-08-12 17:57 ` Ammar Yasser
2026-08-13 1:26 ` David Gibson
2026-08-16 17:48 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 6/8] virtio: Implement pasta vhost acceleration guest->pasta path Ammar Yasser
2026-08-10 7:34 ` David Gibson
2026-08-12 18:17 ` Ammar Yasser
2026-08-13 1:35 ` David Gibson
2026-08-02 13:21 ` [RFC v3 7/8] pasta: Implement pasta vhost TX (pasta->guest) prerequisites Ammar Yasser
2026-08-10 9:01 ` David Gibson
2026-08-12 18:39 ` Ammar Yasser
2026-08-13 2:01 ` David Gibson
2026-08-16 17:55 ` Ammar Yasser
2026-08-02 13:21 ` [RFC v3 8/8] tap: Implement pasta vhost TX Ammar Yasser
2026-08-10 9:18 ` David Gibson
2026-08-12 18:45 ` Ammar Yasser
2026-08-13 2:09 ` David Gibson
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=DKQJVS33DTA0.23SG2ARN7TLWQ@gmail.com \
--to=aerosound161@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=eperezma@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).