From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 02DEE2BC6 for ; Wed, 25 May 2016 10:25:23 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 25 May 2016 01:25:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,363,1459839600"; d="scan'208";a="814369715" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 25 May 2016 01:25:22 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 25 May 2016 01:25:22 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.148]) by shsmsx102.ccr.corp.intel.com ([169.254.2.104]) with mapi id 14.03.0248.002; Wed, 25 May 2016 16:25:20 +0800 From: "Xie, Huawei" To: "dev@dpdk.org" CC: "stephen@networkplumber.org" , "Ananyev, Konstantin" , "thomas.monjalon@6wind.com" , "ms >> Michael S. Tsirkin" , Yuanhan Liu , "Tan, Jianfeng" Thread-Topic: [PATCH] virtio: use volatile to get used->idx in the loop Thread-Index: AdG2XvmKwNO0MjgYSTywkVzJeasT7A== Date: Wed, 25 May 2016 08:25:20 +0000 Message-ID: References: <1464106601-981-1-git-send-email-huawei.xie@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Wed, 25 May 2016 08:25:24 -0000 On 5/25/2016 4:12 PM, Xie, Huawei wrote:=0A= > There is no external function call or any barrier in the loop,=0A= > the used->idx would only be retrieved once.=0A= >=0A= > Signed-off-by: Huawei Xie =0A= > ---=0A= > drivers/net/virtio/virtio_ethdev.c | 3 ++-=0A= > 1 file changed, 2 insertions(+), 1 deletion(-)=0A= >=0A= > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virt= io_ethdev.c=0A= > index c3fb628..f6d6305 100644=0A= > --- a/drivers/net/virtio/virtio_ethdev.c=0A= > +++ b/drivers/net/virtio/virtio_ethdev.c=0A= > @@ -204,7 +204,8 @@ virtio_send_command(struct virtqueue *vq, struct virt= io_pmd_ctrl *ctrl,=0A= > usleep(100);=0A= > }=0A= > =0A= > - while (vq->vq_used_cons_idx !=3D vq->vq_ring.used->idx) {=0A= > + while (vq->vq_used_cons_idx !=3D=0A= > + *((volatile uint16_t *)(&vq->vq_ring.used->idx))) {=0A= > uint32_t idx, desc_idx, used_idx;=0A= > struct vring_used_elem *uep;=0A= > =0A= =0A= Find this issue when do the code rework of RX/TX queue.=0A= As in other places, we also have loop retrieving the value of avial->idx=0A= or used->idx, i prefer to declare the index in vq structure as volatile=0A= to avoid potential issue.=0A= =0A= Stephen:=0A= Another question is why we need a loop here?=0A= =0A= /huawei=0A=