From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:55855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goikA-00076T-Ko for qemu-devel@nongnu.org; Wed, 30 Jan 2019 00:49:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goik9-00089b-V8 for qemu-devel@nongnu.org; Wed, 30 Jan 2019 00:49:02 -0500 Received: from mail-yw1-xc44.google.com ([2607:f8b0:4864:20::c44]:34888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goik9-00087s-Qa for qemu-devel@nongnu.org; Wed, 30 Jan 2019 00:49:01 -0500 Received: by mail-yw1-xc44.google.com with SMTP id j82so1036654ywb.2 for ; Tue, 29 Jan 2019 21:49:01 -0800 (PST) MIME-Version: 1.0 References: <20190122083152.10705-1-xieyongji@baidu.com> <20190122083152.10705-4-xieyongji@baidu.com> <09287313-0f6e-38a3-be36-9bf65bba7b9d@redhat.com> In-Reply-To: <09287313-0f6e-38a3-be36-9bf65bba7b9d@redhat.com> From: Yongji Xie Date: Wed, 30 Jan 2019 13:48:49 +0800 Message-ID: Content-Type: text/plain; charset="UTF-8" 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: Jason Wang Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , =?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 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 the > 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? Thanks, Yongji