[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/26] migration/multifd: solve zero page causing multiple page fa
From: |
Peter Xu |
Subject: |
[PULL 25/26] migration/multifd: solve zero page causing multiple page faults |
Date: |
Tue, 23 Apr 2024 18:38:12 -0400 |
From: Yuan Liu <yuan1.liu@intel.com>
Implemented recvbitmap tracking of received pages in multifd.
If the zero page appears for the first time in the recvbitmap, this
page is not checked and set.
If the zero page has already appeared in the recvbitmap, there is no
need to check the data but directly set the data to 0, because it is
unlikely that the zero page will be migrated multiple times.
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: 20240401154110.2028453-2-yuan1.liu@intel.com">https://lore.kernel.org/r/20240401154110.2028453-2-yuan1.liu@intel.com
[peterx: touch up the comment, as the bitmap is used outside postcopy now]
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/exec/ramblock.h | 2 +-
migration/ram.h | 1 +
migration/multifd-zero-page.c | 4 +++-
migration/multifd-zlib.c | 1 +
migration/multifd-zstd.c | 1 +
migration/multifd.c | 1 +
migration/ram.c | 4 ++++
7 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h
index 848915ea5b..7062da380b 100644
--- a/include/exec/ramblock.h
+++ b/include/exec/ramblock.h
@@ -57,7 +57,7 @@ struct RAMBlock {
off_t bitmap_offset;
uint64_t pages_offset;
- /* bitmap of already received pages in postcopy */
+ /* Bitmap of already received pages. Only used on destination side. */
unsigned long *receivedmap;
/*
diff --git a/migration/ram.h b/migration/ram.h
index 08feecaf51..bc0318b834 100644
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -69,6 +69,7 @@ int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr);
bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_offset);
void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr);
void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, size_t nr);
+void ramblock_recv_bitmap_set_offset(RAMBlock *rb, uint64_t byte_offset);
int64_t ramblock_recv_bitmap_send(QEMUFile *file,
const char *block_name);
bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb, Error **errp);
diff --git a/migration/multifd-zero-page.c b/migration/multifd-zero-page.c
index 1ba38be636..e1b8370f88 100644
--- a/migration/multifd-zero-page.c
+++ b/migration/multifd-zero-page.c
@@ -80,8 +80,10 @@ void multifd_recv_zero_page_process(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)) {
+ if (ramblock_recv_bitmap_test_byte_offset(p->block, p->zero[i])) {
memset(page, 0, p->page_size);
+ } else {
+ ramblock_recv_bitmap_set_offset(p->block, p->zero[i]);
}
}
}
diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c
index 99821cd4d5..737a9645d2 100644
--- a/migration/multifd-zlib.c
+++ b/migration/multifd-zlib.c
@@ -284,6 +284,7 @@ static int zlib_recv(MultiFDRecvParams *p, Error **errp)
int flush = Z_NO_FLUSH;
unsigned long start = zs->total_out;
+ ramblock_recv_bitmap_set_offset(p->block, p->normal[i]);
if (i == p->normal_num - 1) {
flush = Z_SYNC_FLUSH;
}
diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
index 02112255ad..256858df0a 100644
--- a/migration/multifd-zstd.c
+++ b/migration/multifd-zstd.c
@@ -278,6 +278,7 @@ static int zstd_recv(MultiFDRecvParams *p, Error **errp)
z->in.pos = 0;
for (i = 0; i < p->normal_num; i++) {
+ ramblock_recv_bitmap_set_offset(p->block, p->normal[i]);
z->out.dst = p->host + p->normal[i];
z->out.size = p->page_size;
z->out.pos = 0;
diff --git a/migration/multifd.c b/migration/multifd.c
index 2802afe79d..f317bff077 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -277,6 +277,7 @@ static int nocomp_recv(MultiFDRecvParams *p, Error **errp)
for (int i = 0; i < p->normal_num; i++) {
p->iov[i].iov_base = p->host + p->normal[i];
p->iov[i].iov_len = p->page_size;
+ ramblock_recv_bitmap_set_offset(p->block, p->normal[i]);
}
return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp);
}
diff --git a/migration/ram.c b/migration/ram.c
index daffcd82d4..a975c5af16 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -275,6 +275,10 @@ void ramblock_recv_bitmap_set_range(RAMBlock *rb, void
*host_addr,
nr);
}
+void ramblock_recv_bitmap_set_offset(RAMBlock *rb, uint64_t byte_offset)
+{
+ set_bit_atomic(byte_offset >> TARGET_PAGE_BITS, rb->receivedmap);
+}
#define RAMBLOCK_RECV_BITMAP_ENDING (0x0123456789abcdefULL)
/*
--
2.44.0
- [PULL 07/26] tests/qtest/migration: Add multifd_tcp_plain test using list of channels instead of uri, (continued)
- [PULL 07/26] tests/qtest/migration: Add multifd_tcp_plain test using list of channels instead of uri, Peter Xu, 2024/04/23
- [PULL 13/26] migration: Always report an error in ram_save_setup(), Peter Xu, 2024/04/23
- [PULL 16/26] migration: Add Error** argument to .save_setup() handler, Peter Xu, 2024/04/23
- [PULL 19/26] migration: Introduce ram_bitmaps_destroy(), Peter Xu, 2024/04/23
- [PULL 24/26] migration: Add Error** argument to add_bitmaps_to_list(), Peter Xu, 2024/04/23
- [PULL 26/26] migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_coroutine()' failed., Peter Xu, 2024/04/23
- [PULL 08/26] tests/qtest/migration: Add negative tests to validate migration QAPIs, Peter Xu, 2024/04/23
- [PULL 06/26] tests/qtest/migration: Add channels parameter in migrate_qmp, Peter Xu, 2024/04/23
- [PULL 17/26] migration: Add Error** argument to .load_setup() handler, Peter Xu, 2024/04/23
- [PULL 10/26] s390/stattrib: Add Error** argument to set_migrationmode() handler, Peter Xu, 2024/04/23
- [PULL 25/26] migration/multifd: solve zero page causing multiple page faults,
Peter Xu <=
- [PULL 05/26] tests/qtest/migration: Add migrate_set_ports into migrate_qmp to update migration port value, Peter Xu, 2024/04/23
- [PULL 12/26] migration: Always report an error in block_save_setup(), Peter Xu, 2024/04/23
- [PULL 14/26] migration: Add Error** argument to vmstate_save(), Peter Xu, 2024/04/23
- [PULL 09/26] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str, Peter Xu, 2024/04/23
- [PULL 11/26] vfio: Always report an error in vfio_save_setup(), Peter Xu, 2024/04/23
- [PULL 22/26] migration: Add Error** argument to xbzrle_init(), Peter Xu, 2024/04/23
- [PULL 03/26] tests/qtest/migration: Replace migrate_get_connect_uri inplace of migrate_get_socket_address, Peter Xu, 2024/04/23
- [PULL 15/26] migration: Add Error** argument to qemu_savevm_state_setup(), Peter Xu, 2024/04/23
- [PULL 18/26] memory: Add Error** argument to .log_global_start() handler, Peter Xu, 2024/04/23
- [PULL 23/26] migration: Modify ram_init_bitmaps() to report dirty tracking errors, Peter Xu, 2024/04/23