From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org,
Leonardo Bras Soares Passos <lsoaresp@redhat.com>,
James Houghton <jthoughton@google.com>,
Juan Quintela <quintela@redhat.com>
Subject: Re: [PATCH RFC 11/21] migration: Add hugetlb-doublemap cap
Date: Tue, 24 Jan 2023 12:45:38 +0000 [thread overview]
Message-ID: <Y8/S8g4s42RCBTEV@work-vm> (raw)
In-Reply-To: <20230117220914.2062125-12-peterx@redhat.com>
* Peter Xu (peterx@redhat.com) wrote:
> Add a new cap to allow mapping hugetlbfs backed RAMs in small page sizes.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
although, I'm curious if the protocol actually changes - or whether
a doublepage enabled destination would work with an unmodified source?
I guess potentially you can get away without the dirty clearing of the
partially sent hugepages that the source normally does.
Dave
> ---
> migration/migration.c | 48 ++++++++++++++++++++++++++++++++++++++++++-
> migration/migration.h | 1 +
> qapi/migration.json | 7 ++++++-
> 3 files changed, 54 insertions(+), 2 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 64f74534e2..b174f2af92 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -17,6 +17,7 @@
> #include "qemu/cutils.h"
> #include "qemu/error-report.h"
> #include "qemu/main-loop.h"
> +#include "qemu/madvise.h"
> #include "migration/blocker.h"
> #include "exec.h"
> #include "fd.h"
> @@ -62,6 +63,7 @@
> #include "sysemu/cpus.h"
> #include "yank_functions.h"
> #include "sysemu/qtest.h"
> +#include "exec/ramblock.h"
>
> #define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
>
> @@ -1363,12 +1365,47 @@ static bool migrate_caps_check(bool *cap_list,
> "Zero copy only available for non-compressed non-TLS multifd migration");
> return false;
> }
> +
> + if (cap_list[MIGRATION_CAPABILITY_HUGETLB_DOUBLEMAP]) {
> + RAMBlock *rb;
> +
> + /* Check whether the platform/binary supports the new madvise()s */
> +
> +#if QEMU_MADV_SPLIT == QEMU_MADV_INVALID
> + error_setg(errp, "MADV_SPLIT is not supported by the QEMU binary");
> + return false;
> +#endif
> +
> +#if QEMU_MADV_COLLAPSE == QEMU_MADV_INVALID
> + error_setg(errp, "MADV_COLLAPSE is not supported by the QEMU binary");
> + return false;
> +#endif
> +
> + /*
> + * Check against kernel support of MADV_SPLIT is not easy, delay
> + * that until we have all the hugetlb mappings ready on dest node,
> + * meanwhile do the best effort check here because doublemap
> + * requires the hugetlb ramblocks to be shared first.
> + */
> + RAMBLOCK_FOREACH_NOT_IGNORED(rb) {
> + if (qemu_ram_is_hugetlb(rb) && !qemu_ram_is_shared(rb)) {
> + error_setg(errp, "RAMBlock '%s' needs to be shared for doublemap",
> + rb->idstr);
> + return false;
> + }
> + }
> + }
> #else
> if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) {
> error_setg(errp,
> "Zero copy currently only available on Linux");
> return false;
> }
> +
> + if (cap_list[MIGRATION_CAPABILITY_HUGETLB_DOUBLEMAP]) {
> + error_setg(errp, "Hugetlb doublemap is only supported on Linux");
> + return false;
> + }
> #endif
>
> if (cap_list[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) {
> @@ -2792,6 +2829,13 @@ bool migrate_postcopy_preempt(void)
> return s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
> }
>
> +bool migrate_hugetlb_doublemap(void)
> +{
> + MigrationState *s = migrate_get_current();
> +
> + return s->enabled_capabilities[MIGRATION_CAPABILITY_HUGETLB_DOUBLEMAP];
> +}
> +
> /* migration thread support */
> /*
> * Something bad happened to the RP stream, mark an error
> @@ -4472,7 +4516,9 @@ static Property migration_properties[] = {
> DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH),
> DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD),
> DEFINE_PROP_MIG_CAP("x-background-snapshot",
> - MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
> + MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT),
> + DEFINE_PROP_MIG_CAP("hugetlb-doublemap",
> + MIGRATION_CAPABILITY_HUGETLB_DOUBLEMAP),
> #ifdef CONFIG_LINUX
> DEFINE_PROP_MIG_CAP("x-zero-copy-send",
> MIGRATION_CAPABILITY_ZERO_COPY_SEND),
> diff --git a/migration/migration.h b/migration/migration.h
> index 5674a13876..bbd610a2d5 100644
> --- a/migration/migration.h
> +++ b/migration/migration.h
> @@ -447,6 +447,7 @@ bool migrate_use_events(void);
> bool migrate_postcopy_blocktime(void);
> bool migrate_background_snapshot(void);
> bool migrate_postcopy_preempt(void);
> +bool migrate_hugetlb_doublemap(void);
>
> /* Sending on the return path - generic and then for each message type */
> void migrate_send_rp_shut(MigrationIncomingState *mis,
> diff --git a/qapi/migration.json b/qapi/migration.json
> index 88ecf86ac8..b23516e75e 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -477,6 +477,11 @@
> # will be handled faster. This is a performance feature and
> # should not affect the correctness of postcopy migration.
> # (since 7.1)
> +# @hugetlb-doublemap: If enabled, the migration process will allow postcopy
> +# to handle page faults based on small pages even if
> +# hugetlb is used. This will drastically reduce page
> +# fault latencies when hugetlb is used as the guest RAM
> +# backends. (since 7.3)
> #
> # Features:
> # @unstable: Members @x-colo and @x-ignore-shared are experimental.
> @@ -492,7 +497,7 @@
> 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate',
> { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] },
> 'validate-uuid', 'background-snapshot',
> - 'zero-copy-send', 'postcopy-preempt'] }
> + 'zero-copy-send', 'postcopy-preempt', 'hugetlb-doublemap'] }
>
> ##
> # @MigrationCapabilityStatus:
> --
> 2.37.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2023-01-24 12:46 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 22:08 [PATCH RFC 00/21] migration: Support hugetlb doublemaps Peter Xu
2023-01-17 22:08 ` [PATCH RFC 01/21] update linux headers Peter Xu
2023-01-17 22:08 ` [PATCH RFC 02/21] util: Include osdep.h first in util/mmap-alloc.c Peter Xu
2023-01-18 12:00 ` Dr. David Alan Gilbert
2023-01-25 0:19 ` Philippe Mathieu-Daudé
2023-01-30 4:57 ` Juan Quintela
2023-01-17 22:08 ` [PATCH RFC 03/21] physmem: Add qemu_ram_is_hugetlb() Peter Xu
2023-01-18 12:02 ` Dr. David Alan Gilbert
2023-01-30 5:00 ` Juan Quintela
2023-01-17 22:08 ` [PATCH RFC 04/21] madvise: Include linux/mman.h under linux-headers/ Peter Xu
2023-01-18 12:08 ` Dr. David Alan Gilbert
2023-01-30 5:01 ` Juan Quintela
2023-01-17 22:08 ` [PATCH RFC 05/21] madvise: Add QEMU_MADV_SPLIT Peter Xu
2023-01-30 5:01 ` Juan Quintela
2023-01-17 22:08 ` [PATCH RFC 06/21] madvise: Add QEMU_MADV_COLLAPSE Peter Xu
2023-01-18 18:51 ` Dr. David Alan Gilbert
2023-01-18 20:21 ` Peter Xu
2023-01-30 5:02 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 07/21] ramblock: Cache file offset for file-backed ramblocks Peter Xu
2023-01-30 5:02 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 08/21] ramblock: Cache the length to do file mmap() on ramblocks Peter Xu
2023-01-23 18:51 ` Dr. David Alan Gilbert
2023-01-24 20:28 ` Peter Xu
2023-01-30 5:05 ` Juan Quintela
2023-01-30 22:07 ` Peter Xu
2023-01-17 22:09 ` [PATCH RFC 09/21] ramblock: Add RAM_READONLY Peter Xu
2023-01-23 19:42 ` Dr. David Alan Gilbert
2023-01-30 5:06 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 10/21] ramblock: Add ramblock_file_map() Peter Xu
2023-01-24 10:06 ` Dr. David Alan Gilbert
2023-01-24 20:47 ` Peter Xu
2023-01-25 9:24 ` Dr. David Alan Gilbert
2023-01-25 14:46 ` Peter Xu
2023-01-30 5:09 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 11/21] migration: Add hugetlb-doublemap cap Peter Xu
2023-01-24 12:45 ` Dr. David Alan Gilbert [this message]
2023-01-24 21:15 ` Peter Xu
2023-01-30 5:13 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 12/21] migration: Introduce page size for-migration-only Peter Xu
2023-01-24 13:20 ` Dr. David Alan Gilbert
2023-01-24 21:36 ` Peter Xu
2023-01-24 22:03 ` Peter Xu
2023-01-30 5:17 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 13/21] migration: Add migration_ram_pagesize_largest() Peter Xu
2023-01-24 17:34 ` Dr. David Alan Gilbert
2023-01-30 5:19 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 14/21] migration: Map hugetlbfs ramblocks twice, and pre-allocate Peter Xu
2023-01-25 14:25 ` Dr. David Alan Gilbert
2023-01-30 5:24 ` Juan Quintela
2023-01-30 22:35 ` Peter Xu
2023-02-01 18:53 ` Juan Quintela
2023-02-06 21:40 ` Peter Xu
2023-01-17 22:09 ` [PATCH RFC 15/21] migration: Teach qemu about minor faults and doublemap Peter Xu
2023-01-30 5:45 ` Juan Quintela
2023-01-30 22:50 ` Peter Xu
2023-02-01 18:55 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 16/21] migration: Enable doublemap with MADV_SPLIT Peter Xu
2023-02-01 18:59 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 17/21] migration: Rework ram discard logic for hugetlb double-map Peter Xu
2023-02-01 19:03 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 18/21] migration: Allow postcopy_register_shared_ufd() to fail Peter Xu
2023-02-01 19:09 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 19/21] migration: Add postcopy_mark_received() Peter Xu
2023-02-01 19:10 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 20/21] migration: Handle page faults using UFFDIO_CONTINUE Peter Xu
2023-02-01 19:24 ` Juan Quintela
2023-02-01 19:52 ` Juan Quintela
2023-01-17 22:09 ` [PATCH RFC 21/21] migration: Collapse huge pages again after postcopy finished Peter Xu
2023-02-01 19:49 ` Juan Quintela
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=Y8/S8g4s42RCBTEV@work-vm \
--to=dgilbert@redhat.com \
--cc=jthoughton@google.com \
--cc=lsoaresp@redhat.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).