Skip to contentSkip to conversation

Introduce multifd zero page checking.

PATCH Superseded Hao Xiang 3 participants 20 messages Feb 6, 2024 – Feb 8, 2024

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Hao Xiang

author
#0 lore raw

cover Introduce multifd zero page checking.

This patchset is based on Juan Quintela's old series here
https://lore.kernel.org/all/[email protected]/

In the multifd live migration model, there is a single migration main thread scanning the page map, queuing the pages to multiple multifd sender threads. The migration main thread runs zero page checking on every page before queuing the page to the sender threads. Zero page checking is a CPU intensive task and hence having a single thread doing all that doesn't scale well. This change introduces a new function to run the zero page checking on the multifd sender threads. This patchset also lays the ground work for future changes to offload zero page checking task to accelerator hardwares.

Use two Intel 4th generation Xeon servers for testing.

Architecture:        x86_64
CPU(s):              192
Thread(s) per core:  2
Core(s) per socket:  48
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               143
Model name:          Intel(R) Xeon(R) Platinum 8457C
Stepping:            8
CPU MHz:             2538.624
CPU max MHz:         3800.0000
CPU min MHz:         800.0000

Perform multifd live migration with below setup:
1. VM has 100GB memory. All pages in the VM are zero pages.
2. Use tcp socket for live migratio.
3. Use 4 multifd channels and zero page checking on migration main thread.
4. Use 1/2/4 multifd channels and zero page checking on multifd sender threads.
5. Record migration total time from sender QEMU console's "info migrate" command.
6. Calculate throughput with "100GB / total time".

+------------------------------------------------------+
|zero-page-checking | total-time(ms) | throughput(GB/s)|
+------------------------------------------------------+
|main-thread        | 9629           | 10.38GB/s       |
+------------------------------------------------------+
|multifd-1-threads  | 6182           | 16.17GB/s       |
+------------------------------------------------------+
|multifd-2-threads  | 4643           | 21.53GB/s       |
+------------------------------------------------------+
|multifd-4-threads  | 4143           | 24.13GB/s       |
+------------------------------------------------------+

Apply this patchset on top of commit
39a6e4f87e7b75a45b08d6dc8b8b7c2954c87440

Hao Xiang (6):
migration/multifd: Add new migration option multifd-zero-page. migration/multifd: Add zero pages and zero bytes counter to migration
status interface.
migration/multifd: Support for zero pages transmission in multifd
format.
migration/multifd: Zero page transmission on the multifd thread. migration/multifd: Enable zero page checking from multifd threads. migration/multifd: Add a new migration test case for legacy zero page
checking.

 migration/migration-hmp-cmds.c |  11 ++++
 migration/multifd.c            | 106 ++++++++++++++++++++++++++++-----
 migration/multifd.h            |  22 ++++++-
 migration/options.c            |  20 +++++++
 migration/options.h            |   1 +
 migration/ram.c                |  49 ++++++++++++---
 migration/trace-events         |   8 +--
 qapi/migration.json            |  39 ++++++++++--
 tests/qtest/migration-test.c   |  26 ++++++++
 9 files changed, 249 insertions(+), 33 deletions(-)
Signature · 1 line
2.30.2
author
#1 lore raw

PATCH 1/6 migration/multifd: Add new migration option multifd-zero-page.

This new parameter controls where the zero page checking is running. If this parameter is set to true, zero page checking is done in the multifd sender threads. If this parameter is set to false, zero page checking is done in the migration main thread.

---
 migration/migration-hmp-cmds.c |  7 +++++++
 migration/options.c            | 20 ++++++++++++++++++++
 migration/options.h            |  1 +
 qapi/migration.json            | 24 +++++++++++++++++++++---
 4 files changed, 49 insertions(+), 3 deletions(-)
migration/migration-hmp-cmds.c +7 -0
index 99b49df5dd..8b0c205a41 100644
@@ -344,6 +344,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "%s: %s\n",
             MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION),
             MultiFDCompression_str(params->multifd_compression));
+        monitor_printf(mon, "%s: %s\n",
+            MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_ZERO_PAGE),
+            params->multifd_zero_page ? "on" : "off");
         monitor_printf(mon, "%s: %" PRIu64 " bytes\n",
             MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE),
             params->xbzrle_cache_size);
@@ -634,6 +637,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
         p->has_multifd_zstd_level = true;
         visit_type_uint8(v, param, &p->multifd_zstd_level, &err);
         break;
+    case MIGRATION_PARAMETER_MULTIFD_ZERO_PAGE:
+        p->has_multifd_zero_page = true;
+        visit_type_bool(v, param, &p->multifd_zero_page, &err);
+        break;
     case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
         p->has_xbzrle_cache_size = true;
         if (!visit_type_size(v, param, &cache_size, &err)) {
migration/options.c +20 -0
index 3e3e0b93b4..cb18a41267 100644
@@ -179,6 +179,8 @@ Property migration_properties[] = {
     DEFINE_PROP_MIG_MODE("mode", MigrationState,
                       parameters.mode,
                       MIG_MODE_NORMAL),
+    DEFINE_PROP_BOOL("multifd-zero-page", MigrationState,
+                     parameters.multifd_zero_page, true),
 
     /* Migration capabilities */
     DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
@@ -903,6 +905,13 @@ uint64_t migrate_xbzrle_cache_size(void)
     return s->parameters.xbzrle_cache_size;
 }
 
+bool migrate_multifd_zero_page(void)
+{
+    MigrationState *s = migrate_get_current();
+
+    return s->parameters.multifd_zero_page;
+}
+
 /* parameter setters */
 
 void migrate_set_block_incremental(bool value)
@@ -1013,6 +1022,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
     params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit;
     params->has_mode = true;
     params->mode = s->parameters.mode;
+    params->has_multifd_zero_page = true;
+    params->multifd_zero_page = s->parameters.multifd_zero_page;
 
     return params;
 }
