From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66]) by dpdk.org (Postfix) with ESMTP id BCCC0377C for ; Fri, 24 Apr 2015 03:01:35 +0200 (CEST) Received: from 172.24.2.119 (EHLO szxeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BFA01802; Fri, 24 Apr 2015 09:01:32 +0800 (CST) Received: from [127.0.0.1] (10.177.19.115) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.158.1; Fri, 24 Apr 2015 09:01:18 +0800 Message-ID: <553995DB.4000801@huawei.com> Date: Fri, 24 Apr 2015 09:01:15 +0800 From: Linhaifeng User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: Huawei Xie , References: <1429720392-25345-1-git-send-email-huawei.xie@intel.com> In-Reply-To: <1429720392-25345-1-git-send-email-huawei.xie@intel.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.19.115] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.553995EC.00F9, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c61f996eee8d2ada3ae1b664901a535e 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 01:01:36 -0000 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 flag. > > 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_rxtx.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 += count; > vq->last_used_idx = 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); > If not add memory fence what would happen? Packets loss or interrupt loss?How to test it ?