From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Alexey Perevalov <a.perevalov@samsung.com>
Cc: qemu-devel@nongnu.org, i.maximets@samsung.com, peterx@redhat.com,
eblake@redhat.com, quintela@redhat.com, heetae82.ahn@samsung.com
Subject: Re: [Qemu-devel] [PATCH v10 10/10] migration: add postcopy total blocktime into query-migrate
Date: Thu, 21 Sep 2017 17:44:32 +0100 [thread overview]
Message-ID: <20170921164431.GK2717@work-vm> (raw)
In-Reply-To: <288ce5a4-ece0-1754-c7df-0a6be5af1f2a@samsung.com>
* Alexey Perevalov (a.perevalov@samsung.com) wrote:
> On 09/21/2017 03:42 PM, Dr. David Alan Gilbert wrote:
> > * Alexey Perevalov (a.perevalov@samsung.com) wrote:
> > > Postcopy total blocktime is available on destination side only.
> > > But query-migrate was possible only for source. This patch
> > > adds ability to call query-migrate on destination.
> > > To be able to see postcopy blocktime, need to request postcopy-blocktime
> > > capability.
> > >
> > > The query-migrate command will show following sample result:
> > > {"return":
> > > "postcopy-vcpu-blocktime": [115, 100],
> > > "status": "completed",
> > > "postcopy-blocktime": 100
> > > }}
> > >
> > > postcopy_vcpu_blocktime contains list, where the first item is the first
> > > vCPU in QEMU.
> > >
> > > This patch has a drawback, it combines states of incoming and
> > > outgoing migration. Ongoing migration state will overwrite incoming
> > > state. Looks like better to separate query-migrate for incoming and
> > > outgoing migration or add parameter to indicate type of migration.
> > >
> > > Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > > Signed-off-by: Alexey Perevalov <a.perevalov@samsung.com>
> > > ---
> > > hmp.c | 15 +++++++++++++
> > > migration/migration.c | 42 +++++++++++++++++++++++++++++++----
> > > migration/migration.h | 4 ++++
> > > migration/postcopy-ram.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++
> > > migration/trace-events | 1 +
> > > qapi/migration.json | 11 +++++++++-
> > > 6 files changed, 125 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/hmp.c b/hmp.c
> > > index 0fb2bc7..142f76e 100644
> > > --- a/hmp.c
> > > +++ b/hmp.c
> > > @@ -264,6 +264,21 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
> > > info->cpu_throttle_percentage);
> > > }
> > > + if (info->has_postcopy_blocktime) {
> > > + monitor_printf(mon, "postcopy blocktime: %" PRId64 "\n",
> > > + info->postcopy_blocktime);
> > > + }
> > > +
> > > + if (info->has_postcopy_vcpu_blocktime) {
> > > + Visitor *v;
> > > + char *str;
> > > + v = string_output_visitor_new(false, &str);
> > > + visit_type_int64List(v, NULL, &info->postcopy_vcpu_blocktime, NULL);
> > > + visit_complete(v, &str);
> > > + monitor_printf(mon, "postcopy vcpu blocktime: %s\n", str);
> > > + g_free(str);
> > > + visit_free(v);
> > > + }
> > > qapi_free_MigrationInfo(info);
> > > qapi_free_MigrationCapabilityStatusList(caps);
> > > }
> > > diff --git a/migration/migration.c b/migration/migration.c
> > > index 4f029e8..e1d3248 100644
> > > --- a/migration/migration.c
> > > +++ b/migration/migration.c
> > > @@ -528,14 +528,15 @@ static void populate_disk_info(MigrationInfo *info)
> > > }
> > > }
> > > -MigrationInfo *qmp_query_migrate(Error **errp)
> > > +static void fill_source_migration_info(MigrationInfo *info)
> > > {
> > > - MigrationInfo *info = g_malloc0(sizeof(*info));
> > > MigrationState *s = migrate_get_current();
> > > switch (s->state) {
> > > case MIGRATION_STATUS_NONE:
> > > /* no migration has happened ever */
> > > + /* do not overwrite destination migration status */
> > > + return;
> > > break;
> > > case MIGRATION_STATUS_SETUP:
> > > info->has_status = true;
> > > @@ -584,8 +585,6 @@ MigrationInfo *qmp_query_migrate(Error **errp)
> > > break;
> > > }
> > > info->status = s->state;
> > > -
> > > - return info;
> > > }
> > > /**
> > > @@ -649,6 +648,41 @@ static bool migrate_caps_check(bool *cap_list,
> > > return true;
> > > }
> > > +static void fill_destination_migration_info(MigrationInfo *info)
> > > +{
> > > + MigrationIncomingState *mis = migration_incoming_get_current();
> > > +
> > > + switch (mis->state) {
> > > + case MIGRATION_STATUS_NONE:
> > > + return;
> > > + break;
> > > + case MIGRATION_STATUS_SETUP:
> > > + case MIGRATION_STATUS_CANCELLING:
> > > + case MIGRATION_STATUS_CANCELLED:
> > > + case MIGRATION_STATUS_ACTIVE:
> > > + case MIGRATION_STATUS_POSTCOPY_ACTIVE:
> > > + case MIGRATION_STATUS_FAILED:
> > > + case MIGRATION_STATUS_COLO:
> > > + info->has_status = true;
> > > + break;
> > > + case MIGRATION_STATUS_COMPLETED:
> > > + info->has_status = true;
> > > + fill_destination_postcopy_migration_info(info);
> > > + break;
> > > + }
> > > + info->status = mis->state;
> > > +}
> > > +
> > > +MigrationInfo *qmp_query_migrate(Error **errp)
> > > +{
> > > + MigrationInfo *info = g_malloc0(sizeof(*info));
> > > +
> > > + fill_destination_migration_info(info);
> > > + fill_source_migration_info(info);
> > > +
> > > + return info;
> > > +}
> > > +
> > > void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
> > > Error **errp)
> > > {
> > > diff --git a/migration/migration.h b/migration/migration.h
> > > index 770466b..882a59b 100644
> > > --- a/migration/migration.h
> > > +++ b/migration/migration.h
> > > @@ -70,6 +70,10 @@ struct MigrationIncomingState {
> > > MigrationIncomingState *migration_incoming_get_current(void);
> > > void migration_incoming_state_destroy(void);
> > > +/*
> > > + * Functions to work with blocktime context
> > > + */
> > > +void fill_destination_postcopy_migration_info(MigrationInfo *info);
> > > #define TYPE_MIGRATION "migration"
> > > diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> > > index 9a5133f..5fdbf1e 100644
> > > --- a/migration/postcopy-ram.c
> > > +++ b/migration/postcopy-ram.c
> > > @@ -113,6 +113,55 @@ static struct PostcopyBlocktimeContext *blocktime_context_new(void)
> > > return ctx;
> > > }
> > > +static int64List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx)
> > > +{
> > > + int64List *list = NULL, *entry = NULL;
> > > + int i;
> > > +
> > > + for (i = smp_cpus - 1; i >= 0; i--) {
> > > + entry = g_new0(int64List, 1);
> > > + entry->value = ctx->vcpu_blocktime[i];
> > > + entry->next = list;
> > > + list = entry;
> > > + }
> > > +
> > > + return list;
> > > +}
> > > +
> > > +/*
> > > + * This function just populates MigrationInfo from postcopy's
> > > + * blocktime context. It will not populate MigrationInfo,
> > > + * unless postcopy-blocktime capability was set.
> > > + *
> > > + * @info: pointer to MigrationInfo to populate
> > > + */
> > > +void fill_destination_postcopy_migration_info(MigrationInfo *info)
> > > +{
> > > + MigrationIncomingState *mis = migration_incoming_get_current();
> > > + PostcopyBlocktimeContext *bc = mis->blocktime_ctx;
> > > +
> > > + if (!bc) {
> > > + return;
> > > + }
> > > +
> > > + info->has_postcopy_blocktime = true;
> > > + info->postcopy_blocktime = bc->total_blocktime;
> > > + info->has_postcopy_vcpu_blocktime = true;
> > > + info->postcopy_vcpu_blocktime = get_vcpu_blocktime_list(bc);
> > > +}
> > > +
> > > +static uint64_t get_postcopy_total_blocktime(void)
> > > +{
> > > + MigrationIncomingState *mis = migration_incoming_get_current();
> > > + PostcopyBlocktimeContext *bc = mis->blocktime_ctx;
> > > +
> > > + if (!bc) {
> > > + return 0;
> > > + }
> > > +
> > > + return bc->total_blocktime;
> > > +}
> > > +
> > > /**
> > > * receive_ufd_features: check userfault fd features, to request only supported
> > > * features in the future.
> > > @@ -487,6 +536,9 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
> > > munmap(mis->postcopy_tmp_zero_page, mis->largest_page_size);
> > > mis->postcopy_tmp_zero_page = NULL;
> > > }
> > > + trace_postcopy_ram_incoming_cleanup_blocktime(
> > > + get_postcopy_total_blocktime());
> > > +
> > > trace_postcopy_ram_incoming_cleanup_exit();
> > > return 0;
> > > }
> > > @@ -958,6 +1010,11 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis)
> > > #else
> > > /* No target OS support, stubs just fail */
> > > +void fill_destination_postcopy_migration_info(MigrationInfo *info)
> > > +{
> > > + error_report("%s: No OS support", __func__);
> > > +}
> > > +
> > Do we want that error_report? info migrate shouldn't give an error on a
> > non-postcopy host.
> >
> > Also, don't you fancy just checking for the presence of this new info in
> > the test?
> I'll add assert, like that
> g_assert(qdict_haskey(rsp_return, "postcopy-blocktime"));
Yes, that seems reasonable.
> when host supports UFFD_FEATURE_THREAD_ID
Great; note that needs to be runtime, not the ifdef.
Dave
> --
> Best regards,
> Alexey Perevalov
> >
> > Dave
> >
> > > bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
> > > {
> > > error_report("%s: No OS support", __func__);
> > > diff --git a/migration/trace-events b/migration/trace-events
> > > index 01f30fe..741f2ae 100644
> > > --- a/migration/trace-events
> > > +++ b/migration/trace-events
> > > @@ -197,6 +197,7 @@ postcopy_ram_incoming_cleanup_closeuf(void) ""
> > > postcopy_ram_incoming_cleanup_entry(void) ""
> > > postcopy_ram_incoming_cleanup_exit(void) ""
> > > postcopy_ram_incoming_cleanup_join(void) ""
> > > +postcopy_ram_incoming_cleanup_blocktime(uint64_t total) "total blocktime %" PRIu64
> > > save_xbzrle_page_skipping(void) ""
> > > save_xbzrle_page_overflow(void) ""
> > > ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: %" PRIu64 " milliseconds, %d iterations"
> > > diff --git a/qapi/migration.json b/qapi/migration.json
> > > index 2e4a15d..55b055e 100644
> > > --- a/qapi/migration.json
> > > +++ b/qapi/migration.json
> > > @@ -150,6 +150,13 @@
> > > # @status is 'failed'. Clients should not attempt to parse the
> > > # error strings. (Since 2.7)
> > > #
> > > +# @postcopy-blocktime: total time when all vCPU were blocked during postcopy
> > > +# live migration (Since 2.11)
> > > +#
> > > +# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU (Since 2.10)
> > > +#
> > > +
> > > +#
> > > # Since: 0.14.0
> > > ##
> > > { 'struct': 'MigrationInfo',
> > > @@ -161,7 +168,9 @@
> > > '*downtime': 'int',
> > > '*setup-time': 'int',
> > > '*cpu-throttle-percentage': 'int',
> > > - '*error-desc': 'str'} }
> > > + '*error-desc': 'str',
> > > + '*postcopy-blocktime' : 'int64',
> > > + '*postcopy-vcpu-blocktime': ['int64']} }
> > > ##
> > > # @query-migrate:
> > > --
> > > 1.9.1
> > >
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> >
> >
> >
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2017-09-21 16:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170919164818eucas1p292f634ca79c4b7ed8e83d1529dd23c04@eucas1p2.samsung.com>
2017-09-19 16:47 ` [Qemu-devel] [PATCH v10 00/10] calculate blocktime for postcopy live migration Alexey Perevalov
[not found] ` <CGME20170919164820eucas1p25f16f91aa65933fa18cdff7cb7b7444c@eucas1p2.samsung.com>
2017-09-19 16:47 ` [Qemu-devel] [PATCH v10 01/10] userfault: update kernel header for UFFD_FEATURE_* Alexey Perevalov
2017-09-20 18:43 ` Dr. David Alan Gilbert
2017-09-21 7:33 ` Alexey Perevalov
[not found] ` <CGME20170919164821eucas1p2c3d141e6ae576901e95212d1136b0453@eucas1p2.samsung.com>
2017-09-19 16:47 ` [Qemu-devel] [PATCH v10 02/10] migration: pass MigrationIncomingState* into migration check functions Alexey Perevalov
2017-09-20 9:01 ` Juan Quintela
[not found] ` <CGME20170919164822eucas1p2e2b1f9bbf32fdb171a8db1e6d75941ef@eucas1p2.samsung.com>
2017-09-19 16:47 ` [Qemu-devel] [PATCH v10 03/10] migration: fix hardcoded function name in error report Alexey Perevalov
[not found] ` <CGME20170919164822eucas1p27957a05191b242b4982f62fab15a4539@eucas1p2.samsung.com>
2017-09-19 16:47 ` [Qemu-devel] [PATCH v10 04/10] migration: split ufd_version_check onto receive/request features part Alexey Perevalov
[not found] ` <CGME20170919164823eucas1p25540d608fc48a5e0ebd2f170416aec45@eucas1p2.samsung.com>
2017-09-19 16:47 ` [Qemu-devel] [PATCH v10 05/10] migration: introduce postcopy-blocktime capability Alexey Perevalov
[not found] ` <CGME20170919164824eucas1p23607e53e3ea38f8be4e885bb960e803f@eucas1p2.samsung.com>
2017-09-19 16:48 ` [Qemu-devel] [PATCH v10 06/10] migration: add postcopy blocktime ctx into MigrationIncomingState Alexey Perevalov
2017-09-21 10:16 ` Dr. David Alan Gilbert
2017-09-21 11:27 ` Alexey Perevalov
[not found] ` <CGME20170919164825eucas1p213639e95387bf054270d020f1d7dbfe9@eucas1p2.samsung.com>
2017-09-19 16:48 ` [Qemu-devel] [PATCH v10 07/10] migration: calculate vCPU blocktime on dst side Alexey Perevalov
2017-09-21 11:57 ` Dr. David Alan Gilbert
2017-09-22 8:47 ` Alexey Perevalov
2017-09-28 8:01 ` Alexey Perevalov
[not found] ` <CGME20170919164825eucas1p21fd133a55091e4a09fdeee05d130260d@eucas1p2.samsung.com>
2017-09-19 16:48 ` [Qemu-devel] [PATCH v10 08/10] migration: postcopy_blocktime documentation Alexey Perevalov
2017-09-21 12:33 ` Dr. David Alan Gilbert
2017-09-21 13:26 ` Alexey Perevalov
2017-09-21 14:40 ` Dr. David Alan Gilbert
[not found] ` <CGME20170919164826eucas1p249e6e9759612d74cd5c69bd375a01cd9@eucas1p2.samsung.com>
2017-09-19 16:48 ` [Qemu-devel] [PATCH v10 09/10] migration: add blocktime calculation into postcopy-test Alexey Perevalov
2017-09-21 12:39 ` Dr. David Alan Gilbert
[not found] ` <CGME20170919164827eucas1p231a5b9afd8e81427db114e57a0b6fbbe@eucas1p2.samsung.com>
2017-09-19 16:48 ` [Qemu-devel] [PATCH v10 10/10] migration: add postcopy total blocktime into query-migrate Alexey Perevalov
2017-09-19 17:41 ` Eric Blake
2017-09-21 12:42 ` Dr. David Alan Gilbert
2017-09-21 15:24 ` Alexey Perevalov
2017-09-21 16:44 ` Dr. David Alan Gilbert [this message]
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=20170921164431.GK2717@work-vm \
--to=dgilbert@redhat.com \
--cc=a.perevalov@samsung.com \
--cc=eblake@redhat.com \
--cc=heetae82.ahn@samsung.com \
--cc=i.maximets@samsung.com \
--cc=peterx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).