From: Peter Xu <peterx@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: David Hildenbrand <david@redhat.com>,
qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Michal Privoznik <mprivozn@redhat.com>
Subject: Re: [PATCH v3 3/8] migration/savevm: Allow immutable device state to be migrated early (i.e., before RAM)
Date: Thu, 12 Jan 2023 17:28:15 -0500 [thread overview]
Message-ID: <Y8CJf7hCy76AtfcF@x1n> (raw)
In-Reply-To: <Y8CGYZ3F/h1oXV+d@x1n>
On Thu, Jan 12, 2023 at 05:14:57PM -0500, Peter Xu wrote:
> On Thu, Jan 12, 2023 at 07:52:41PM +0000, Dr. David Alan Gilbert wrote:
> > * David Hildenbrand (david@redhat.com) wrote:
> > > On 12.01.23 18:56, Dr. David Alan Gilbert wrote:
> > > > * David Hildenbrand (david@redhat.com) wrote:
> > > > > For virtio-mem, we want to have the plugged/unplugged state of memory
> > > > > blocks available before migrating any actual RAM content, and perform
> > > > > sanity checks before touching anything on the destination. This
> > > > > information is immutable on the migration source while migration is active,
> > > > >
> > > > > We want to use this information for proper preallocation support with
> > > > > migration: currently, we don't preallocate memory on the migration target,
> > > > > and especially with hugetlb, we can easily run out of hugetlb pages during
> > > > > RAM migration and will crash (SIGBUS) instead of catching this gracefully
> > > > > via preallocation.
> > > > >
> > > > > Migrating device state via a vmsd before we start iterating is currently
> > > > > impossible: the only approach that would be possible is avoiding a vmsd
> > > > > and migrating state manually during save_setup(), to be restored during
> > > > > load_state().
> > > > >
> > > > > Let's allow for migrating device state via a vmsd early, during the
> > > > > setup phase in qemu_savevm_state_setup(). To keep it simple, we
> > > > > indicate applicable vmds's using an "immutable" flag.
> > > > >
> > > > > Note that only very selected devices (i.e., ones seriously messing with
> > > > > RAM setup) are supposed to make use of such early state migration.
> > > > >
> > > > > Signed-off-by: David Hildenbrand <david@redhat.com>
> > > > > ---
> > > > > include/migration/vmstate.h | 5 +++++
> > > > > migration/savevm.c | 14 ++++++++++++++
> > > > > 2 files changed, 19 insertions(+)
> > > > >
> > > > > diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> > > > > index ad24aa1934..dd06c3abad 100644
> > > > > --- a/include/migration/vmstate.h
> > > > > +++ b/include/migration/vmstate.h
> > > > > @@ -179,6 +179,11 @@ struct VMStateField {
> > > > > struct VMStateDescription {
> > > > > const char *name;
> > > > > int unmigratable;
> > > > > + /*
> > > > > + * The state is immutable while migration is active and is saved
> > > > > + * during the setup phase, to be restored early on the destination.
> > > > > + */
> > > > > + int immutable;
> > > >
> > > > A bool would be nicer (as it would for unmigratable above)
> > >
> > > Yes, I chose an int for consistency with "unmigratable". I can turn that
> > > into a bool.
> > >
> > > I'd even include a cleanup patch for unmigratable if it wouldn't be ...
> > >
> > > $ git grep "unmigratable \=" | wc -l
> > > 29
> >
> > It might be OK if you just change the declaration; I mean '1' is pretty
> > close to true? (I think...)
> > Anyway, at least make the new one a bool.
>
> Agreed bool is better. Can we rename it to something like "early_setup"?
> "immutable" isn't clear on its most important attribute (on when it'll be
> migrated). Meanwhile I'd hope we can comment that explicitly. I'd go with:
>
> /*
> * This VMSD describes something that should be sent during setup phase
> * of migration. It plays similar role as save_setup() for explicitly
> * registered vmstate entries, the only difference is the vmsd will be
> * sent right at the start of migration.
> */
> bool early_setup;
Let me try some even better wording..
/*
* This VMSD describes something that should be sent during setup phase
* of migration. It plays similar role as save_setup() for explicitly
* registered vmstate entries, so it can be seen as a way to describe
* save_setup() in vmsd structures.
*
* One SaveStateEntry should either have the save_setup() specified or
* the vmsd with early_setup set to true. It should never have both
* things set.
*/
bool early_setup;
There's one tricky thing that we'll send QEMU_VM_SECTION_START for
save_setup() entries but QEMU_VM_SECTION_FULL for vmsd early_setup
entries.
David, do you think we can slightly modify your new version of
vmstate_save() so as to pass in the section_type? I think it'll be even
cleaner to send QEMU_VM_SECTION_START for the early vmsds too. I assume
this shouldn't affect your goal and anything else.
>
> >
> > > > > int version_id;
> > > > > int minimum_version_id;
> > > > > MigrationPriority priority;
> > > > > diff --git a/migration/savevm.c b/migration/savevm.c
> > > > > index ff2b8d0064..536d6f662b 100644
> > > > > --- a/migration/savevm.c
> > > > > +++ b/migration/savevm.c
> > > > > @@ -1200,6 +1200,15 @@ void qemu_savevm_state_setup(QEMUFile *f)
> > > > > trace_savevm_state_setup();
> > > > > QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
> > > > > + if (se->vmsd && se->vmsd->immutable) {
> > > > > + ret = vmstate_save(f, se, ms->vmdesc);
> > > > > + if (ret) {
> > > > > + qemu_file_set_error(f, ret);
> > > > > + break;
> > > > > + }
> > > > > + continue;
> > > > > + }
> > > > > +
> > > >
> > > > Does this give you the ordering you want? i.e. there's no guarantee here
> > > > that immutables come first?
> > >
> > > Yes, for virtio-mem at least this is fine. There are no real ordering
> > > requirements in regard to save_setup().
> > >
> > > I guess one could use vmstate priorities to affect the ordering, if
> > > required.
> > >
> > > So for my use case this is good enough, any suggestions? Thanks.
> >
> > OK, but consider whether it might be better just to have a separate
> > QTAILQ_FOREACH look in savevm_state_setup that first does all the
> > immutables, and then all the setups.
>
> After patch 1 the order may not matter iiuc, because each call to the
> immutable vmsds calls the new vmstate_save() which will always send
> QEMU_VM_SECTION_FULL and footers along the vmsd.
>
> Thanks,
>
> --
> Peter Xu
--
Peter Xu
next prev parent reply other threads:[~2023-01-12 22:29 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 16:43 [PATCH v3 0/8] virtio-mem: Handle preallocation with migration David Hildenbrand
2023-01-12 16:43 ` [PATCH v3 1/8] migration/savevm: Move more savevm handling into vmstate_save() David Hildenbrand
2023-01-12 16:58 ` Dr. David Alan Gilbert
2023-01-12 17:49 ` David Hildenbrand
2023-01-12 18:36 ` Dr. David Alan Gilbert
2023-01-13 12:59 ` David Hildenbrand
2023-01-12 16:43 ` [PATCH v3 2/8] migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup() David Hildenbrand
2023-01-12 17:43 ` Dr. David Alan Gilbert
2023-01-12 17:47 ` David Hildenbrand
2023-01-12 18:40 ` Dr. David Alan Gilbert
2023-01-12 22:06 ` Peter Xu
2023-01-13 13:01 ` David Hildenbrand
2023-01-13 13:05 ` David Hildenbrand
2023-01-12 16:43 ` [PATCH v3 3/8] migration/savevm: Allow immutable device state to be migrated early (i.e., before RAM) David Hildenbrand
2023-01-12 17:56 ` Dr. David Alan Gilbert
2023-01-12 18:21 ` David Hildenbrand
2023-01-12 19:52 ` Dr. David Alan Gilbert
2023-01-12 22:14 ` Peter Xu
2023-01-12 22:28 ` Peter Xu [this message]
2023-01-13 13:47 ` David Hildenbrand
2023-01-13 15:20 ` Peter Xu
2023-01-13 15:27 ` Peter Xu
2023-01-16 10:35 ` David Hildenbrand
2023-01-16 14:56 ` Peter Xu
2023-01-16 14:57 ` David Hildenbrand
2023-01-13 15:28 ` David Hildenbrand
2023-01-12 16:43 ` [PATCH v3 4/8] migration/vmstate: Introduce VMSTATE_WITH_TMP_TEST() and VMSTATE_BITMAP_TEST() David Hildenbrand
2023-01-12 16:44 ` [PATCH v3 5/8] migration/ram: Factor out check for advised postcopy David Hildenbrand
2023-01-12 18:23 ` Dr. David Alan Gilbert
2023-01-12 16:44 ` [PATCH v3 6/8] virtio-mem: Fail if a memory backend with "prealloc=on" is specified David Hildenbrand
2023-01-12 18:33 ` Dr. David Alan Gilbert
2023-01-12 16:44 ` [PATCH v3 7/8] virtio-mem: Migrate immutable properties early David Hildenbrand
2023-01-12 19:44 ` Dr. David Alan Gilbert
2023-01-13 13:59 ` David Hildenbrand
2023-01-12 16:44 ` [PATCH v3 8/8] virtio-mem: Proper support for preallocation with migration David Hildenbrand
2023-01-12 19:50 ` Dr. David Alan Gilbert
2023-01-12 16:45 ` [PATCH v3 0/8] virtio-mem: Handle " David Hildenbrand
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=Y8CJf7hCy76AtfcF@x1n \
--to=peterx@redhat.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=mprivozn@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@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.