[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/30] multifd: Fix a race on reading MultiFDPages_t.block
From: |
Juan Quintela |
Subject: |
[PULL 27/30] multifd: Fix a race on reading MultiFDPages_t.block |
Date: |
Tue, 7 Feb 2023 01:56:47 +0100 |
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
In multifd_queue_page() MultiFDPages_t.block is checked twice.
Between the two checks, MultiFDPages_t.block may be reset to NULL
by multifd thread. This lead to the 2nd check always true then a
redundant page submitted to multifd thread again.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/multifd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index eeb4fb87ee..ad89293b4e 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -442,6 +442,7 @@ static int multifd_send_pages(QEMUFile *f)
int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset)
{
MultiFDPages_t *pages = multifd_send_state->pages;
+ bool changed = false;
if (!pages->block) {
pages->block = block;
@@ -454,14 +455,16 @@ int multifd_queue_page(QEMUFile *f, RAMBlock *block,
ram_addr_t offset)
if (pages->num < pages->allocated) {
return 1;
}
+ } else {
+ changed = true;
}
if (multifd_send_pages(f) < 0) {
return -1;
}
- if (pages->block != block) {
- return multifd_queue_page(f, block, offset);
+ if (changed) {
+ return multifd_queue_page(f, block, offset);
}
return 1;
--
2.39.1
- [PULL 18/30] virtio-mem: Migrate immutable properties early, (continued)
- [PULL 18/30] virtio-mem: Migrate immutable properties early, Juan Quintela, 2023/02/06
- [PULL 17/30] virtio-mem: Fail if a memory backend with "prealloc=on" is specified, Juan Quintela, 2023/02/06
- [PULL 19/30] virtio-mem: Proper support for preallocation with migration, Juan Quintela, 2023/02/06
- [PULL 20/30] migration: Show downtime during postcopy phase, Juan Quintela, 2023/02/06
- [PULL 21/30] migration/rdma: fix return value for qio_channel_rdma_{readv, writev}, Juan Quintela, 2023/02/06
- [PULL 22/30] migration: Add canary to VMSTATE_END_OF_LIST, Juan Quintela, 2023/02/06
- [PULL 23/30] migration: Perform vmsd structure check during tests, Juan Quintela, 2023/02/06
- [PULL 24/30] migration/dirtyrate: Show sample pages only in page-sampling mode, Juan Quintela, 2023/02/06
- [PULL 25/30] io: Add support for MSG_PEEK for socket channel, Juan Quintela, 2023/02/06
- [PULL 26/30] migration: check magic value for deciding the mapping of channels, Juan Quintela, 2023/02/06
- [PULL 27/30] multifd: Fix a race on reading MultiFDPages_t.block,
Juan Quintela <=
- [PULL 28/30] multifd: Fix flush of zero copy page send request, Juan Quintela, 2023/02/06
- [PULL 29/30] migration: Introduce interface query-migrationthreads, Juan Quintela, 2023/02/06
- [PULL 30/30] migration: save/delete migration thread info, Juan Quintela, 2023/02/06
- Re: [PULL 00/30] Migration 20230206 patches, Peter Maydell, 2023/02/07