@@ -1049,6 +1060,7 @@ void migrate_params_init(MigrationParameters *params)
     params->has_x_vcpu_dirty_limit_period = true;
     params->has_vcpu_dirty_limit = true;
     params->has_mode = true;
+    params->has_multifd_zero_page = true;
 }
 
 /*
@@ -1350,6 +1362,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
     if (params->has_mode) {
         dest->mode = params->mode;
     }
+
+    if (params->has_multifd_zero_page) {
+        dest->multifd_zero_page = params->multifd_zero_page;
+    }
 }
 
 static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
@@ -1494,6 +1510,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
     if (params->has_mode) {
         s->parameters.mode = params->mode;
     }
+
+    if (params->has_multifd_zero_page) {
+        s->parameters.multifd_zero_page = params->multifd_zero_page;
+    }
 }
 
 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
migration/options.h +1 -0
index 246c160aee..c080a6ba18 100644
@@ -93,6 +93,7 @@ const char *migrate_tls_authz(void);
 const char *migrate_tls_creds(void);
 const char *migrate_tls_hostname(void);
 uint64_t migrate_xbzrle_cache_size(void);
+bool migrate_multifd_zero_page(void);
 
 /* parameters setters */
 
qapi/migration.json +21 -3
index 819708321d..ff033a0344 100644
@@ -874,6 +874,11 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-zero-page: Multifd zero page checking. If the parameter is true,
+#     zero page checking is done on the multifd sender thread. If the parameter
+#     is false, zero page checking is done on the migration main thread. Default
+#     is set to true. (Since 9.0)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -907,7 +912,8 @@
            'block-bitmap-mapping',
            { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] },
            'vcpu-dirty-limit',
-           'mode'] }
+           'mode',
+           'multifd-zero-page'] }
 
 ##
 # @MigrateSetParameters:
@@ -1062,6 +1068,11 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-zero-page: Multifd zero page checking. If the parameter is true,
+#     zero page checking is done on the multifd sender thread. If the parameter
+#     is false, zero page checking is done on the migration main thread. Default
+#     is set to true. (Since 9.0)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -1115,7 +1126,8 @@
             '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
                                             'features': [ 'unstable' ] },
             '*vcpu-dirty-limit': 'uint64',
-            '*mode': 'MigMode'} }
+            '*mode': 'MigMode',
+            '*multifd-zero-page': 'bool'} }
 
 ##
 # @migrate-set-parameters:
@@ -1290,6 +1302,11 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-zero-page: Multifd zero page checking. If the parameter is true,
+#     zero page checking is done on the multifd sender thread. If the parameter
+#     is false, zero page checking is done on the migration main thread. Default
+#     is set to true. (Since 9.0)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -1340,7 +1357,8 @@
             '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
                                             'features': [ 'unstable' ] },
             '*vcpu-dirty-limit': 'uint64',
-            '*mode': 'MigMode'} }
+            '*mode': 'MigMode',
+            '*multifd-zero-page': 'bool'} }
 
 ##
 # @query-migrate-parameters:
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/6] migration/multifd: Add new migration option multifd-zero-page.

qapi/migration.json line 880

Quoted 12 lines · Hao Xiang
qapi/migration.json +4 -0
index 819708321d..ff033a0344 100644
@@ -874,6 +874,11 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-zero-page: Multifd zero page checking. If the parameter is true,
+#     zero page checking is done on the multifd sender thread. If the parameter
+#     is false, zero page checking is done on the migration main thread. Default
+#     is set to true. (Since 9.0)

I replied somewhere before on this, but I can try again..

Do you think it'll be better to introduce a generic parameter for zero page detection?

- "none" if disabled,
- "legacy" for main thread,
- "multifd" for multifd (software-based).

A string could work, but maybe cleaner to introduce @MigrationZeroPageDetector enum?

When you add more, you can keep extending that with the single field ("multifd-dsa", etc.).

Signature · 1 line
Peter Xu
author
#3 lore raw

Re: [External] Re: [PATCH 1/6] migration/multifd: Add new migration option multifd-zero-page.

Quoted 24 lines · Peter Xu

qapi/migration.json line 880

Quoted 12 lines · Hao Xiang
qapi/migration.json +4 -0
index 819708321d..ff033a0344 100644
@@ -874,6 +874,11 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-zero-page: Multifd zero page checking. If the parameter is true,
+#     zero page checking is done on the multifd sender thread. If the parameter
+#     is false, zero page checking is done on the migration main thread. Default
+#     is set to true. (Since 9.0)

I replied somewhere before on this, but I can try again..

Do you think it'll be better to introduce a generic parameter for zero page detection?

- "none" if disabled,
- "legacy" for main thread,
- "multifd" for multifd (software-based).

Quoted 9 lines

A string could work, but maybe cleaner to introduce @MigrationZeroPageDetector enum?

When you add more, you can keep extending that with the single field ("multifd-dsa", etc.).

--
Peter Xu

Sorry I overlooked the previous email. This sounds like a good idea.

author
#4 lore raw

PATCH 2/6 migration/multifd: Add zero pages and zero bytes counter to migration status interface.

In reply to Hao Xiang

This change extends the MigrationStatus interface to track zero pages and zero bytes counter.

---
 qapi/migration.json | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
qapi/migration.json +14 -1
index ff033a0344..69366fe3f4 100644
@@ -63,6 +63,10 @@
 #     between 0 and @dirty-sync-count * @multifd-channels.  (since
 #     7.1)
 #
+# @zero: number of zero pages (since 9.0)
+#
+# @zero-bytes: number of zero bytes sent (since 9.0)
+#
 # Features:
 #
 # @deprecated: Member @skipped is always zero since 1.5.3
