From: Eugenio Perez Martin <eperezma@redhat.com>
To: Sahil <icegambit91@gmail.com>
Cc: sgarzare@redhat.com, mst@redhat.com, qemu-devel@nongnu.org,
Sahil Siddiq <sahilcdq@proton.me>
Subject: Re: [RFC v2 1/3] vhost: Introduce packed vq and add buffer elements
Date: Mon, 29 Jul 2024 10:21:27 +0200 [thread overview]
Message-ID: <CAJaqyWd4Ts-JMofDeZ4Uv8Azdi3s_NaYmATd7ezJxwMG+HiPUw@mail.gmail.com> (raw)
In-Reply-To: <2957475.e9J7NaK4W3@valdaarhun>
On Sun, Jul 28, 2024 at 7:37 PM Sahil <icegambit91@gmail.com> wrote:
>
> Hi,
>
> On Friday, July 26, 2024 7:18:28 PM GMT+5:30 Eugenio Perez Martin wrote:
> > On Fri, Jul 26, 2024 at 11:58 AM Sahil Siddiq <icegambit91@gmail.com> wrote:
> > > This is the first patch in a series to add support for packed
> > > virtqueues in vhost_shadow_virtqueue. This patch implements the
> > > insertion of available buffers in the descriptor area. It takes
> > > into account descriptor chains, but does not consider indirect
> > > descriptors.
> > >
> > > Signed-off-by: Sahil Siddiq <sahilcdq@proton.me>
> > > ---
> > > Changes v1 -> v2:
> > > * Split commit from RFC v1 into two commits.
> > > * vhost-shadow-virtqueue.c
> > >
> > > (vhost_svq_add_packed):
> > > - Merge with "vhost_svq_vring_write_descs_packed()"
> > > - Remove "num == 0" check
> > >
> > > hw/virtio/vhost-shadow-virtqueue.c | 93 +++++++++++++++++++++++++++++-
> > > 1 file changed, 92 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/hw/virtio/vhost-shadow-virtqueue.c
> > > b/hw/virtio/vhost-shadow-virtqueue.c index fc5f408f77..c7b7e0c477 100644
> > > --- a/hw/virtio/vhost-shadow-virtqueue.c
> > > +++ b/hw/virtio/vhost-shadow-virtqueue.c
> > > @@ -217,6 +217,91 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue *svq,
> > > return true;
> > >
> > > }
> > >
> > > +static bool vhost_svq_add_packed(VhostShadowVirtqueue *svq,
> > > + const struct iovec *out_sg, size_t out_num,
> > > + const struct iovec *in_sg, size_t in_num,
> > > + unsigned *head)
> > > +{
> > > + bool ok;
> > > + uint16_t head_flags = 0;
> > > + g_autofree hwaddr *sgs = g_new(hwaddr, out_num + in_num);
> > > +
> > > + *head = svq->vring_packed.next_avail_idx;
> > > +
> > > + /* We need some descriptors here */
> > > + if (unlikely(!out_num && !in_num)) {
> > > + qemu_log_mask(LOG_GUEST_ERROR,
> > > + "Guest provided element with no descriptors");
> > > + return false;
> > > + }
> > > +
> > > + uint16_t id, curr, i;
> > > + unsigned n;
> > > + struct vring_packed_desc *descs = svq->vring_packed.vring.desc;
> > > +
> > > + i = *head;
> > > + id = svq->free_head;
> > > + curr = id;
> > > +
> > > + size_t num = out_num + in_num;
> > > +
> > > + ok = vhost_svq_translate_addr(svq, sgs, out_sg, out_num);
> > > + if (unlikely(!ok)) {
> > > + return false;
> > > + }
> > > +
> > > + ok = vhost_svq_translate_addr(svq, sgs + out_num, in_sg, in_num);
> > > + if (unlikely(!ok)) {
> > > + return false;
> > > + }
> > > +
> >
> > (sorry I missed this from the RFC v1) I think all of the above should
> > be in the caller, isn't it? It is duplicated with split.
>
> I don't think this will be straightforward. While they perform the same logical
> step in both cases, their implementation is a little different. For example, the
> "sgs" pointer is created a little differently in both cases.
Do you mean because MAX() vs in_num+out_num? It is ok to convert both
to the latter.
> The parameters to
> "vhost_svq_translate_addr" is also a little different. I think if they are moved to
> the caller, they will be in both "svq->is_packed" branches (in "vhost_svq_add").
>
I don't see any difference apart from calling it with in and out sgs
separately or calling it for all of the array, am I missing something?
> > Also, declarations should be at the beginning of blocks per QEMU
> > coding style [1].
>
> Sorry, I missed this. I'll rectify this.
>
No worries!
You can run scripts/checkpatch.pl in QEMU for the next series, it
should catch many of these small issues.
Thanks!
next prev parent reply other threads:[~2024-07-29 8:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 9:58 [RFC v2 0/3] Add packed virtqueue to shadow virtqueue Sahil Siddiq
2024-07-26 9:58 ` [RFC v2 1/3] vhost: Introduce packed vq and add buffer elements Sahil Siddiq
2024-07-26 13:48 ` Eugenio Perez Martin
2024-07-28 17:37 ` Sahil
2024-07-29 8:21 ` Eugenio Perez Martin [this message]
2024-08-02 11:26 ` Sahil
2024-07-26 9:58 ` [RFC v2 2/3] vhost: Data structure changes to support packed vqs Sahil Siddiq
2024-07-26 9:58 ` [RFC v2 3/3] vhost: Allocate memory for packed vring Sahil Siddiq
2024-07-26 14:28 ` Eugenio Perez Martin
2024-07-28 13:41 ` Sahil
2024-07-26 13:40 ` [RFC v2 0/3] Add packed virtqueue to shadow virtqueue Eugenio Perez Martin
2024-07-26 17:11 ` Sahil
2024-07-26 18:25 ` Eugenio Perez Martin
2024-07-28 16:42 ` Sahil
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=CAJaqyWd4Ts-JMofDeZ4Uv8Azdi3s_NaYmATd7ezJxwMG+HiPUw@mail.gmail.com \
--to=eperezma@redhat.com \
--cc=icegambit91@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sahilcdq@proton.me \
--cc=sgarzare@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.
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 NNTP newsgroup(s).