From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1aoH-0008J9-Jg for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:17:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1aoE-00019l-BC for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:17:09 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1aoE-00019X-4k for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:17:06 -0400 Received: by mail-wm0-x244.google.com with SMTP id u144so3931283wmu.0 for ; Tue, 01 Nov 2016 08:17:06 -0700 (PDT) Date: Tue, 1 Nov 2016 15:17:01 +0000 From: Stefan Hajnoczi Message-ID: <20161101151701.GC5707@stefanha-x1.localdomain> References: <1477672540-27952-1-git-send-email-guangrong.xiao@linux.intel.com> <1477672540-27952-3-git-send-email-guangrong.xiao@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eRtJSFbw+EEWtPj3" Content-Disposition: inline In-Reply-To: <1477672540-27952-3-git-send-email-guangrong.xiao@linux.intel.com> Subject: Re: [Qemu-devel] [PATCH v3 2/4] nvdimm acpi: introduce fit buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xiao Guangrong Cc: pbonzini@redhat.com, imammedo@redhat.com, gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com, mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com, dan.j.williams@intel.com, kvm@vger.kernel.org, qemu-devel@nongnu.org --eRtJSFbw+EEWtPj3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 29, 2016 at 12:35:38AM +0800, Xiao Guangrong wrote: > The buffer is used to save the FIT info for all the presented nvdimm > devices which is updated after the nvdimm device is plugged or > unplugged. In the later patch, it will be used to construct NVDIMM > ACPI _FIT method which reflects the presented nvdimm devices after > nvdimm hotplug >=20 > As FIT buffer can not completely mapped into guest address space, > OSPM will exit to QEMU multiple times, however, there is the race > condition - FIT may be changed during these multiple exits, so that > some rules are introduced: > 1) the user should hold the @lock to access the buffer and I don't understand the purpose of the QEMUMutex lock. Don't all threads calling nvdimm/acpi code hold the QEMU global mutex (main loop and vcpu threads)? > -static void nvdimm_build_nfit(GSList *device_list, GArray *table_offsets, > +static void nvdimm_init_fit_buffer(NvdimmFitBuffer *fit_buf) > +{ > + qemu_mutex_init(&fit_buf->lock); > + fit_buf->fit =3D g_array_new(false, true /* clear */, 1); Is it possible to call nvdimm_build_device_structure() here? That way we don't duplicate the g_array_new() details. > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 5783442..d835e62 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -945,10 +945,21 @@ static void device_set_realized(Object *obj, bool v= alue, Error **errp) > goto child_realize_fail; > } > } > + > if (dev->hotplugged) { > device_reset(dev); > } > dev->pending_deleted_event =3D false; > + dev->realized =3D value; > + > + if (hotplug_ctrl) { > + hotplug_handler_post_plug(hotplug_ctrl, dev, &local_err); > + } > + > + if (local_err !=3D NULL) { > + dev->realized =3D value; dev->realized =3D value was already set above. In order to preserve semantics you would need a bool old_value =3D dev->realized which you can restore in post_realize_fail. QEMU current does not assign dev->realized =3D value when there is a failure! --eRtJSFbw+EEWtPj3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYGLHtAAoJEJykq7OBq3PIVvwH/2BwqOmon/LfKuzfiD+8MLKa ujOwuc6PyK8EjjNbEI7D/hBRTT8ltlVt5ODjUTcRsuwkGKLiZVrMhiYSHXywIsj2 DhSx7uWScAm8qH9vgxdgRARe2L2F/9oPUyfzt1zuW4rWboXNweUSXiYpfy/xsV9O 9CdEr3KN/B0JkDcSam8TiF7RlgW4OApjjzxWbgf8HhWmiOeyLijwOm9aYsbY2rgZ WixpTK3MISUkzcKnwSbKsOUj+E1YmlZ7tki1mMlYYfCaYm1VGwodR0SqFe8bRA/x W96gaeitnQT5FCA0ek77YYR0NmXPY1nPNHckjKk4KkHUOYbuiqiRDc8vSQxaSTI= =n5tg -----END PGP SIGNATURE----- --eRtJSFbw+EEWtPj3--