@@ -81,7 +85,8 @@
            'multifd-bytes': 'uint64', 'pages-per-second': 'uint64',
            'precopy-bytes': 'uint64', 'downtime-bytes': 'uint64',
            'postcopy-bytes': 'uint64',
-           'dirty-sync-missed-zero-copy': 'uint64' } }
+           'dirty-sync-missed-zero-copy': 'uint64',
+           'zero': 'int', 'zero-bytes': 'int' } }
 
 ##
 # @XBZRLECacheStats:
@@ -332,6 +337,8 @@
 #           "duplicate":123,
 #           "normal":123,
 #           "normal-bytes":123456,
+#           "zero":123,
+#           "zero-bytes":123456,
 #           "dirty-sync-count":15
 #         }
 #      }
@@ -358,6 +365,8 @@
 #             "duplicate":123,
 #             "normal":123,
 #             "normal-bytes":123456,
+#             "zero":123,
+#             "zero-bytes":123456,
 #             "dirty-sync-count":15
 #          }
 #       }
@@ -379,6 +388,8 @@
 #             "duplicate":123,
 #             "normal":123,
 #             "normal-bytes":123456,
+#             "zero":123,
+#             "zero-bytes":123456,
 #             "dirty-sync-count":15
 #          },
 #          "disk":{
@@ -405,6 +416,8 @@
 #             "duplicate":10,
 #             "normal":3333,
 #             "normal-bytes":3412992,
+#             "zero":3333,
+#             "zero-bytes":3412992,
 #             "dirty-sync-count":15
 #          },
 #          "xbzrle-cache":{
Signature · 1 line
2.30.2
Reviewed-by on v1 2/6
#5 lore raw

Re: [PATCH 2/6] migration/multifd: Add zero pages and zero bytes counter to migration status interface.

Quoted 4 lines · Hao Xiang

This change extends the MigrationStatus interface to track zero pages and zero bytes counter.

When post anything QAPI relevant, please always remember to copy QAPI maintainers too, thanks.

$ ./scripts/get_maintainer.pl -f qapi/migration.json 
Eric Blake <[email protected]> (supporter:QAPI Schema)
Markus Armbruster <[email protected]> (supporter:QAPI Schema)
Peter Xu <[email protected]> (maintainer:Migration)
Fabiano Rosas <[email protected]> (maintainer:Migration)
[email protected] (open list:All patches CC here)
Signature · 1 line
Peter Xu
#6 lore raw

Re: [PATCH 2/6] migration/multifd: Add zero pages and zero bytes counter to migration status interface.

Quoted 7 lines · Peter Xu
Quoted 4 lines · Hao Xiang

This change extends the MigrationStatus interface to track zero pages and zero bytes counter.

I'll need to scratch this, sorry..

The issue is I forgot we have "duplicate" which is exactly "zero page"s.. See:

    info->ram->duplicate = stat64_get(&mig_stats.zero_pages);

If you think the name too confusing and want a replacement, maybe it's fine and maybe we can do that. Then we can keep this zero page counter introduced, reporting the same value as duplicates, then with a follow up patch to deprecate "duplicate" parameter. See an exmaple on how to deprecate in 7b24d326348e1672.

One thing I'm not sure is whether Libvirt will be fine on losing "duplicates" after 2+ QEMU major releases. Copy Jiri for this. My understanding is that Libvirt should be keeping an eye on deprecation list and react, but I'd like to double check..

Or we can keep using "duplicates", but I agree it just reads weird..

Thanks,

Signature · 1 line
Peter Xu
#7 lore raw

Re: Re: [PATCH 2/6] migration/multifd: Add zero pages and zero bytes counter to migration status interface.

Quoted 22 lines · Peter Xu
Quoted 7 lines · Peter Xu
Quoted 4 lines · Hao Xiang

This change extends the MigrationStatus interface to track zero pages and zero bytes counter.

I'll need to scratch this, sorry..

The issue is I forgot we have "duplicate" which is exactly "zero page"s.. See:

    info->ram->duplicate = stat64_get(&mig_stats.zero_pages);

If you think the name too confusing and want a replacement, maybe it's fine and maybe we can do that. Then we can keep this zero page counter introduced, reporting the same value as duplicates, then with a follow up patch to deprecate "duplicate" parameter. See an exmaple on how to deprecate in 7b24d326348e1672.

Quoted 4 lines

One thing I'm not sure is whether Libvirt will be fine on losing "duplicates" after 2+ QEMU major releases. Copy Jiri for this. My understanding is that Libvirt should be keeping an eye on deprecation list and react, but I'd like to double check..

This should not be a big deal as we can internally map either one (depending on what QEMU supports) to the same libvirt's field. AFAIK there is a consensus on Cc-ing libvirt-devel on patches that deprecate QEMU interfaces so that we can update our code in time before the deprecated interface is dropped.

BTW, libvirt maps "duplicate" to:

/**
* VIR_DOMAIN_JOB_MEMORY_CONSTANT:
*
* virDomainGetJobStats field: number of pages filled with a constant
* byte (all bytes in a single page are identical) transferred since the
* beginning of the migration job, as VIR_TYPED_PARAM_ULLONG.
*
* The most common example of such pages are zero pages, i.e., pages filled
* with zero bytes.
*
* Since: 1.0.3
*/

# define VIR_DOMAIN_JOB_MEMORY_CONSTANT          "memory_constant"

Jirka

author
#8 lore raw

Re: [External] Re: Re: [PATCH 2/6] migration/multifd: Add zero pages and zero bytes counter to migration status interface.

Quoted 49 lines · Jiri Denemark
Quoted 22 lines · Peter Xu
Quoted 7 lines · Peter Xu
Quoted 4 lines · Hao Xiang

This change extends the MigrationStatus interface to track zero pages and zero bytes counter.

I'll need to scratch this, sorry..

