Re: [PATCH vhost 02/10] virtio_ring: packed: separate prepare code from virtuque_add_indirect_packed()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 20 Feb 2023 13:37:41 +0800, Jason Wang <jasowang@xxxxxxxxxx> wrote:
> On Tue, Feb 14, 2023 at 3:27 PM Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> wrote:
> >
> > Separating the logic of allocating indirect desc and checking queue
> > status to the upper layer function.
> >
> > The proposal of this is convenient to refactor virtqueue_add_packed()
> > for premapped.
> >
>
> Ok, so this is another hint that we should do the same thing for split.


Since split does not have an independent indirect function, both are different
here. Therefore, there will be no the same thing for split.

Thanks.


>
> Thanks
>
>
> > Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx>
> > ---
> >  drivers/virtio/virtio_ring.c | 29 ++++++++++++-----------------
> >  1 file changed, 12 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > index 560ee30d942c..42b1ff87518e 100644
> > --- a/drivers/virtio/virtio_ring.c
> > +++ b/drivers/virtio/virtio_ring.c
> > @@ -1330,25 +1330,14 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq,
> >                                          unsigned int out_sgs,
> >                                          unsigned int in_sgs,
> >                                          void *data,
> > -                                        gfp_t gfp)
> > +                                        struct vring_packed_desc *desc)
> >  {
> > -       struct vring_packed_desc *desc;
> >         struct scatterlist *sg;
> >         unsigned int i, n, err_idx;
> >         u16 head, id;
> >         dma_addr_t addr;
> >
> >         head = vq->packed.next_avail_idx;
> > -       desc = alloc_indirect_packed(total_sg, gfp);
> > -       if (!desc)
> > -               return -ENOMEM;
> > -
> > -       if (unlikely(vq->vq.num_free < 1)) {
> > -               pr_debug("Can't add buf len 1 - avail = 0\n");
> > -               kfree(desc);
> > -               END_USE(vq);
> > -               return -ENOSPC;
> > -       }
> >
> >         i = 0;
> >         id = vq->free_head;
> > @@ -1470,11 +1459,17 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
> >         BUG_ON(total_sg == 0);
> >
> >         if (virtqueue_use_indirect(vq, total_sg)) {
> > -               err = virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs,
> > -                                                   in_sgs, data, gfp);
> > -               if (err != -ENOMEM) {
> > -                       END_USE(vq);
> > -                       return err;
> > +               desc = alloc_indirect_packed(total_sg, gfp);
> > +               if (desc) {
> > +                       if (unlikely(vq->vq.num_free < 1)) {
> > +                               pr_debug("Can't add buf len 1 - avail = 0\n");
> > +                               kfree(desc);
> > +                               END_USE(vq);
> > +                               return -ENOSPC;
> > +                       }
> > +
> > +                       return virtqueue_add_indirect_packed(vq, sgs, total_sg, out_sgs,
> > +                                                            in_sgs, data, desc);
> >                 }
> >
> >                 /* fall back on direct */
> > --
> > 2.32.0.3.g01195cf9f
> >
>
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux