All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Huawei Xie <huawei.xie@intel.com>
Cc: dev@dpdk.org, yuanhan.liu@intel.com, thomas.monjalon@6wind.com,
	mst@redhat.com, jianfeng.tan@intel.com,
	stephen@networkplumber.org, konstantin.ananyev@intel.com,
	bruce.richardson@intel.com
Subject: Re: [PATCH] virtio: fix idx in used ring retrieved only once
Date: Mon, 20 Jun 2016 14:27:10 +0800	[thread overview]
Message-ID: <20160620062710.GE23111@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1466015437-36809-1-git-send-email-huawei.xie@intel.com>

On Thu, Jun 16, 2016 at 02:30:37AM +0800, Huawei Xie wrote:
> -	while (vq->vq_used_cons_idx != vq->vq_ring.used->idx) {
> +	while (VIRTQUEUE_NUSED(vq)) {
>  		uint32_t idx, desc_idx, used_idx;
>  		struct vring_used_elem *uep;
>  
> diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h
> index 447760a..fcecc16 100644
> --- a/drivers/net/virtio/virtio_ring.h
> +++ b/drivers/net/virtio/virtio_ring.h
> @@ -79,7 +79,7 @@ struct vring_used_elem {
>  
>  struct vring_used {
>  	uint16_t flags;
> -	uint16_t idx;
> +	volatile uint16_t idx;
>  	struct vring_used_elem ring[0];
>  };
>  
> diff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c
> index 7b50119..a0ef8d2 100644
> --- a/drivers/net/virtio/virtio_rxtx_simple.c
> +++ b/drivers/net/virtio/virtio_rxtx_simple.c
> @@ -184,8 +184,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	if (unlikely(nb_pkts < RTE_VIRTIO_DESC_PER_LOOP))
>  		return 0;
>  
> -	nb_used = *(volatile uint16_t *)&vq->vq_ring.used->idx -
> -		vq->vq_used_cons_idx;
> +	nb_used = vq->vq_ring.used->idx - vq->vq_used_cons_idx;

How about replacing it with VIRTQUEUE_NUSED here?

	--yliu

      parent reply	other threads:[~2016-06-20  6:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15 18:30 [PATCH] virtio: fix idx in used ring retrieved only once Huawei Xie
2016-06-19 17:48 ` [PATCH v2] " Huawei Xie
2016-06-20 11:46   ` Yuanhan Liu
2016-06-20  6:27 ` Yuanhan Liu [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=20160620062710.GE23111@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@intel.com \
    --cc=jianfeng.tan@intel.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=mst@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas.monjalon@6wind.com \
    --cc=yuanhan.liu@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.