The issue is I forgot we have "duplicate" which is exactly "zero page"s.. See:

    info->ram->duplicate = stat64_get(&mig_stats.zero_pages);

If you think the name too confusing and want a replacement, maybe it's fine and maybe we can do that. Then we can keep this zero page counter introduced, reporting the same value as duplicates, then with a follow up patch to deprecate "duplicate" parameter. See an exmaple on how to deprecate in 7b24d326348e1672.

Quoted 4 lines

One thing I'm not sure is whether Libvirt will be fine on losing "duplicates" after 2+ QEMU major releases. Copy Jiri for this. My understanding is that Libvirt should be keeping an eye on deprecation list and react, but I'd like to double check..

This should not be a big deal as we can internally map either one (depending on what QEMU supports) to the same libvirt's field. AFAIK there is a consensus on Cc-ing libvirt-devel on patches that deprecate QEMU interfaces so that we can update our code in time before the deprecated interface is dropped.

BTW, libvirt maps "duplicate" to:

/**
* VIR_DOMAIN_JOB_MEMORY_CONSTANT:
*
* virDomainGetJobStats field: number of pages filled with a constant
* byte (all bytes in a single page are identical) transferred since the
* beginning of the migration job, as VIR_TYPED_PARAM_ULLONG.
*
* The most common example of such pages are zero pages, i.e., pages filled
* with zero bytes.
*
* Since: 1.0.3
*/

Quoted 4 lines
# define VIR_DOMAIN_JOB_MEMORY_CONSTANT          "memory_constant"

Jirka

Interesting. I didn't notice the existence of "duplicate" for zero pages. I do think the name is quite confusing. I will create the "zero/zero_bytes" counter and a separate commit to deprecate "duplicate". Will add libvirt devs per instruction above.

#9 lore raw

Re: [External] Re: Re: [PATCH 2/6] migration/multifd: Add zero pages and zero bytes counter to migration status interface.

Quoted 25 lines · Hao Xiang
Quoted 24 lines · Jiri Denemark
Quoted 22 lines · Peter Xu
Quoted 7 lines · Peter Xu
Quoted 4 lines · Hao Xiang

This change extends the MigrationStatus interface to track zero pages and zero bytes counter.

I'll need to scratch this, sorry..

The issue is I forgot we have "duplicate" which is exactly "zero page"s.. See:

    info->ram->duplicate = stat64_get(&mig_stats.zero_pages);

If you think the name too confusing and want a replacement, maybe it's fine and maybe we can do that. Then we can keep this zero page counter introduced, reporting the same value as duplicates, then with a follow up patch to deprecate "duplicate" parameter. See an exmaple on how to deprecate in 7b24d326348e1672.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

One thing I'm not sure is whether Libvirt will be fine on losing "duplicates" after 2+ QEMU major releases. Copy Jiri for this. My understanding is that Libvirt should be keeping an eye on deprecation list and react, but I'd like to double check..

This should not be a big deal as we can internally map either one (depending on what QEMU supports) to the same libvirt's field. AFAIK there is a consensus on Cc-ing libvirt-devel on patches that deprecate

I see.

Quoted 2 lines
Quoted 2 lines

QEMU interfaces so that we can update our code in time before the deprecated interface is dropped.

Right.

What I mostly worried is "old libvirt" + "new qemu", where the old libvirt only knows "duplicates", while the new (after 2 releases) will only report "zeros".

Quoted 17 lines
Quoted 17 lines

BTW, libvirt maps "duplicate" to:

/**
* VIR_DOMAIN_JOB_MEMORY_CONSTANT:
*
* virDomainGetJobStats field: number of pages filled with a constant
* byte (all bytes in a single page are identical) transferred since the
* beginning of the migration job, as VIR_TYPED_PARAM_ULLONG.
*
* The most common example of such pages are zero pages, i.e., pages filled
* with zero bytes.
*
* Since: 1.0.3
*/

# define VIR_DOMAIN_JOB_MEMORY_CONSTANT          "memory_constant"
Quoted 7 lines
Quoted 2 lines

Jirka

Interesting. I didn't notice the existence of "duplicate" for zero pages. I do think the name is quite confusing. I will create the "zero/zero_bytes" counter and a separate commit to deprecate "duplicate". Will add libvirt devs per instruction above.

Yeah, please go ahead, and I hope my worry is not a real concern above; we can figure that out later. Even without deprecating "duplicate", maybe it'll at least still be worthwhile we start having "zeros" reported alongside. Then after 10/20/30/N years we always have a chance to deprecate the other one, just a matter of compatible window.

Thanks,

Signature · 1 line
Peter Xu
author
#10 lore raw

PATCH 3/6 migration/multifd: Support for zero pages transmission in multifd format.

In reply to Hao Xiang

This change adds zero page counters and updates multifd send/receive tracing format to track the newly added counters.

---
 migration/migration-hmp-cmds.c |  4 ++++
 migration/multifd.c            | 43 ++++++++++++++++++++++++++--------
 migration/multifd.h            | 17 +++++++++++++-
 migration/trace-events         |  8 +++----
 4 files changed, 57 insertions(+), 15 deletions(-)
migration/migration-hmp-cmds.c +4 -0
index 8b0c205a41..2dd99b0509 100644
@@ -111,6 +111,10 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
                        info->ram->normal);
         monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n",
                        info->ram->normal_bytes >> 10);
+        monitor_printf(mon, "zero: %" PRIu64 " pages\n",
+                       info->ram->zero);
+        monitor_printf(mon, "zero bytes: %" PRIu64 " kbytes\n",
+                       info->ram->zero_bytes >> 10);
         monitor_printf(mon, "dirty sync count: %" PRIu64 "\n",
                        info->ram->dirty_sync_count);
         monitor_printf(mon, "page size: %" PRIu64 " kbytes\n",
migration/multifd.c +33 -10

135 lines not on this page · raw message

migration/multifd.h +16 -1
index 35d11f103c..6be9b2f6c1 100644
@@ -48,7 +48,10 @@ typedef struct {
     /* size of the next packet that contains pages */
     uint32_t next_packet_size;
     uint64_t packet_num;
-    uint64_t unused[4];    /* Reserved for future use */
+    /* zero pages */
+    uint32_t zero_pages;
+    uint32_t unused32[1];    /* Reserved for future use */
+    uint64_t unused64[3];    /* Reserved for future use */
     char ramblock[256];
     uint64_t offset[];
 } __attribute__((packed)) MultiFDPacket_t;
@@ -120,6 +123,8 @@ typedef struct {
     uint64_t num_packets;
     /* non zero pages sent through this channel */
     uint64_t total_normal_pages;
+    /* zero pages sent through this channel */
+    uint64_t total_zero_pages;
     /* buffers to send */
     struct iovec *iov;
     /* number of iovs used */
@@ -128,6 +133,10 @@ typedef struct {
     ram_addr_t *normal;
     /* num of non zero pages */
     uint32_t normal_num;
+    /* Pages that are zero */
+    ram_addr_t *zero;
+    /* num of zero pages */
+    uint32_t zero_num;
     /* used for compression methods */
     void *data;
 }  MultiFDSendParams;
@@ -179,12 +188,18 @@ typedef struct {
     uint8_t *host;
     /* non zero pages recv through this channel */
     uint64_t total_normal_pages;
+    /* zero pages recv through this channel */
+    uint64_t total_zero_pages;
     /* buffers to recv */
     struct iovec *iov;
     /* Pages that are not zero */
     ram_addr_t *normal;
     /* num of non zero pages */
     uint32_t normal_num;
+    /* Pages that are zero */
+    ram_addr_t *zero;
+    /* num of zero pages */
+    uint32_t zero_num;
     /* used for de-compression methods */
     void *data;
 } MultiFDRecvParams;
migration/trace-events +4 -4
index de4a743c8a..c0a758db9d 100644
@@ -128,21 +128,21 @@ postcopy_preempt_reset_channel(void) ""
 # multifd.c
 multifd_new_send_channel_async(uint8_t id) "channel %u"
 multifd_new_send_channel_async_error(uint8_t id, void *err) "channel=%u err=%p"
-multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u flags 0x%x next packet size %u"
+multifd_recv(uint8_t id, uint64_t packet_num, uint32_t normal, uint32_t zero, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u zero pages %u flags 0x%x next packet size %u"
 multifd_recv_new_channel(uint8_t id) "channel %u"
 multifd_recv_sync_main(long packet_num) "packet num %ld"
 multifd_recv_sync_main_signal(uint8_t id) "channel %u"
 multifd_recv_sync_main_wait(uint8_t id) "channel %u"
 multifd_recv_terminate_threads(bool error) "error %d"
-multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %u packets %" PRIu64 " pages %" PRIu64
+multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages, uint64_t zero_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 " zero pages %" PRIu64
 multifd_recv_thread_start(uint8_t id) "%u"
-multifd_send(uint8_t id, uint64_t packet_num, uint32_t normal, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u flags 0x%x next packet size %u"
+multifd_send(uint8_t id, uint64_t packet_num, uint32_t normalpages, uint32_t zero_pages, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u zero pages %u flags 0x%x next packet size %u"
 multifd_send_error(uint8_t id) "channel %u"
 multifd_send_sync_main(long packet_num) "packet num %ld"
 multifd_send_sync_main_signal(uint8_t id) "channel %u"
 multifd_send_sync_main_wait(uint8_t id) "channel %u"
 multifd_send_terminate_threads(bool error) "error %d"
-multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages) "channel %u packets %" PRIu64 " normal pages %"  PRIu64
+multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages, uint64_t zero_pages) "channel %u packets %" PRIu64 " normal pages %"  PRIu64 " zero pages %"  PRIu64
 multifd_send_thread_start(uint8_t id) "%u"
 multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s"
 multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s"
Signature · 1 line
2.30.2
#11 lore raw

Re: [PATCH 3/6] migration/multifd: Support for zero pages transmission in multifd format.

migration/multifd.c static void multifd_send_fill_packet(MultiFDSendParams *p) · line 267

Quoted 9 lines · Hao Xiang
migration/multifd.c +1 -0
index 25cbc6dc6b..a20d0ed10e 100644
@@ -264,6 +264,7 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
     packet->flags = cpu_to_be32(p->flags);
     packet->pages_alloc = cpu_to_be32(p->pages->allocated);
     packet->normal_pages = cpu_to_be32(p->normal_num);
+    packet->zero_pages = cpu_to_be32(p->zero_num);

This doesn't look right..

If to fill up the zero accounting only, we shouldn't be touching multifd packet at all since multifd zero page detection is not yet supported.

We should only reference mig_stats.zero_pages.

Quoted 2 lines
migration/multifd.c +0 -0
     packet->next_packet_size = cpu_to_be32(p->next_packet_size);
     packet->packet_num = cpu_to_be64(p->packet_num);
Signature · 1 line
Peter Xu
author
#12 lore raw

Re: [External] Re: [PATCH 3/6] migration/multifd: Support for zero pages transmission in multifd format.

Quoted 14 lines · Peter Xu

migration/multifd.c static void multifd_send_fill_packet(MultiFDSendParams *p) · line 267

Quoted 9 lines · Hao Xiang
migration/multifd.c +1 -0
index 25cbc6dc6b..a20d0ed10e 100644
@@ -264,6 +264,7 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
     packet->flags = cpu_to_be32(p->flags);
     packet->pages_alloc = cpu_to_be32(p->pages->allocated);
     packet->normal_pages = cpu_to_be32(p->normal_num);
+    packet->zero_pages = cpu_to_be32(p->zero_num);

This doesn't look right..

Quoted 4 lines

If to fill up the zero accounting only, we shouldn't be touching multifd packet at all since multifd zero page detection is not yet supported.

We should only reference mig_stats.zero_pages.

p->zero_num will always be 0 because multifd zero page checking is not yet enabled. The next commit will contain the code to calculate p->zero_num for each packet. This is just a preparation for the next commit that enables the feature. Main migration thread zero page goes through a different format. We are using the same counter mig_stats.zero_pages to track zero pages for both the legacy zero page checking and multifd zero page checking. These two are mutually exclusive so zero page will not be double counted.

Let me know if I am missing something.

Quoted 7 lines

migration/multifd.c static void multifd_send_fill_packet(MultiFDSendParams *p) · line 269

Quoted 3 lines
migration/multifd.c +0 -0
     packet->next_packet_size = cpu_to_be32(p->next_packet_size);
     packet->packet_num = cpu_to_be64(p->packet_num);

--
Peter Xu

author
#13 lore raw

PATCH 4/6 migration/multifd: Zero page transmission on the multifd thread.

In reply to Hao Xiang

This implements the zero page detection and handling on the multifd threads.

---
 migration/multifd.c | 62 +++++++++++++++++++++++++++++++++++++++++----
 migration/multifd.h |  5 ++++
 2 files changed, 62 insertions(+), 5 deletions(-)
migration/multifd.c +57 -5
index a20d0ed10e..c031f947c7 100644
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qemu/rcu.h"
 #include "exec/target_page.h"
 #include "sysemu/sysemu.h"
@@ -278,6 +279,12 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
 
         packet->offset[i] = cpu_to_be64(temp);
     }
+    for (i = 0; i < p->zero_num; i++) {
+        /* there are architectures where ram_addr_t is 32 bit */
+        uint64_t temp = p->zero[i];
+
+        packet->offset[p->normal_num + i] = cpu_to_be64(temp);
+    }
 }
 
 static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
@@ -360,6 +367,18 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
         p->normal[i] = offset;
     }
 
