qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sahil <icegambit91@gmail.com>
To: Eugenio Perez Martin <eperezma@redhat.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: Fri, 02 Aug 2024 16:56:03 +0530	[thread overview]
Message-ID: <12491035.O9o76ZdvQC@valdaarhun> (raw)
In-Reply-To: <CAJaqyWd4Ts-JMofDeZ4Uv8Azdi3s_NaYmATd7ezJxwMG+HiPUw@mail.gmail.com>

Hi,

On Monday, July 29, 2024 1:51:27 PM GMT+5:30 Eugenio Perez Martin wrote:
> On Sun, Jul 28, 2024 at 7:37 PM Sahil <icegambit91@gmail.com> wrote:
> > [...]
> > > > +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?
> 

I tried refactoring this and have sent a new patch series. Please let me
know if I have missed something.

Thanks,
Sahil




  reply	other threads:[~2024-08-02 11:26 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
2024-08-02 11:26         ` Sahil [this message]
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=12491035.O9o76ZdvQC@valdaarhun \
    --to=icegambit91@gmail.com \
    --cc=eperezma@redhat.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).