From: Stefan Hajnoczi <stefanha@gmail.com> To: Xiao Guangrong <guangrong.xiao@linux.intel.com> Cc: ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, imammedo@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, rth@twiddle.net Subject: Re: [PATCH v3 2/4] nvdimm acpi: introduce fit buffer Date: Tue, 1 Nov 2016 15:17:01 +0000 [thread overview] Message-ID: <20161101151701.GC5707@stefanha-x1.localdomain> (raw) In-Reply-To: <1477672540-27952-3-git-send-email-guangrong.xiao@linux.intel.com> [-- Attachment #1: Type: text/plain, Size: 2138 bytes --] 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 > > 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 = 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 value, Error **errp) > goto child_realize_fail; > } > } > + > if (dev->hotplugged) { > device_reset(dev); > } > dev->pending_deleted_event = false; > + dev->realized = value; > + > + if (hotplug_ctrl) { > + hotplug_handler_post_plug(hotplug_ctrl, dev, &local_err); > + } > + > + if (local_err != NULL) { > + dev->realized = value; dev->realized = value was already set above. In order to preserve semantics you would need a bool old_value = dev->realized which you can restore in post_realize_fail. QEMU current does not assign dev->realized = value when there is a failure! [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 455 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Stefan Hajnoczi <stefanha@gmail.com> To: Xiao Guangrong <guangrong.xiao@linux.intel.com> 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 Subject: Re: [Qemu-devel] [PATCH v3 2/4] nvdimm acpi: introduce fit buffer Date: Tue, 1 Nov 2016 15:17:01 +0000 [thread overview] Message-ID: <20161101151701.GC5707@stefanha-x1.localdomain> (raw) In-Reply-To: <1477672540-27952-3-git-send-email-guangrong.xiao@linux.intel.com> [-- Attachment #1: Type: text/plain, Size: 2138 bytes --] 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 > > 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 = 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 value, Error **errp) > goto child_realize_fail; > } > } > + > if (dev->hotplugged) { > device_reset(dev); > } > dev->pending_deleted_event = false; > + dev->realized = value; > + > + if (hotplug_ctrl) { > + hotplug_handler_post_plug(hotplug_ctrl, dev, &local_err); > + } > + > + if (local_err != NULL) { > + dev->realized = value; dev->realized = value was already set above. In order to preserve semantics you would need a bool old_value = dev->realized which you can restore in post_realize_fail. QEMU current does not assign dev->realized = value when there is a failure! [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2016-11-01 15:17 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-10-28 16:35 [PATCH v3 0/4] nvdimm: hotplug support Xiao Guangrong 2016-10-28 16:35 ` [Qemu-devel] " Xiao Guangrong 2016-10-28 16:35 ` [PATCH v3 1/4] nvdimm acpi: prebuild nvdimm devices for available slots Xiao Guangrong 2016-10-28 16:35 ` [Qemu-devel] " Xiao Guangrong 2016-11-01 15:16 ` Igor Mammedov 2016-11-01 15:16 ` [Qemu-devel] " Igor Mammedov 2016-10-28 16:35 ` [PATCH v3 2/4] nvdimm acpi: introduce fit buffer Xiao Guangrong 2016-10-28 16:35 ` [Qemu-devel] " Xiao Guangrong 2016-11-01 15:17 ` Stefan Hajnoczi [this message] 2016-11-01 15:17 ` Stefan Hajnoczi 2016-11-01 15:25 ` Igor Mammedov 2016-11-01 15:25 ` [Qemu-devel] " Igor Mammedov 2016-11-01 16:00 ` Xiao Guangrong 2016-11-01 16:00 ` [Qemu-devel] " Xiao Guangrong 2016-10-28 16:35 ` [PATCH v3 3/4] nvdimm acpi: introduce _FIT Xiao Guangrong 2016-10-28 16:35 ` [Qemu-devel] " Xiao Guangrong 2016-11-01 16:24 ` Igor Mammedov 2016-11-01 16:24 ` [Qemu-devel] " Igor Mammedov 2016-11-02 15:40 ` Xiao Guangrong 2016-11-02 15:40 ` [Qemu-devel] " Xiao Guangrong 2016-11-03 9:15 ` Igor Mammedov 2016-11-03 9:15 ` [Qemu-devel] " Igor Mammedov 2016-11-01 16:41 ` Stefan Hajnoczi 2016-11-01 16:41 ` [Qemu-devel] " Stefan Hajnoczi 2016-11-02 15:42 ` Xiao Guangrong 2016-11-02 15:42 ` [Qemu-devel] " Xiao Guangrong 2016-11-02 13:56 ` Igor Mammedov 2016-11-02 15:54 ` Xiao Guangrong 2016-11-03 9:22 ` Igor Mammedov 2016-10-28 16:35 ` [PATCH v3 4/4] pc: memhp: enable nvdimm device hotplug Xiao Guangrong 2016-10-28 16:35 ` [Qemu-devel] " Xiao Guangrong 2016-11-01 16:44 ` Stefan Hajnoczi 2016-11-01 16:44 ` [Qemu-devel] " Stefan Hajnoczi 2016-11-02 11:21 ` Igor Mammedov 2016-11-02 11:21 ` [Qemu-devel] " Igor Mammedov 2016-11-02 15:55 ` Xiao Guangrong 2016-11-02 15:55 ` [Qemu-devel] " Xiao Guangrong 2016-11-02 14:01 ` [Qemu-devel] [PATCH v3 0/4] nvdimm: hotplug support Igor Mammedov 2016-11-03 4:53 ` Michael S. Tsirkin 2016-11-03 9:27 ` Igor Mammedov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20161101151701.GC5707@stefanha-x1.localdomain \ --to=stefanha@gmail.com \ --cc=dan.j.williams@intel.com \ --cc=ehabkost@redhat.com \ --cc=gleb@kernel.org \ --cc=guangrong.xiao@linux.intel.com \ --cc=imammedo@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=mst@redhat.com \ --cc=mtosatti@redhat.com \ --cc=pbonzini@redhat.com \ --cc=qemu-devel@nongnu.org \ --cc=rth@twiddle.net \ --cc=stefanha@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.