+    for (i = 0; i < p->zero_num; i++) {
+        uint64_t offset = be64_to_cpu(packet->offset[p->normal_num + i]);
+
+        if (offset > (p->block->used_length - p->page_size)) {
+            error_setg(errp, "multifd: offset too long %" PRIu64
+                       " (max " RAM_ADDR_FMT ")",
+                       offset, p->block->used_length);
+            return -1;
+        }
+        p->zero[i] = offset;
+    }
+
     return 0;
 }
 
@@ -658,13 +677,37 @@ int multifd_send_sync_main(void)
     return 0;
 }
 
+static void zero_page_check_send(MultiFDSendParams *p)
+{
+    /*
+     * QEMU older than 9.0 don't understand zero page
+     * on multifd channel. This switch is required to
+     * maintain backward compatibility.
+     */
+    bool use_multifd_zero_page = migrate_multifd_zero_page();
+    RAMBlock *rb = p->pages->block;
+
+    for (int i = 0; i < p->pages->num; i++) {
+        uint64_t offset = p->pages->offset[i];
+        if (use_multifd_zero_page &&
+            buffer_is_zero(rb->host + offset, p->page_size)) {
+            p->zero[p->zero_num] = offset;
+            p->zero_num++;
+            ram_release_page(rb->idstr, offset);
+        } else {
+            p->normal[p->normal_num] = offset;
+            p->normal_num++;
+        }
+    }
+}
+
 static void *multifd_send_thread(void *opaque)
 {
     MultiFDSendParams *p = opaque;
     MigrationThread *thread = NULL;
     Error *local_err = NULL;
-    int ret = 0;
     bool use_zero_copy_send = migrate_zero_copy_send();
+    int ret = 0;
 
     thread = migration_threads_add(p->name, qemu_get_thread_id());
 
@@ -699,10 +742,7 @@ static void *multifd_send_thread(void *opaque)
                 p->iovs_num = 1;
             }
 
-            for (int i = 0; i < p->pages->num; i++) {
-                p->normal[p->normal_num] = p->pages->offset[i];
-                p->normal_num++;
-            }
+            zero_page_check_send(p);
 
             if (p->normal_num) {
                 ret = multifd_send_state->ops->send_prepare(p, &local_err);
@@ -1107,6 +1147,16 @@ void multifd_recv_sync_main(void)
     trace_multifd_recv_sync_main(multifd_recv_state->packet_num);
 }
 
+static void zero_page_check_recv(MultiFDRecvParams *p)
+{
+    for (int i = 0; i < p->zero_num; i++) {
+        void *page = p->host + p->zero[i];
+        if (!buffer_is_zero(page, p->page_size)) {
+            memset(page, 0, p->page_size);
+        }
+    }
+}
+
 static void *multifd_recv_thread(void *opaque)
 {
     MultiFDRecvParams *p = opaque;
@@ -1153,6 +1203,8 @@ static void *multifd_recv_thread(void *opaque)
             }
         }
 
+        zero_page_check_recv(p);
+
         if (flags & MULTIFD_FLAG_SYNC) {
             qemu_sem_post(&multifd_recv_state->sem_sync);
             qemu_sem_wait(&p->sem_sync);
migration/multifd.h +5 -0
index 6be9b2f6c1..7448cb1aa9 100644
@@ -53,6 +53,11 @@ typedef struct {
     uint32_t unused32[1];    /* Reserved for future use */
     uint64_t unused64[3];    /* Reserved for future use */
     char ramblock[256];
+    /*
+     * This array contains the pointers to:
+     *  - normal pages (initial normal_pages entries)
+     *  - zero pages (following zero_pages entries)
+     */
     uint64_t offset[];
 } __attribute__((packed)) MultiFDPacket_t;
 
Signature · 1 line
2.30.2
#14 lore raw

Re: [PATCH 4/6] migration/multifd: Zero page transmission on the multifd thread.

Quoted 22 lines · Hao Xiang

This implements the zero page detection and handling on the multifd threads.

---
 migration/multifd.c | 62 +++++++++++++++++++++++++++++++++++++++++----
 migration/multifd.h |  5 ++++
 2 files changed, 62 insertions(+), 5 deletions(-)
migration/multifd.c +1 -0
index a20d0ed10e..c031f947c7 100644
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qemu/rcu.h"
 #include "exec/target_page.h"
 #include "sysemu/sysemu.h"

migration/multifd.c static void multifd_send_fill_packet(MultiFDSendParams *p) · line 288

Quoted 10 lines
migration/multifd.c +6 -0
@@ -278,6 +279,12 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
 
         packet->offset[i] = cpu_to_be64(temp);
     }
+    for (i = 0; i < p->zero_num; i++) {
+        /* there are architectures where ram_addr_t is 32 bit */
+        uint64_t temp = p->zero[i];
+
+        packet->offset[p->normal_num + i] = cpu_to_be64(temp);
+    }
 }

Please be noted taht p->normal_num will be dropped very soon, see:

https://lore.kernel.org/all/[email protected]/

Please use p->pages->num instead.

This patch also relies on some changes in previous patch.. IMHO we can split the patch better in this way:

- Patch 1: Add new parameter "zero-page-detection", support "none", "legacy". You'll need to implement "none" here that we skip zero page by returning 0 in save_zero_page() if "none".

- Patch 2: Add new "multifd" mode in above, implement it in the same patch completely.

- Patch 3: introduce ram_save_target_page_multifd()

- Patch 4: test case

If you want to add "zeros" accounting, that can be done as more patches on top.

Thanks,

Signature · 1 line
Peter Xu
author
#15 lore raw

PATCH 5/6 migration/multifd: Enable zero page checking from multifd threads.

In reply to Hao Xiang

This change adds a dedicated handler for MigrationOps::ram_save_target_page in multifd live migration. Now zero page checking can be done in the multifd threads and this becomes the default configuration. We still provide backward compatibility where zero page checking is done from the migration main thread.

---
 migration/multifd.c |  3 ++-
 migration/ram.c     | 49 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 42 insertions(+), 10 deletions(-)
migration/multifd.c +2 -1
index c031f947c7..c6833ccb07 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
 #include "qemu/rcu.h"
+#include "qemu/cutils.h"
 #include "exec/target_page.h"
 #include "sysemu/sysemu.h"
 #include "exec/ramblock.h"
@@ -458,7 +459,6 @@ static int multifd_send_pages(void)
     p->packet_num = multifd_send_state->packet_num++;
     multifd_send_state->pages = p->pages;
     p->pages = pages;
-
     qemu_mutex_unlock(&p->mutex);
     qemu_sem_post(&p->sem);
 
@@ -733,6 +733,7 @@ static void *multifd_send_thread(void *opaque)
         if (p->pending_job) {
             uint64_t packet_num = p->packet_num;
             uint32_t flags;
+
             p->normal_num = 0;
             p->zero_num = 0;
 
migration/ram.c +40 -9

77 lines not on this page · raw message

Signature · 1 line
2.30.2
author
#16 lore raw

PATCH 6/6 migration/multifd: Add a new migration test case for legacy zero page checking.

In reply to Hao Xiang

Now that zero page checking is done on the multifd sender threads by default, we still provide an option for backward compatibility. This change adds a qtest migration test case to set the multifd-zero-page option to false and run multifd migration with zero page checking on the migration main thread.

---
 tests/qtest/migration-test.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
tests/qtest/migration-test.c +26 -0
index 7675519cfa..2c13df04c3 100644
@@ -2621,6 +2621,15 @@ test_migrate_precopy_tcp_multifd_start(QTestState *from,
     return test_migrate_precopy_tcp_multifd_start_common(from, to, "none");
 }
 
+static void *
+test_migrate_precopy_tcp_multifd_start_zero_page_legacy(QTestState *from,
+                                                        QTestState *to)
+{
+    test_migrate_precopy_tcp_multifd_start_common(from, to, "none");
+    migrate_set_parameter_bool(from, "multifd-zero-page", false);
+    return NULL;
+}
+
 static void *
 test_migrate_precopy_tcp_multifd_zlib_start(QTestState *from,
                                             QTestState *to)
@@ -2652,6 +2661,21 @@ static void test_multifd_tcp_none(void)
     test_precopy_common(&args);
 }
 
