From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 40FF52B95 for ; Wed, 1 Jun 2016 07:40:11 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 31 May 2016 22:40:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,399,1459839600"; d="scan'208";a="992753494" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 31 May 2016 22:40:11 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 31 May 2016 22:40:09 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.150]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.181]) with mapi id 14.03.0248.002; Wed, 1 Jun 2016 13:40:08 +0800 From: "Xie, Huawei" To: Yuanhan Liu CC: "dev@dpdk.org" , "stephen@networkplumber.org" , "Ananyev, Konstantin" , "thomas.monjalon@6wind.com" Thread-Topic: [dpdk-dev] [PATCH] virtio: use volatile to get used->idx in the loop Thread-Index: AdG7yA4yoCOUROu/Rf+v+VEjIsQC1w== Date: Wed, 1 Jun 2016 05:40:08 +0000 Message-ID: References: <1464106601-981-1-git-send-email-huawei.xie@intel.com> <20160530082258.GF5641@yliu-dev.sh.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, 01 Jun 2016 05:40:11 -0000 On 5/30/2016 4:20 PM, Yuanhan Liu wrote:=0A= > On Wed, May 25, 2016 at 12:16:41AM +0800, Huawei Xie 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/vir= tio_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 vir= tio_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= > I'm wondering maybe we could fix VIRTQUEUE_NUSED (which has no such=0A= > qualifier) and use this macro here?=0A= >=0A= > If you check the reference of that macro, you might find similar=0A= > issues, say, it is also used inside the while-loop of=0A= > virtio_recv_mergeable_pkts().=0A= >=0A= > --yliu=0A= > =0A= >=0A= =0A= Yes, seems it has same issue though haven't confirmed with asm code.=0A=