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: ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com,
	gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org,
	stefanha@redhat.com, pbonzini@redhat.com,
	dan.j.williams@intel.com, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v2 0/8] nvdimm: hotplug support
Date: Mon, 10 Oct 2016 21:57:55 +0800	[thread overview]
Message-ID: <560c2e37-ef5d-c0b0-0059-29d07cecd443@linux.intel.com> (raw)
In-Reply-To: <20161010145931.59c0c5bb@nial.brq.redhat.com>



On 10/10/2016 08:59 PM, Igor Mammedov wrote:
> On Sat, 8 Oct 2016 16:34:06 +0800
> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>
>> On 10/03/2016 09:48 PM, Igor Mammedov wrote:
>>> On Fri, 12 Aug 2016 14:54:02 +0800
>>> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>>>
>>> General design issue in this series is regenerating
>>> _FIT data every time inside of _FIT read loop.
>>>
>>> The issue here is that if FIT data doesn't fit in one page
>>> RFIT would be called several times resulting in calling
>>> nvdimm_dsm_func_read_fit() N-times, and in between
>>> these N exits generated FIT data could change
>>> (for example if another NVDIMM has been hotpluged in between)
>>> resulting in corrupted concatenated FIT buffer returned by
>>> _FIT method.
>>> So one need either to block follow up hotplug or make sure
>>> that FIT data regenerated/updated only once per _FIT
>>> invocation and stay immutable until _FIT is completed
>>> (maybe RCU protected buffer).
>>>
>
>
>>> Regenerating/updating inside qemu could also be shared
>>> with NFIT table creation path so that both cold/hotplug
>>> would reuse the same data which are updated only when
>>> a NVDIMM is added/removed.
> try to take into account this point so that FIT data
> aren't regenerated on every RFIT invocation.

Okay.

The reason that the FIT was always regenerated is avoiding saving
FIT during live-migration. Well, it seems that we are hard to
avoid it now. :)

>
>
>> Explicitly sync up QEMU and OSPM is hard as OSPM is running
>> in a VM which is vulnerable and can not be expected always
>> triggering correct sequence.
>>
>> So how about introducing generation-number which is updated
>> for each hotplug event and a new DSM function reserved to
>> get this number by OSPM. Then the ACPI code is like this:
>>
>> restart:
>>     old-number = DSM(Read_NUM);
>>     FIT = DSM(FIT)
>>     new-number = DSM(Read_NUM);
>>
>>     if (old-number != new-number)
>>        goto restart;
>>
>>     return FIT
> It's a bit complicated.
>

Hmm, how about this algorithm:

struct fit_data {
	u64 generation_number;
	GArray *fit;
};

struct fit_data *fit;
u64 current_number;

The update-side (hotplug happens):
   new_fit = malloc();

   old_fit = rcu_dereference(fit);

   new_fit->generation_number = old_fit->generation_number + 1;
   new_fit->fit = ...generate-fit...;

   rcu_assign(fit, new_fit);
   sync_rcu()
   free(old_fit);


On the read-side (DSM issued by OSPM):
{
    rcu_read_lock()

    fit = rcu_dereference(fit);

    /* if it is the first time issuing RFIT. */
    if (fit-read-position == 0)
      current_number = fit->generation_number;
    else if (current_number != fit->generation_number)
      return FAIL_FIT_CHANGED;

    ... fill returned info with fit->fit...;

    rcu_read_unlock()
}

