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: <20220620042221-mutt-send-email-mst@kernel.org>
Date:   Mon, 20 Jun 2022 04:24:30 -0400
From:   "Michael S. Tsirkin" <mst@...hat.com>
To:     Deming Wang <wangdeming@...pur.com>
Cc:     jasowang@...hat.com, virtualization@...ts.linux-foundation.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virtio_ring: Optimize duplicate judgment codes for
 virtqueue_add_split

On Mon, Jun 20, 2022 at 04:06:56AM -0400, Deming Wang wrote:
> We combine repeated judgments about indirect in one place
> 
> Signed-off-by: Deming Wang <wangdeming@...pur.com>


Point being? The patch makes the code kind of confusing.
What do we gain in return?

> ---
>  drivers/virtio/virtio_ring.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 13a7348cedff..331fa3cf5be7 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -582,23 +582,19 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
>  					 total_sg * sizeof(struct vring_desc),
>  					 VRING_DESC_F_INDIRECT,
>  					 false);
> +		vq->free_head = vq->split.desc_extra[head].next;
> +		vq->split.desc_state[head].indir_desc = desc;
> +	} else {
> +		/* Update free pointer */
> +		vq->free_head = i;
> +		vq->split.desc_state[head].indir_desc = ctx;
>  	}
>  
>  	/* We're using some buffers from the free list. */
>  	vq->vq.num_free -= descs_used;
>  
> -	/* Update free pointer */
> -	if (indirect)
> -		vq->free_head = vq->split.desc_extra[head].next;
> -	else
> -		vq->free_head = i;
> -
>  	/* Store token and indirect buffer state. */
>  	vq->split.desc_state[head].data = data;
> -	if (indirect)
> -		vq->split.desc_state[head].indir_desc = desc;
> -	else
> -		vq->split.desc_state[head].indir_desc = ctx;
>  
>  	/* Put entry in available array (but don't update avail->idx until they
>  	 * do sync). */
> -- 
> 2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