+static void test_multifd_tcp_zero_page_legacy(void)
+{
+    MigrateCommon args = {
+        .listen_uri = "defer",
+        .start_hook = test_migrate_precopy_tcp_multifd_start_zero_page_legacy,
+        /*
+         * Multifd is more complicated than most of the features, it
+         * directly takes guest page buffers when sending, make sure
+         * everything will work alright even if guest page is changing.
+         */
+        .live = true,
+    };
+    test_precopy_common(&args);
+}
+
 static void test_multifd_tcp_zlib(void)
 {
     MigrateCommon args = {
@@ -3550,6 +3574,8 @@ int main(int argc, char **argv)
     }
     migration_test_add("/migration/multifd/tcp/plain/none",
                        test_multifd_tcp_none);
+    migration_test_add("/migration/multifd/tcp/plain/zero_page_legacy",
+                       test_multifd_tcp_zero_page_legacy);
     migration_test_add("/migration/multifd/tcp/plain/cancel",
                        test_multifd_tcp_cancel);
     migration_test_add("/migration/multifd/tcp/plain/zlib",
Signature · 1 line
2.30.2
#17 lore raw
In reply to Hao Xiang
Quoted 40 lines · Hao Xiang

This patchset is based on Juan Quintela's old series here
https://lore.kernel.org/all/[email protected]/

In the multifd live migration model, there is a single migration main thread scanning the page map, queuing the pages to multiple multifd sender threads. The migration main thread runs zero page checking on every page before queuing the page to the sender threads. Zero page checking is a CPU intensive task and hence having a single thread doing all that doesn't scale well. This change introduces a new function to run the zero page checking on the multifd sender threads. This patchset also lays the ground work for future changes to offload zero page checking task to accelerator hardwares.

Use two Intel 4th generation Xeon servers for testing.

Architecture:        x86_64
CPU(s):              192
Thread(s) per core:  2
Core(s) per socket:  48
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               143
Model name:          Intel(R) Xeon(R) Platinum 8457C
Stepping:            8
CPU MHz:             2538.624
CPU max MHz:         3800.0000
CPU min MHz:         800.0000

Perform multifd live migration with below setup:
1. VM has 100GB memory. All pages in the VM are zero pages.
2. Use tcp socket for live migratio.
3. Use 4 multifd channels and zero page checking on migration main thread.
4. Use 1/2/4 multifd channels and zero page checking on multifd sender threads.
5. Record migration total time from sender QEMU console's "info migrate" command.
6. Calculate throughput with "100GB / total time".

Quoted 11 lines
+------------------------------------------------------+
|zero-page-checking | total-time(ms) | throughput(GB/s)|
+------------------------------------------------------+
|main-thread        | 9629           | 10.38GB/s       |
+------------------------------------------------------+
|multifd-1-threads  | 6182           | 16.17GB/s       |
+------------------------------------------------------+
|multifd-2-threads  | 4643           | 21.53GB/s       |
+------------------------------------------------------+
|multifd-4-threads  | 4143           | 24.13GB/s       |
+------------------------------------------------------+

This "throughput" is slightly confusing; I was initially surprised to see a large throughput for idle guests. IMHO the "total-time" would explain. Feel free to drop that column if there's a repost.

Did you check why 4 channels mostly already reached the top line? Is it because main thread is already spinning 100%?

Thanks,

Signature · 1 line
Peter Xu
author
#18 lore raw
Quoted 58 lines · Peter Xu
Quoted 40 lines · Hao Xiang

This patchset is based on Juan Quintela's old series here
https://lore.kernel.org/all/[email protected]/

In the multifd live migration model, there is a single migration main thread scanning the page map, queuing the pages to multiple multifd sender threads. The migration main thread runs zero page checking on every page before queuing the page to the sender threads. Zero page checking is a CPU intensive task and hence having a single thread doing all that doesn't scale well. This change introduces a new function to run the zero page checking on the multifd sender threads. This patchset also lays the ground work for future changes to offload zero page checking task to accelerator hardwares.

Use two Intel 4th generation Xeon servers for testing.

Architecture:        x86_64
CPU(s):              192
Thread(s) per core:  2
Core(s) per socket:  48
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               143
Model name:          Intel(R) Xeon(R) Platinum 8457C
Stepping:            8
CPU MHz:             2538.624
CPU max MHz:         3800.0000
CPU min MHz:         800.0000

Perform multifd live migration with below setup:
1. VM has 100GB memory. All pages in the VM are zero pages.
2. Use tcp socket for live migratio.
3. Use 4 multifd channels and zero page checking on migration main thread.
4. Use 1/2/4 multifd channels and zero page checking on multifd sender threads.
5. Record migration total time from sender QEMU console's "info migrate" command.
6. Calculate throughput with "100GB / total time".

Quoted 11 lines
+------------------------------------------------------+
|zero-page-checking | total-time(ms) | throughput(GB/s)|
+------------------------------------------------------+
|main-thread        | 9629           | 10.38GB/s       |
+------------------------------------------------------+
|multifd-1-threads  | 6182           | 16.17GB/s       |
+------------------------------------------------------+
|multifd-2-threads  | 4643           | 21.53GB/s       |
+------------------------------------------------------+
|multifd-4-threads  | 4143           | 24.13GB/s       |
+------------------------------------------------------+

This "throughput" is slightly confusing; I was initially surprised to see a large throughput for idle guests. IMHO the "total-time" would explain. Feel free to drop that column if there's a repost.

Quoted 7 lines

Did you check why 4 channels mostly already reached the top line? Is it because main thread is already spinning 100%?

Thanks,

--
Peter Xu

Sure I will drop "throughput" to avoid confusion. In my testing, 1 multifd channel already makes the main thread spin at 100%. So the total-time is the same across 1/2/4 multifd channels as long as zero page is run on the main migration thread. Of course, this is based on the fact that the network is not the bottleneck. One interesting finding is that multifd 1 channel with multifd zero page has better performance than multifd 1 channel with main migration thread.

Quoted 1 line
#19 lore raw
Quoted 7 lines · Hao Xiang

Sure I will drop "throughput" to avoid confusion. In my testing, 1 multifd channel already makes the main thread spin at 100%. So the total-time is the same across 1/2/4 multifd channels as long as zero page is run on the main migration thread. Of course, this is based on the fact that the network is not the bottleneck. One interesting finding is that multifd 1 channel with multifd zero page has better performance than multifd 1 channel with main migration thread.

It's probably because the main thread has even more works to do than "detecting zero page" alone.

When zero detection is done in main thread and when the guest is fully idle, it'll consume a major portion of main thread cpu resource scanning those pages already. Consider all pages zero, multifd threads should be fully idle, so n_channels may not matter here.

When 1 multifd thread created with zero-page offloading, zero page is fully offloaded from main -> multifd thread even if only one. It's kind of a similar effect of forking the main thread into two threads, so the main thread can be more efficient on other tasks (fetching/scanning dirty bits, etc.).

Thanks,

Signature · 1 line
Peter Xu