From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D14D312A8 for ; Fri, 24 Apr 2015 04:40:31 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 23 Apr 2015 19:40:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,636,1422950400"; d="scan'208";a="561019703" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by orsmga003.jf.intel.com with ESMTP; 23 Apr 2015 19:40:29 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.224.2; Fri, 24 Apr 2015 10:40:28 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.107]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0224.002; Fri, 24 Apr 2015 10:40:27 +0800 From: "Xie, Huawei" To: Linhaifeng , "dev@dpdk.org" Thread-Topic: [PATCH] vhost: flush used->idx update before reading avail->flags Thread-Index: AQHQfiopgtA1J/I5VkGjp5VtYEtYDZ1bcdxg Date: Fri, 24 Apr 2015 02:40:26 +0000 Message-ID: References: <1429720392-25345-1-git-send-email-huawei.xie@intel.com> <553995DB.4000801@huawei.com> In-Reply-To: <553995DB.4000801@huawei.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 Cc: "mst@redhat.com" Subject: Re: [dpdk-dev] [PATCH] vhost: flush used->idx update before reading avail->flags 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: Fri, 24 Apr 2015 02:40:32 -0000 > -----Original Message----- > From: Linhaifeng [mailto:haifeng.lin@huawei.com] > Sent: Friday, April 24, 2015 9:01 AM > To: Xie, Huawei; dev@dpdk.org > Cc: luke@snabb.co; mst@redhat.com > Subject: Re: [PATCH] vhost: flush used->idx update before reading avail- > >flags >=20 >=20 >=20 > On 2015/4/23 0:33, Huawei Xie wrote: > > update of used->idx and read of avail->flags could be reordered. > > memory fence should be used to ensure the order, otherwise guest could > see a stale used->idx value after it toggles the interrupt suppression fl= ag. > > > > Signed-off-by: Huawei Xie > > --- > > lib/librte_vhost/vhost_rxtx.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxt= x.c > > index 510ffe8..6afba35 100644 > > --- a/lib/librte_vhost/vhost_rxtx.c > > +++ b/lib/librte_vhost/vhost_rxtx.c > > @@ -178,6 +178,9 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t > queue_id, > > *(volatile uint16_t *)&vq->used->idx +=3D count; > > vq->last_used_idx =3D res_end_idx; > > > > + /* flush used->idx update before we read avail->flags. */ > > + rte_mb(); > > + > > /* Kick the guest if necessary. */ > > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > > eventfd_write((int)vq->callfd, 1); > > >=20 > If not add memory fence what would happen? Packets loss or interrupt > loss?How to test it ? If those two store and load are reordered, guest toggles the interrupt sup= pression flag, then it checks that there is no more work to do. Actually there is.