public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Deming Wang <wangdeming@inspur.com>
Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] virtio_ring: Optimize duplicate judgment codes for virtqueue_add_split
Date: Mon, 20 Jun 2022 04:24:30 -0400	[thread overview]
Message-ID: <20220620042221-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220620080656.1559-1-wangdeming@inspur.com>

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@inspur.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


      reply	other threads:[~2022-06-20  8:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  8:06 [PATCH] virtio_ring: Optimize duplicate judgment codes for virtqueue_add_split Deming Wang
2022-06-20  8:24 ` Michael S. Tsirkin [this message]

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=20220620042221-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wangdeming@inspur.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