From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4343F5A8B for ; Mon, 30 May 2016 10:20:28 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 30 May 2016 01:20:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,388,1459839600"; d="scan'208";a="977124903" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga001.fm.intel.com with ESMTP; 30 May 2016 01:20:26 -0700 Date: Mon, 30 May 2016 16:22:58 +0800 From: Yuanhan Liu To: Huawei Xie Cc: dev@dpdk.org, stephen@networkplumber.org, konstantin.ananyev@intel.com, thomas.monjalon@6wind.com Message-ID: <20160530082258.GF5641@yliu-dev.sh.intel.com> References: <1464106601-981-1-git-send-email-huawei.xie@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464106601-981-1-git-send-email-huawei.xie@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] virtio: use volatile to get used->idx in the loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2016 08:20:28 -0000 On Wed, May 25, 2016 at 12:16:41AM +0800, Huawei Xie wrote: > There is no external function call or any barrier in the loop, > the used->idx would only be retrieved once. > > Signed-off-by: Huawei Xie > --- > drivers/net/virtio/virtio_ethdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index c3fb628..f6d6305 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -204,7 +204,8 @@ virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, > usleep(100); > } > > - while (vq->vq_used_cons_idx != vq->vq_ring.used->idx) { > + while (vq->vq_used_cons_idx != > + *((volatile uint16_t *)(&vq->vq_ring.used->idx))) { I'm wondering maybe we could fix VIRTQUEUE_NUSED (which has no such qualifier) and use this macro here? If you check the reference of that macro, you might find similar issues, say, it is also used inside the while-loop of virtio_recv_mergeable_pkts(). --yliu