lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220928000342-mutt-send-email-mst@kernel.org>
Date:   Wed, 28 Sep 2022 00:04:45 -0400
From:   "Michael S. Tsirkin" <mst@...hat.com>
To:     Bo Liu (刘波)-浪潮信息 
        <liubo03@...pur.com>
Cc:     "jasowang@...hat.com" <jasowang@...hat.com>,
        "virtualization@...ts.linux-foundation.org" 
        <virtualization@...ts.linux-foundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] virtio_ring: remove unnecessary to_vvq() call

On Wed, Sep 28, 2022 at 02:26:16AM +0000, Bo Liu (刘波)-浪潮信息 wrote:
> >On Mon, Sep 26, 2022 at 05:11:30AM -0400, Bo Liu wrote:
> >> It passes '_vq' to vring_free(), which still calls to_vvq() to get
> >> 'vq', let's directly pass 'vq'. It can avoid unnecessary call of
> >> to_vvq() in hot path.
> >>
> >> Signed-off-by: Bo Liu <liubo03@...pur.com>
> >
> >What is the point of this change?
> >
> >__vring_new_virtqueue returns struct virtqueue *, so vring_free matches
> that.
> >No?
> >
> 
> Hi
> In function vring_free(), to_vvq() js unnecessary, we can directly pass
> struct vring_virtqueue * to avoid this and remove the unnecessary code.

And so? Is the resulting binary smaller?

> >> ---
> >>  drivers/virtio/virtio_ring.c | 12 +++++-------
> >>  1 file changed, 5 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/virtio/virtio_ring.c
> >> b/drivers/virtio/virtio_ring.c index 8974c34b40fd..d6d77bf58802 100644
> >> --- a/drivers/virtio/virtio_ring.c
> >> +++ b/drivers/virtio/virtio_ring.c
> >> @@ -221,7 +221,7 @@ static struct virtqueue
> >*__vring_new_virtqueue(unsigned int index,
> >>  					       void (*callback)(struct
> virtqueue *),
> >>  					       const char *name);
> >>  static struct vring_desc_extra *vring_alloc_desc_extra(unsigned int
> >> num); -static void vring_free(struct virtqueue *_vq);
> >> +static void vring_free(struct vring_virtqueue *vq);
> >>
> >>  /*
> >>   * Helpers.
> >> @@ -1140,7 +1140,7 @@ static int virtqueue_resize_split(struct virtqueue
> >*_vq, u32 num)
> >>  	if (err)
> >>  		goto err_state_extra;
> >>
> >> -	vring_free(&vq->vq);
> >> +	vring_free(vq);
> >>
> >>  	virtqueue_vring_init_split(&vring_split, vq);
> >>
> >> @@ -2059,7 +2059,7 @@ static int virtqueue_resize_packed(struct virtqueue
> >*_vq, u32 num)
> >>  	if (err)
> >>  		goto err_state_extra;
> >>
> >> -	vring_free(&vq->vq);
> >> +	vring_free(vq);
> >>
> >>  	virtqueue_vring_init_packed(&vring_packed, !!vq->vq.callback);
> >>
> >> @@ -2649,10 +2649,8 @@ struct virtqueue *vring_new_virtqueue(unsigned
> >> int index,  }  EXPORT_SYMBOL_GPL(vring_new_virtqueue);
> >>
> >> -static void vring_free(struct virtqueue *_vq)
> >> +static void vring_free(struct vring_virtqueue *vq)
> >>  {
> >> -	struct vring_virtqueue *vq = to_vvq(_vq);
> >> -
> >>  	if (vq->we_own_ring) {
> >>  		if (vq->packed_ring) {
> >>  			vring_free_queue(vq->vq.vdev,
> >> @@ -2693,7 +2691,7 @@ void vring_del_virtqueue(struct virtqueue *_vq)
> >>  	list_del(&_vq->list);
> >>  	spin_unlock(&vq->vq.vdev->vqs_list_lock);
> >>
> >> -	vring_free(_vq);
> >> +	vring_free(vq);
> >>
> >>  	kfree(vq);
> >>  }
> >> --
> >> 2.27.0
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