From: Lukas Straub <lukasstraub2@web.de>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Hailiang Zhang <zhang.zhanghailiang@huawei.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Juan Quintela <quintela@redhat.com>
Subject: [PATCH 1/6] migration/colo.c: Use event instead of semaphore
Date: Mon, 11 May 2020 13:10:44 +0200 [thread overview]
Message-ID: <fd601ba1beb524aada54ba66e87ebfc12cf4574b.1589193382.git.lukasstraub2@web.de> (raw)
In-Reply-To: <cover.1589193382.git.lukasstraub2@web.de>
[-- Attachment #1: Type: text/plain, Size: 3226 bytes --]
If multiple packets miscompare in a short timeframe, the semaphore
value will be increased multiple times. This causes multiple
checkpoints even if one would be sufficient.
Fix this by using a event instead of a semaphore for triggering
checkpoints. Now, checkpoint requests will be ignored until the
checkpoint event is sent to colo-compare (which releases the
miscompared packets).
Benchmark results (iperf3):
Client-to-server tcp:
without patch: ~66 Mbit/s
with patch: ~61 Mbit/s
Server-to-client tcp:
without patch: ~702 Kbit/s
with patch: ~16 Mbit/s
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
---
migration/colo.c | 9 +++++----
migration/migration.h | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/migration/colo.c b/migration/colo.c
index a54ac84f41..09168627bc 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -430,6 +430,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
goto out;
}
+ qemu_event_reset(&s->colo_checkpoint_event);
colo_notify_compares_event(NULL, COLO_EVENT_CHECKPOINT, &local_err);
if (local_err) {
goto out;
@@ -580,7 +581,7 @@ static void colo_process_checkpoint(MigrationState *s)
goto out;
}
- qemu_sem_wait(&s->colo_checkpoint_sem);
+ qemu_event_wait(&s->colo_checkpoint_event);
if (s->state != MIGRATION_STATUS_COLO) {
goto out;
@@ -628,7 +629,7 @@ out:
colo_compare_unregister_notifier(&packets_compare_notifier);
timer_del(s->colo_delay_timer);
timer_free(s->colo_delay_timer);
- qemu_sem_destroy(&s->colo_checkpoint_sem);
+ qemu_event_destroy(&s->colo_checkpoint_event);
/*
* Must be called after failover BH is completed,
@@ -645,7 +646,7 @@ void colo_checkpoint_notify(void *opaque)
MigrationState *s = opaque;
int64_t next_notify_time;
- qemu_sem_post(&s->colo_checkpoint_sem);
+ qemu_event_set(&s->colo_checkpoint_event);
s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
next_notify_time = s->colo_checkpoint_time +
s->parameters.x_checkpoint_delay;
@@ -655,7 +656,7 @@ void colo_checkpoint_notify(void *opaque)
void migrate_start_colo_process(MigrationState *s)
{
qemu_mutex_unlock_iothread();
- qemu_sem_init(&s->colo_checkpoint_sem, 0);
+ qemu_event_init(&s->colo_checkpoint_event, false);
s->colo_delay_timer = timer_new_ms(QEMU_CLOCK_HOST,
colo_checkpoint_notify, s);
diff --git a/migration/migration.h b/migration/migration.h
index 507284e563..f617960522 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -215,8 +215,8 @@ struct MigrationState
/* The semaphore is used to notify COLO thread that failover is finished */
QemuSemaphore colo_exit_sem;
- /* The semaphore is used to notify COLO thread to do checkpoint */
- QemuSemaphore colo_checkpoint_sem;
+ /* The event is used to notify COLO thread to do checkpoint */
+ QemuEvent colo_checkpoint_event;
int64_t colo_checkpoint_time;
QEMUTimer *colo_delay_timer;
--
2.20.1
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-05-11 11:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 11:10 [PATCH 0/6] colo: migration related bugfixes Lukas Straub
2020-05-11 11:10 ` Lukas Straub [this message]
2020-05-13 11:31 ` 答复: [PATCH 1/6] migration/colo.c: Use event instead of semaphore Zhanghailiang
2020-05-11 11:10 ` [PATCH 2/6] migration/colo.c: Use cpu_synchronize_all_states() Lukas Straub
2020-05-13 9:47 ` Dr. David Alan Gilbert
2020-05-13 19:15 ` Lukas Straub
2020-05-11 11:10 ` [PATCH 3/6] migration/colo.c: Flush ram cache only after receiving device state Lukas Straub
2020-05-14 12:45 ` 答复: " Zhanghailiang
2020-05-11 11:10 ` [PATCH 4/6] migration/colo.c: Relaunch failover even if there was an error Lukas Straub
2020-05-15 6:24 ` Zhanghailiang
2020-05-11 11:10 ` [PATCH 5/6] migration/qemu-file.c: Don't ratelimit a shutdown fd Lukas Straub
2020-05-14 13:05 ` 答复: " Zhanghailiang
2020-05-18 11:55 ` Dr. David Alan Gilbert
2020-05-19 13:08 ` Lukas Straub
2020-05-19 14:50 ` Dr. David Alan Gilbert
2020-05-20 20:44 ` Lukas Straub
2020-05-11 11:11 ` [PATCH 6/6] migration/colo.c: Move colo_notify_compares_event to the right place Lukas Straub
2020-05-14 13:27 ` 答复: " Zhanghailiang
2020-05-14 14:31 ` Lukas Straub
2020-05-15 1:45 ` Zhanghailiang
2020-05-15 1:53 ` Zhanghailiang
2020-06-01 16:50 ` [PATCH 0/6] colo: migration related bugfixes Dr. David Alan Gilbert
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=fd601ba1beb524aada54ba66e87ebfc12cf4574b.1589193382.git.lukasstraub2@web.de \
--to=lukasstraub2@web.de \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhang.zhanghailiang@huawei.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).