From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:36845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpOYy-0006bp-MS for qemu-devel@nongnu.org; Thu, 31 Jan 2019 21:28:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpOYx-0001pk-TG for qemu-devel@nongnu.org; Thu, 31 Jan 2019 21:28:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpOYx-0001pR-Ns for qemu-devel@nongnu.org; Thu, 31 Jan 2019 21:28:15 -0500 References: <20190122083152.10705-1-xieyongji@baidu.com> <20190122083152.10705-4-xieyongji@baidu.com> <09287313-0f6e-38a3-be36-9bf65bba7b9d@redhat.com> From: Jason Wang Message-ID: Date: Fri, 1 Feb 2019 10:27:56 +0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 3/6] libvhost-user: Support tracking inflight I/O in shared memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yongji Xie Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , =?UTF-8?Q?Daniel_P=2e_Berrang=c3=a9?= , "Coquelin, Maxime" , Yury Kotov , =?UTF-8?B?0JXQstCz0LXQvdC40Lkg0K/QutC+0LLQu9C10LI=?= , nixun@baidu.com, qemu-devel , lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji On 2019/1/30 =E4=B8=8B=E5=8D=881:48, Yongji Xie wrote: > On Wed, 30 Jan 2019 at 10:32, Jason Wang wrote: >> >> On 2019/1/22 =E4=B8=8B=E5=8D=884:31, elohimes@gmail.com wrote: >>> +static int >>> +vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx) >>> +{ >>> + if (!has_feature(dev->protocol_features, >>> + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { >>> + return 0; >>> + } >>> + >>> + if (unlikely(!vq->inflight)) { >>> + return -1; >>> + } >>> + >>> + vq->inflight->desc[desc_idx].inuse =3D 1; >>> + >>> + vq->inflight->desc[desc_idx].avail_idx =3D vq->last_avail_idx; >>> + >>> + return 0; >>> +} >>> + >>> +static int >>> +vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx) >>> +{ >>> + if (!has_feature(dev->protocol_features, >>> + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { >>> + return 0; >>> + } >>> + >>> + if (unlikely(!vq->inflight)) { >>> + return -1; >>> + } >>> + >>> + vq->inflight->desc[desc_idx].used_idx =3D vq->used_idx; >>> + >>> + barrier(); >>> + >>> + vq->inflight->desc[desc_idx].version++; >>> + >>> + return 0; >>> +} >> >> You probably need WRITE_ONCE() semantic (e.g volatile) to make sure th= e >> value reach memory. >> > The cache line should have been flushed during crash. So we can see > the correct value when backend reconnecting. If so, compile barrier > should be enough here, right? Maybe I worry too much but it's not about flushing cache, but about=20 whether or not compiler can generate mov to memory instead of mov to=20 registers. Thanks > > Thanks, > Yongji