All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Richard Henderson <rth@twiddle.net>,
	qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PULL 37/47] nvdimm acpi: introduce fit buffer
Date: Tue, 1 Nov 2016 21:40:46 +0800	[thread overview]
Message-ID: <d5006d18-4e44-e213-95e6-e18dba58dc06@linux.intel.com> (raw)
In-Reply-To: <20161101113526.1396cdd4@nial.brq.redhat.com>



On 11/01/2016 06:35 PM, Igor Mammedov wrote:
> On Tue, 1 Nov 2016 11:30:46 +0800
> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>
>> On 10/31/2016 07:09 PM, Igor Mammedov wrote:
>>> On Mon, 31 Oct 2016 17:52:24 +0800
>>> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>>>
>>>> On 10/31/2016 05:45 PM, Igor Mammedov wrote:
>>>>> On Sun, 30 Oct 2016 23:25:05 +0200
>>>>> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>>>>>
>>>>>> From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>>>>>>
>>>>>> 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
>>> Could you explain why lock is needed?
>>
>> Yes. These are two things need to be synced between QEMU and OSPM:
>> - fit buffer. QEMU products it and VM will consume it at the same time.
>> - dirty indicator. QEMU sets it and it will be cleared by OSPM, that means.
>>    both sides will modify it.
>
> I understand why 'dirty indicator' is necessary but
> could you describe a concrete call flows in detail
> that would cause concurrent access and need extra
> lock protection.
>
> Note that there is global lock (dubbed BQL) in QEMU,
> which is taken every time guest accesses IO port or
> QMP/monitor control event happens.

Ah. okay. If there is a lock to protect vm-exit handler and
monitor handler, i think it is okay to drop the lock.

>
>>>>>> 2) mark @dirty whenever the buffer is updated.
>>>>>>
>>>>>> @dirty is cleared for the first time OSPM gets fit buffer, if
>>>>>> dirty is detected in the later access, OSPM will restart the
>>>>>> access
>>>>>>
>>>>>> As fit should be updated after nvdimm device is successfully realized
>>>>>> so that a new hotplug callback, post_hotplug, is introduced
>>>>>>
>>>>>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>>>>>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>>>>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>>>>> ---
>>>>>>  include/hw/hotplug.h    | 10 +++++++++
>>>>>>  include/hw/mem/nvdimm.h | 26 +++++++++++++++++++++-
>>>>>>  hw/acpi/nvdimm.c        | 59 +++++++++++++++++++++++++++++++++++--------------
>>>>>>  hw/core/hotplug.c       | 11 +++++++++
>>>>>>  hw/core/qdev.c          | 20 +++++++++++++----
>>>>>>  hw/i386/acpi-build.c    |  2 +-
>>>>>>  hw/i386/pc.c            | 19 ++++++++++++++++
>>>>>>  7 files changed, 124 insertions(+), 23 deletions(-)
>>>>>>
>>>>>> diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
>>>>>> index c0db869..10ca5b6 100644
>>>>>> --- a/include/hw/hotplug.h
>>>>>> +++ b/include/hw/hotplug.h
>>>>>> @@ -47,6 +47,7 @@ typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
>>>>>>   * @parent: Opaque parent interface.
>>>>>>   * @pre_plug: pre plug callback called at start of device.realize(true)
>>>>>>   * @plug: plug callback called at end of device.realize(true).
>>>>>> + * @post_pug: post plug callback called after device is successfully plugged.
>>>>> this doesn't seem to be necessary,
>>>>> why hotplug_handler_plug() isn't sufficient?
>>>>
>>>> At the point of hotplug_handler_plug(), the device is not realize (realized == 0),
>>>> however, nvdimm_get_plugged_device_list() works on realized nvdimm devices.
>>>
>>> I suggest instead of adding redundant hook, to reuse hotplug_handler_plug()
>>> which is called after device::realize() successfully completed and amend
>>> nvdimm_plugged_device_list() as follow:
>>>
>>> diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
>>> index e486128..c6d8cbb 100644
>>> --- a/hw/acpi/nvdimm.c
>>> +++ b/hw/acpi/nvdimm.c
>>> @@ -38,11 +38,7 @@ static int nvdimm_plugged_device_list(Object *obj, void *opaque)
>>>      GSList **list = opaque;
>>>
>>>      if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
>>> -        DeviceState *dev = DEVICE(obj);
>>> -
>>> -        if (dev->realized) { /* only realized NVDIMMs matter */
>>> -            *list = g_slist_append(*list, DEVICE(obj));
>>> -        }
>>> +        *list = g_slist_append(*list, obj);
>>>      }
>>>
>>>      object_child_foreach(obj, nvdimm_plugged_device_list, opaque);
>>>
>>> that should count not only already present nvdimms but also the one that's
>>> being hotplugged.
>>
>> It is not good as the device which failed to initialize
> See device_set_realized()
>         [...]
>         if (dc->realize) {
>             dc->realize(dev, &local_err);
>         }
>
>         if (local_err != NULL) {
>             goto fail;
>         }
>
>         DEVICE_LISTENER_CALL(realize, Forward, dev);
>
>         if (hotplug_ctrl) {
>             hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
>         }
>
> i.e. control reaches to hotplug_handler_plug() only if
> call dc->realize(dev, &local_err) is successful.
>

