[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1649832776.947242-8-xuanzhuo@linux.alibaba.com>
Date: Wed, 13 Apr 2022 14:52:56 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: Jason Wang <jasowang@...hat.com>
Cc: Jeff Dike <jdike@...toit.com>, Richard Weinberger <richard@....at>,
Anton Ivanov <anton.ivanov@...bridgegreys.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Hans de Goede <hdegoede@...hat.com>,
Mark Gross <markgross@...nel.org>,
Vadim Pasternak <vadimp@...dia.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Cornelia Huck <cohuck@...hat.com>,
Halil Pasic <pasic@...ux.ibm.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Johannes Berg <johannes.berg@...el.com>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
linux-um@...ts.infradead.org, netdev@...r.kernel.org,
platform-driver-x86@...r.kernel.org,
linux-remoteproc@...r.kernel.org, linux-s390@...r.kernel.org,
kvm@...r.kernel.org, bpf@...r.kernel.org,
virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v9 06/32] virtio_ring: split: extract the logic of alloc queue
On Tue, 12 Apr 2022 11:22:33 +0800, Jason Wang <jasowang@...hat.com> wrote:
>
> 在 2022/4/6 上午11:43, Xuan Zhuo 写道:
> > Separate the logic of split to create vring queue.
> >
> > This feature is required for subsequent virtuqueue reset vring.
> >
> > Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
> > ---
> > drivers/virtio/virtio_ring.c | 53 ++++++++++++++++++++++++------------
> > 1 file changed, 36 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > index 33fddfb907a6..72d5ae063fa0 100644
> > --- a/drivers/virtio/virtio_ring.c
> > +++ b/drivers/virtio/virtio_ring.c
> > @@ -915,23 +915,15 @@ static void *virtqueue_detach_unused_buf_split(struct virtqueue *_vq)
> > return NULL;
> > }
> >
> > -static struct virtqueue *vring_create_virtqueue_split(
> > - unsigned int index,
> > - unsigned int num,
> > - unsigned int vring_align,
> > - struct virtio_device *vdev,
> > - bool weak_barriers,
> > - bool may_reduce_num,
> > - bool context,
> > - bool (*notify)(struct virtqueue *),
> > - void (*callback)(struct virtqueue *),
> > - const char *name)
> > +static void *vring_alloc_queue_split(struct virtio_device *vdev,
> > + dma_addr_t *dma_addr,
> > + u32 *n,
> > + unsigned int vring_align,
> > + bool weak_barriers,
>
>
> This is not used in this function.
The next version will fix it.
Thanks.
>
> Thanks
>
>
> > + bool may_reduce_num)
> > {
> > - struct virtqueue *vq;
> > void *queue = NULL;
> > - dma_addr_t dma_addr;
> > - size_t queue_size_in_bytes;
> > - struct vring vring;
> > + u32 num = *n;
> >
> > /* We assume num is a power of 2. */
> > if (num & (num - 1)) {
> > @@ -942,7 +934,7 @@ static struct virtqueue *vring_create_virtqueue_split(
> > /* TODO: allocate each queue chunk individually */
> > for (; num && vring_size(num, vring_align) > PAGE_SIZE; num /= 2) {
> > queue = vring_alloc_queue(vdev, vring_size(num, vring_align),
> > - &dma_addr,
> > + dma_addr,
> > GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
> > if (queue)
> > break;
> > @@ -956,11 +948,38 @@ static struct virtqueue *vring_create_virtqueue_split(
> > if (!queue) {
> > /* Try to get a single page. You are my only hope! */
> > queue = vring_alloc_queue(vdev, vring_size(num, vring_align),
> > - &dma_addr, GFP_KERNEL|__GFP_ZERO);
> > + dma_addr, GFP_KERNEL|__GFP_ZERO);
> > }
> > if (!queue)
> > return NULL;
> >
> > + *n = num;
> > + return queue;
> > +}
> > +
> > +static struct virtqueue *vring_create_virtqueue_split(
> > + unsigned int index,
> > + unsigned int num,
> > + unsigned int vring_align,
> > + struct virtio_device *vdev,
> > + bool weak_barriers,
> > + bool may_reduce_num,
> > + bool context,
> > + bool (*notify)(struct virtqueue *),
> > + void (*callback)(struct virtqueue *),
> > + const char *name)
> > +{
> > + size_t queue_size_in_bytes;
> > + struct virtqueue *vq;
> > + dma_addr_t dma_addr;
> > + struct vring vring;
> > + void *queue;
> > +
> > + queue = vring_alloc_queue_split(vdev, &dma_addr, &num, vring_align,
> > + weak_barriers, may_reduce_num);
> > + if (!queue)
> > + return NULL;
> > +
> > queue_size_in_bytes = vring_size(num, vring_align);
> > vring_init(&vring, num, queue, vring_align);
> >
>
Powered by blists - more mailing lists