* [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block
@ 2022-10-17 7:53 Zhenzhong Duan
2022-10-17 7:53 ` [PATCH 2/2] multifd: Fix flush of zero copy page send request Zhenzhong Duan
2023-02-02 20:13 ` [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block Juan Quintela
0 siblings, 2 replies; 4+ messages in thread
From: Zhenzhong Duan @ 2022-10-17 7:53 UTC (permalink / raw)
To: qemu-devel; +Cc: quintela, dgilbert
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>
---
migration/multifd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 586ddc9d657a..36e2139995cf 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -447,6 +447,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;
@@ -459,14 +460,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.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] multifd: Fix flush of zero copy page send request
2022-10-17 7:53 [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block Zhenzhong Duan
@ 2022-10-17 7:53 ` Zhenzhong Duan
2023-02-02 20:14 ` Juan Quintela
2023-02-02 20:13 ` [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block Juan Quintela
1 sibling, 1 reply; 4+ messages in thread
From: Zhenzhong Duan @ 2022-10-17 7:53 UTC (permalink / raw)
To: qemu-devel; +Cc: quintela, dgilbert
Make IO channel flush call after the inflight request has been drained
in multifd thread, or else we may missed to flush the inflight request.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
migration/multifd.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/migration/multifd.c b/migration/multifd.c
index 36e2139995cf..1e01873128f6 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -618,6 +618,12 @@ int multifd_send_sync_main(QEMUFile *f)
ram_counters.transferred += p->packet_len;
qemu_mutex_unlock(&p->mutex);
qemu_sem_post(&p->sem);
+ }
+ for (i = 0; i < migrate_multifd_channels(); i++) {
+ MultiFDSendParams *p = &multifd_send_state->params[i];
+
+ trace_multifd_send_sync_main_wait(p->id);
+ qemu_sem_wait(&p->sem_sync);
if (flush_zero_copy && p->c) {
int ret;
@@ -632,12 +638,6 @@ int multifd_send_sync_main(QEMUFile *f)
}
}
}
- for (i = 0; i < migrate_multifd_channels(); i++) {
- MultiFDSendParams *p = &multifd_send_state->params[i];
-
- trace_multifd_send_sync_main_wait(p->id);
- qemu_sem_wait(&p->sem_sync);
- }
trace_multifd_send_sync_main(multifd_send_state->packet_num);
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block
2022-10-17 7:53 [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block Zhenzhong Duan
2022-10-17 7:53 ` [PATCH 2/2] multifd: Fix flush of zero copy page send request Zhenzhong Duan
@ 2023-02-02 20:13 ` Juan Quintela
1 sibling, 0 replies; 4+ messages in thread
From: Juan Quintela @ 2023-02-02 20:13 UTC (permalink / raw)
To: Zhenzhong Duan; +Cc: qemu-devel, dgilbert
Zhenzhong Duan <zhenzhong.duan@intel.com> wrote:
> 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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] multifd: Fix flush of zero copy page send request
2022-10-17 7:53 ` [PATCH 2/2] multifd: Fix flush of zero copy page send request Zhenzhong Duan
@ 2023-02-02 20:14 ` Juan Quintela
0 siblings, 0 replies; 4+ messages in thread
From: Juan Quintela @ 2023-02-02 20:14 UTC (permalink / raw)
To: Zhenzhong Duan; +Cc: qemu-devel, dgilbert
Zhenzhong Duan <zhenzhong.duan@intel.com> wrote:
> Make IO channel flush call after the inflight request has been drained
> in multifd thread, or else we may missed to flush the inflight request.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Good catch!!!!!
Reviewed-by: Juan Quintela <quintela@redhat.com>
queued the whole series.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-02 20:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-17 7:53 [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block Zhenzhong Duan
2022-10-17 7:53 ` [PATCH 2/2] multifd: Fix flush of zero copy page send request Zhenzhong Duan
2023-02-02 20:14 ` Juan Quintela
2023-02-02 20:13 ` [PATCH 1/2] multifd: Fix a race on reading MultiFDPages_t.block Juan Quintela
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).