I mean, for example. if there are two devices, the first one is failed to be
realized, the second one is init-ed successfully, then can
nvdimm_plugged_device_list() get these two devices?

Based the code of pc_dimm_built_list(), i guess yes.

>> or is not being plugged
>> (consider two nvdimm devices directly appended in QEMU command line, when we plug
>> the first one, both nvdimm devices will be counted in this list) is also counted in
>> this list...
> nope,
> qdev_device_add() is called sequentially (one time for each -device/device_add)
> so nvdimm_plugged_device_list() sees only devices that's been added
> by previous -device/device_add plus one extra device that's
> being added by in progress qdev_device_add() call.
>
> so for "-device nvdimm,id=nv1 -device nvdimm,id=2" call sequence
> would look like:
> 1:
>   qdev_device_add("nvdimm,id=nv1") {
>      -> set parent // device becomes visible to nvdimm_get_plugged_device_list()
>      // this is the only time where device->realized == false
>      // could be observed, all other call chains would either
>      // see device->realized == true or not see device at all
>      -> realize()
>            -> device_set_realized()
>               -> nvdimm->realize()
>               -> hotplug_handler_plug()
>                       nvdimm_get_plugged_device_list()
>                          // would return list with 1 item (nv1)
>                          // where nv1->realized == false)
>
>   }
> 2:
>   qdev_device_add("nvdimm,id=nv2") {
>      -> set parent // device becomes visible to nvdimm_get_plugged_device_list()
>      -> realize()
>            -> device_set_realized()
>               -> nvdimm->realize()
>               -> hotplug_handler_plug()
>                       nvdimm_get_plugged_device_list()
>                          // would return list with 2 items (nv1 and nv2)
>                          // where nv1->realized == true and nv2->realized = false
>   }
>

Okay.

  reply	other threads:[~2016-11-01 13:48 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-30 21:23 [Qemu-devel] [PULL 00/47] virtio, pc: fixes and features Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 01/47] virtio/migration: Add VMStateDescription to VirtioDeviceClass Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 02/47] virtio/migration: Migrate balloon to VMState Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 03/47] virtio: disable ioeventfd as early as possible Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 04/47] virtio: move ioeventfd_disabled flag to VirtioBusState Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 05/47] virtio: move ioeventfd_started " Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 06/47] virtio: add start_ioeventfd and stop_ioeventfd to VirtioDeviceClass Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 07/47] virtio: introduce virtio_device_ioeventfd_enabled Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 08/47] virtio-blk: always use dataplane path if ioeventfd is active Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 09/47] virtio-scsi: " Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 10/47] Revert "virtio: Introduce virtio_add_queue_aio" Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 11/47] virtio: remove set_handler argument from set_host_notifier_internal Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 12/47] virtio: remove ioeventfd_disabled altogether Michael S. Tsirkin