Of course, @fit and @current_number should be persistent during live migration.

  reply	other threads:[~2016-10-10 14:04 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  6:54 [PATCH v2 0/8] nvdimm: hotplug support Xiao Guangrong
2016-08-12  6:54 ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 1/8] acpi nvdimm: fix wrong buffer size returned by DSM method Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-09-20 14:07   ` Igor Mammedov
2016-09-20 14:07     ` [Qemu-devel] " Igor Mammedov
2016-09-20 15:14     ` Michael S. Tsirkin
2016-09-20 15:14       ` [Qemu-devel] " Michael S. Tsirkin
2016-09-20 16:23       ` Igor Mammedov
2016-09-21  5:30     ` Xiao Guangrong
2016-09-21  5:30       ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 2/8] nvdimm acpi: prebuild nvdimm devices for available slots Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-09-21 11:48   ` Igor Mammedov
2016-09-21 11:48     ` [Qemu-devel] " Igor Mammedov
2016-09-22  2:43     ` Xiao Guangrong
2016-09-22  2:43       ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 3/8] nvdimm acpi: introduce _FIT Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-09-30 13:14   ` Igor Mammedov
2016-09-30 13:14     ` [Qemu-devel] " Igor Mammedov
2016-10-08  7:17     ` Xiao Guangrong
2016-10-08  7:17       ` [Qemu-devel] " Xiao Guangrong
2016-10-10 12:51       ` Igor Mammedov
2016-10-10 12:51         ` [Qemu-devel] " Igor Mammedov
2016-10-10 13:09         ` Xiao Guangrong
2016-10-10 13:09           ` [Qemu-devel] " Xiao Guangrong
2016-10-11 11:49           ` Igor Mammedov
2016-10-11 11:49             ` [Qemu-devel] " Igor Mammedov
2016-10-12  8:20             ` Xiao Guangrong
2016-10-12  8:20               ` [Qemu-devel] " Xiao Guangrong
2016-10-13 13:33               ` Igor Mammedov
2016-10-14  7:43                 ` Xiao Guangrong
2016-10-14 11:59                   ` Igor Mammedov
2016-08-12  6:54 ` [PATCH v2 4/8] nvdimm acpi: implement Read FIT function Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-09-30 13:17   ` Igor Mammedov
2016-09-30 13:17     ` [Qemu-devel] " Igor Mammedov
2016-10-08  7:17     ` Xiao Guangrong
2016-10-08  7:17       ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 5/8] pc-dimm: introduce prepare_unplug() callback Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-10-03  9:45   ` Igor Mammedov
2016-10-03  9:45     ` [Qemu-devel] " Igor Mammedov
2016-10-08  7:20     ` Xiao Guangrong
2016-10-08  7:20       ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 6/8] pc: memhp: do not export nvdimm's memory via _CRS Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-10-03 13:21   ` Igor Mammedov
2016-10-03 13:21     ` [Qemu-devel] " Igor Mammedov
2016-10-08  7:42     ` Xiao Guangrong
2016-10-08  7:42       ` [Qemu-devel] " Xiao Guangrong
2016-10-10 12:47       ` Igor Mammedov
2016-10-10 12:47         ` [Qemu-devel] " Igor Mammedov
2016-10-10 13:10         ` Xiao Guangrong
2016-10-10 13:10           ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 7/8] pc: acpi: memhp: nvdimm hotplug support Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-08-12  6:54 ` [PATCH v2 8/8] nvdimm docs: add nvdimm Read FIT function Xiao Guangrong
2016-08-12  6:54   ` [Qemu-devel] " Xiao Guangrong
2016-09-30 14:03   ` Igor Mammedov
2016-09-30 14:03     ` [Qemu-devel] " Igor Mammedov
2016-10-08  7:18     ` Xiao Guangrong
2016-10-08  7:18       ` [Qemu-devel] " Xiao Guangrong
2016-08-12  8:35 ` [PATCH v2 0/8] nvdimm: hotplug support Stefan Hajnoczi
2016-08-12  8:35   ` [Qemu-devel] " Stefan Hajnoczi
2016-08-12 15:13   ` Igor Mammedov
2016-08-12 15:13     ` [Qemu-devel] " Igor Mammedov
2016-09-12  7:33     ` Xiao Guangrong
2016-09-12  7:33       ` [Qemu-devel] " Xiao Guangrong
2016-09-12 12:22       ` Igor Mammedov
2016-08-18 17:47 ` Dan Williams
2016-08-18 17:47   ` [Qemu-devel] " Dan Williams
2016-08-18 18:54   ` Vishal Verma
2016-08-18 18:54     ` [Qemu-devel] " Vishal Verma
2016-08-19  3:40     ` Xiao Guangrong
2016-08-19  3:40       ` [Qemu-devel] " Xiao Guangrong
2016-08-19  3:46       ` Xiao Guangrong
2016-08-19  3:46         ` [Qemu-devel] " Xiao Guangrong
2016-08-19  5:14         ` Dan Williams
2016-08-19  5:14           ` [Qemu-devel] " Dan Williams
2016-10-03 13:48 ` Igor Mammedov
2016-10-08  8:34   ` Xiao Guangrong
2016-10-10 12:59     ` Igor Mammedov
2016-10-10 13:57       ` Xiao Guangrong [this message]
2016-10-11 12:32         ` Igor Mammedov
2016-10-12 10:19           ` Xiao Guangrong

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=560c2e37-ef5d-c0b0-0059-29d07cecd443@linux.intel.com \
    --to=guangrong.xiao@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=gleb@kernel.org \
    --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: 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.