From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 861AF568A for ; Thu, 6 Dec 2018 12:34:58 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181206113457euoutp026fc60d68b55bfb415ee473d054851a05~tuzgqS2BD2475724757euoutp02W for ; Thu, 6 Dec 2018 11:34:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181206113457euoutp026fc60d68b55bfb415ee473d054851a05~tuzgqS2BD2475724757euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1544096097; bh=z4Y1z6idpYFjWLMNy8HFp0SVDu/rjXwKPm96AaDsc6o=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=q5BjPNrnI6VgSU82fXUVcNEFuRuyvBh/jGDea7xVaUEJwiFDcGRSYy30ef5be5+ZJ WGGOFngUKjeaJqKiQJNrNmV+6vz32DeqLEJ5Yv0Qo8zk70H3otA3MzI06FTaFnOMLW xduT556g5BXkav9hhyKVgSJWultVgwB0++qPFxcs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181206113456eucas1p29a25c96dafb450e6c1e70de50c9b7185~tuzgH2D1A0293002930eucas1p28; Thu, 6 Dec 2018 11:34:56 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 93.97.04806.069090C5; Thu, 6 Dec 2018 11:34:56 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181206113455eucas1p2d15e640fba9cd2ea5bf1188354a42126~tuzfNzXnx1180711807eucas1p2a; Thu, 6 Dec 2018 11:34:55 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181206113455eusmtrp11c10d7d5d629c96b417b8d0641ca8818~tuze-NDuS1942919429eusmtrp14; Thu, 6 Dec 2018 11:34:55 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-54-5c0909605701 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FB.EF.04284.F59090C5; Thu, 6 Dec 2018 11:34:55 +0000 (GMT) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181206113454eusmtip2c55ab3af6ed95cfed51d4ca821f1cdd6~tuzecNOlT3171731717eusmtip2d; Thu, 6 Dec 2018 11:34:54 +0000 (GMT) To: Jason Wang , Maxime Coquelin , dev@dpdk.org, jfreimann@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: stable@dpdk.org, "Michael S. Tsirkin" From: Ilya Maximets Message-ID: <9bbdf9aa-91d2-b68f-3d3c-9ee191708e9e@samsung.com> Date: Thu, 6 Dec 2018 14:34:50 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIKsWRmVeSWpSXmKPExsWy7djPc7oJnJwxBiu3C1i8+7SdyeJK+092 i2WXPjNZnFuzlMXiWOceFov/v16xWvzr+MNusbXhP5PF5ouTmBw4PX4tWMrqsXjPSyaP9/uu snn0bVnFGMASxWWTkpqTWZZapG+XwJXxddoLpoLn/BXX7/5nbGB8w9PFyMkhIWAi8XfWNrYu Ri4OIYEVjBLL/p2Gcr4wSvzaspIVpEpI4DOjxIpTsjAd1w9NYYEoWs4o8W/KBUYI5yOjRO/9 D+wgVcICbhJd504xg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2CwCKhI/WlvANogKREicfbkOqkZQ4uTMJ2A1 nED183rfMEMsUJf4M+8SlC0u0fRlJdRieYnmrbOZJzAKzULSPgtJyywkLbOQtCxgZFnFKJJa WpybnltsqFecmFtcmpeul5yfu4kRGIPbjv3cvIPx0sbgQ4wCHIxKPLwvHrDHCLEmlhVX5h5i lOBgVhLhZdDjiBHiTUmsrEotyo8vKs1JLT7EaAr03ERmKdHkfGB6yCuJNzQ1NLewNDQ3Njc2 s1AS5z1vUBklJJCeWJKanZpakFoE08fEwSnVwFju8vaM5uWisjW6F/QUd2XLbtCdGFb5/nm/ tMvNaI6/je+Fe59qeLzJ2bdFOUjBbBfv+ycmX1bLfZjNY3P0VmzCtScPRNOu/b3EfOT81OW5 3+dIFq0/+zwyqCAgZ80fwUObTv4549UWvGkjA0d12fy1Ec0yYQpqz3a4Xy8rMm23lPPm/p0u HazEUpyRaKjFXFScCAAa2D7C1wIAAA== X-CMS-MailID: 20181206113455eucas1p2d15e640fba9cd2ea5bf1188354a42126 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181205133332eucas1p195b3864ed146403e314d7004d27be285 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181205133332eucas1p195b3864ed146403e314d7004d27be285 References: <20181205094957.1938-3-maxime.coquelin@redhat.com> <16a4b2fd-c701-7822-3215-62e431e3f339@samsung.com> Subject: Re: [dpdk-dev] [2/5] vhost: enforce desc flags and content read ordering X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 11:34:58 -0000 On 06.12.2018 7:24, Jason Wang wrote: > > On 2018/12/5 下午9:33, Ilya Maximets wrote: >> On 05.12.2018 12:49, Maxime Coquelin wrote: >>> A read barrier is required to ensure that the ordering between >>> descriptor's flags and content reads is enforced. >>> >>> Fixes: 2f3225a7d69b ("vhost: add vector filling support for packed ring") >>> Cc: stable@dpdk.org >>> >>> Reported-by: Jason Wang >>> Signed-off-by: Maxime Coquelin >>> --- >>>   lib/librte_vhost/virtio_net.c | 6 ++++++ >>>   1 file changed, 6 insertions(+) >>> >>> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c >>> index f11ebb54f..68b72e7a5 100644 >>> --- a/lib/librte_vhost/virtio_net.c >>> +++ b/lib/librte_vhost/virtio_net.c >>> @@ -520,6 +520,12 @@ fill_vec_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, >>>       if (unlikely(!desc_is_avail(&descs[avail_idx], wrap_counter))) >>>           return -1; >>>   +    /* >>> +     * The ordering between desc flags and desc >>> +     * content reads need to be enforced. >>> +     */ >>> +    rte_smp_rmb(); >>> + >> Same here. 'desc_is_avail' reads and uses the flags. i.e. >> no way for reordering, >> Writes must be ordered on the virtio side by the write barrier. >> This means that if flags are updated (desc_is_avail() == true) >> than the whole descriptor already updated and the data is written. >> No need to have any read barriers here. > > > In fact , the sequence might be: > > > flag = read desc[avail_idx].flag [1] > > if(flag is not avail) { > >     read desc[avail_idx].id [2] > > } > > > There's no data dependency but control dependency here, so 2 could be done before 1 without a rmb. OK. Thanks. I agree. Missed that speculative load. Acked-by: Ilya Maximets > > Thanks > > >> >>>       *desc_count = 0; >>>       *len = 0; >>>   > >