2016-11-10 14:35   ` Christian Borntraeger
2016-11-10 14:38     ` Paolo Bonzini
2016-11-10 14:48       ` Christian Borntraeger
2016-11-15  8:27         ` Christian Borntraeger
2016-11-15 10:00           ` Paolo Bonzini
2016-10-30 21:23 ` [Qemu-devel] [PULL 13/47] virtio: use virtio_bus_set_host_notifier to start/stop ioeventfd Michael S. Tsirkin
2016-10-30 21:23 ` [Qemu-devel] [PULL 14/47] virtio: inline virtio_queue_set_host_notifier_fd_handler Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 15/47] virtio: inline set_host_notifier_internal Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 16/47] cryptodev: introduce cryptodev backend interface Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 17/47] cryptodev: add symmetric algorithm operation stuff Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 18/47] virtio-crypto: introduce virtio_crypto.h Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 19/47] cryptodev: introduce a new cryptodev backend Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 20/47] virtio-crypto: add virtio crypto device emulation Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 21/47] virtio-crypto-pci: add virtio crypto pci support Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 22/47] virtio-crypto: set capacity of algorithms supported Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 23/47] virtio-crypto: add control queue handler Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 24/47] virtio-crypto: add data queue processing handler Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 25/47] cryptodev: introduce an unified wrapper for crypto operation Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 26/47] virtio-crypto: using bh to handle dataq's requests Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 27/47] virtio-crypto: add myself as virtio-crypto and cryptodev backends maintainer Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 28/47] acpi nvdimm: fix wrong buffer size returned by DSM method Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 29/47] acpi nvdimm: fix OperationRegion definition Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 30/47] acpi nvdimm: fix device physical address base Michael S. Tsirkin
2016-10-31  9:20   ` Igor Mammedov
2016-10-31  9:23     ` Xiao Guangrong
2016-10-31 10:56       ` Igor Mammedov
2016-10-31 11:09         ` Xiao Guangrong
2016-10-31 13:30           ` Igor Mammedov
2016-10-30 21:24 ` [Qemu-devel] [PULL 31/47] acpi nvdimm: fix ARG3 conflict Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 32/47] acpi nvdimm: fix Arg6 usage Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 33/47] nvdimm acpi: compile nvdimm acpi code arch-independently Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 34/47] acpi nvdimm: rename result_size to dsm_out_buf_siz Michael S. Tsirkin
2016-10-30 21:24 ` [Qemu-devel] [PULL 35/47] nvdimm acpi: use common macros instead of magic names Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 36/47] nvdimm acpi: prebuild nvdimm devices for available slots Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 37/47] nvdimm acpi: introduce fit buffer Michael S. Tsirkin
2016-10-31  9:45   ` Igor Mammedov
2016-10-31  9:52     ` Xiao Guangrong
2016-10-31 11:09       ` Igor Mammedov
2016-11-01  3:30         ` Xiao Guangrong
2016-11-01 10:35           ` Igor Mammedov
2016-11-01 13:40             ` Xiao Guangrong [this message]
2016-11-01 13:58               ` Igor Mammedov
2016-11-01 15:57                 ` Xiao Guangrong
2016-11-01 16:26                   ` Igor Mammedov
2016-10-30 21:25 ` [Qemu-devel] [PULL 38/47] nvdimm acpi: introduce _FIT Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 39/47] pc: memhp: enable nvdimm device hotplug Michael S. Tsirkin
2016-11-02 11:19   ` Igor Mammedov
2016-11-02 16:00     ` Xiao Guangrong
2016-11-03  9:41       ` Igor Mammedov
2016-10-30 21:25 ` [Qemu-devel] [PULL 40/47] ipmi: Remove hotplug from IPMI BMCs Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 41/47] ipmi_bmc_sim: Remove an unnecessary mutex Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 42/47] ipmi: chassis poweroff should use qemu_system_shutdown_request() Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 43/47] ipmi: Implement shutdown via ACPI overtemp Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 44/47] ipmi: fix build config variable name for ipmi_bmc_extern.o Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 45/47] ipmi: Add graceful shutdown handling to the external BMC Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 46/47] acpi/ipmi: Initialize the fwinfo before fetching it Michael S. Tsirkin
2016-10-30 21:25 ` [Qemu-devel] [PULL 47/47] acpi: fix assert failure caused by commit 35c5a52d Michael S. Tsirkin
2016-10-31  9:50 ` [Qemu-devel] [PULL 00/47] virtio, pc: fixes and features Igor Mammedov
2016-10-31 22:48   ` Michael S. Tsirkin
2016-11-01 12:47     ` Peter Maydell
2016-11-01 13:21     ` Igor Mammedov
2016-11-01 13:45       ` Xiao Guangrong
2016-11-01 13:55       ` Michael S. Tsirkin
2016-11-01 14:14         ` Igor Mammedov
2016-11-01 14:29           ` Peter Maydell
2016-11-01 16:03           ` Xiao Guangrong
2016-11-01 15:22 ` Peter Maydell
2016-11-01 17:25   ` Michael S. Tsirkin
2016-11-01 17:27     ` Peter Maydell
2016-11-02  1:13     ` Gonglei (Arei)
2016-11-02  4:35   ` Michael S. Tsirkin
2016-11-02 13:14     ` Peter Maydell
2016-11-03  3:35       ` Michael S. Tsirkin
2016-11-03 16:59 ` Stefan Hajnoczi

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=d5006d18-4e44-e213-95e6-e18dba58dc06@linux.intel.com \
    --to=guangrong.xiao@linux.intel.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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: link
Be 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.