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 4F15A2C4E for ; Thu, 2 Jun 2016 10:54:43 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 02 Jun 2016 01:54:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,405,1459839600"; d="scan'208";a="967310427" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 02 Jun 2016 01:54:42 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 2 Jun 2016 01:54:40 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 2 Jun 2016 01:54:40 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.150]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.193]) with mapi id 14.03.0248.002; Thu, 2 Jun 2016 16:54:38 +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: Thu, 2 Jun 2016 08:54:38 +0000 Message-ID: References: <1464106601-981-1-git-send-email-huawei.xie@intel.com> <20160530082258.GF5641@yliu-dev.sh.intel.com> <20160601060532.GK5641@yliu-dev.sh.intel.com> <20160602085215.GU10038@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: Thu, 02 Jun 2016 08:54:43 -0000 On 6/2/2016 4:52 PM, Yuanhan Liu wrote:=0A= > On Thu, Jun 02, 2016 at 08:39:36AM +0000, Xie, Huawei wrote:=0A= >> On 6/1/2016 2:03 PM, Yuanhan Liu wrote:=0A= >>> On Wed, Jun 01, 2016 at 05:40:08AM +0000, Xie, Huawei wrote:=0A= >>>> 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= /virtio_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= virtio_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= >>>> Yes, seems it has same issue though haven't confirmed with asm code.= =0A= >>> So, move the "volatile" qualifier to VIRTQUEUE_NUSED?=0A= >>>=0A= >>> --yliu=0A= >>>=0A= >> Yes, anyway this is just intermediate fix. In next patch, will declare= =0A= >> the idx as volatile, and remove the qualifier in the macro.=0A= > Hmm.., why we need an intermediate fix then, if we can come up with an=0A= > ultimate fix very quickly?=0A= >=0A= > --yliu=0A= >=0A= ... Either is OK. I have no preference.=0A=