- s390x/sclp: Simplify get_sclp_device() - target/ppc: Remove msr_pr macro - docs/system/target-arm: Re-alphabetize board list - migration: Extend query-migrate to provide dirty page limit info - migration: Implement dirty-limit convergence algo - migration: Put the detection logic before auto-converge checking - migration: Refactor auto-converge capability logic - migration: Introduce dirty-limit capability - qapi/migration: Introduce vcpu-dirty-limit parameters - qapi/migration: Introduce x-vcpu-dirty-limit-period parameter - Change the value of no_ged from true to false - Allow UNIX socket option for VNC websocket - tpm_emulator: Avoid double initialization during - chardev/char-socket: Update AF_UNIX for Windows - KVM: dirty ring: add missing memory barrier - i386: reset KVM nested state upon CPU reset - esp: Handle CMD_BUSRESET by resetting the SCSI bus - dbus-vmstate: Restrict error checks to registered proxies in dbus_get_proxies - vfio/pci: Add Ascend310b scend910b support - target/i386: Export RFDS bit to guests - target/i386: Add new CPU model SierraForest - target/i386: Introduce Icelake-Server-v7 to enable TSX - hw/virtio: handle un-configured shutdown in virtio-pci - target/s390x: display deprecation status in '-cpu help' - target/i386: display deprecation status in '-cpu help' - pc-bios/s390-ccw: Fix booting with logical block size < physical block size Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
184 lines
6.5 KiB
Diff
184 lines
6.5 KiB
Diff
From c7ae0b39eec728d7f88029f932fdd6d3bfda6e68 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?=
|
|
<yong.huang@smartx.com>
|
|
Date: Wed, 7 Jun 2023 23:30:50 +0800
|
|
Subject: [PATCH] migration: Introduce dirty-limit capability
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
There is a conflict when merging patches in qemu-6.2.0, and there is a phenomenon that the corresponding files and functions cannot be found.Merge after modifying the patch by wangguochun@kylinos.cn
|
|
|
|
Introduce migration dirty-limit capability, which can
|
|
be turned on before live migration and limit dirty
|
|
page rate durty live migration.
|
|
|
|
Introduce migrate_dirty_limit function to help check
|
|
if dirty-limit capability enabled during live migration.
|
|
|
|
Meanwhile, refactor vcpu_dirty_rate_stat_collect
|
|
so that period can be configured instead of hardcoded.
|
|
|
|
dirty-limit capability is kind of like auto-converge
|
|
but using dirty limit instead of traditional cpu-throttle
|
|
to throttle guest down. To enable this feature, turn on
|
|
the dirty-limit capability before live migration using
|
|
migrate-set-capabilities, and set the parameters
|
|
"x-vcpu-dirty-limit-period", "vcpu-dirty-limit" suitably
|
|
to speed up convergence.
|
|
|
|
Signed-off-by: Hyman Huang(黄勇) <yong.huang@smartx.com>
|
|
Acked-by: Peter Xu <peterx@redhat.com>
|
|
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
Message-Id: <168618975839.6361.17407633874747688653-4@git.sr.ht>
|
|
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
---
|
|
migration/migration.c | 25 +++++++++++++++++++++++++
|
|
migration/migration.h | 1 +
|
|
qapi/migration.json | 13 ++++++++++++-
|
|
softmmu/dirtylimit.c | 17 +++++++++++++----
|
|
4 files changed, 51 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/migration/migration.c b/migration/migration.c
|
|
index 06d9b6a15d..50c33fecf3 100644
|
|
--- a/migration/migration.c
|
|
+++ b/migration/migration.c
|
|
@@ -60,6 +60,7 @@
|
|
#include "qemu/yank.h"
|
|
#include "sysemu/cpus.h"
|
|
#include "yank_functions.h"
|
|
+#include "sysemu/kvm.h"
|
|
|
|
#define MAX_THROTTLE (128 << 20) /* Migration transfer speed throttling */
|
|
|
|
@@ -1265,6 +1266,20 @@ static bool migrate_caps_check(bool *cap_list,
|
|
error_setg(errp, "multifd is not supported by current protocol");
|
|
return false;
|
|
}
|
|
+
|
|
+ if (cap_list[MIGRATION_CAPABILITY_DIRTY_LIMIT]) {
|
|
+ if (cap_list[MIGRATION_CAPABILITY_AUTO_CONVERGE]) {
|
|
+ error_setg(errp, "dirty-limit conflicts with auto-converge"
|
|
+ " either of then available currently");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ if (!kvm_enabled() || !kvm_dirty_ring_enabled()) {
|
|
+ error_setg(errp, "dirty-limit requires KVM with accelerator"
|
|
+ " property 'dirty-ring-size' set");
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
|
|
return true;
|
|
}
|
|
@@ -2550,6 +2565,15 @@ bool migrate_dirty_bitmaps(void)
|
|
return s->enabled_capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
|
|
}
|
|
|
|
+bool migrate_dirty_limit(void)
|
|
+{
|
|
+ MigrationState *s;
|
|
+
|
|
+ s = migrate_get_current();
|
|
+
|
|
+ return s->enabled_capabilities[MIGRATION_CAPABILITY_DIRTY_LIMIT];
|
|
+}
|
|
+
|
|
bool migrate_ignore_shared(void)
|
|
{
|
|
MigrationState *s;
|
|
@@ -4316,6 +4340,7 @@ static Property migration_properties[] = {
|
|
DEFINE_PROP_UINT64("vcpu-dirty-limit", MigrationState,
|
|
parameters.vcpu_dirty_limit,
|
|
DEFAULT_MIGRATE_VCPU_DIRTY_LIMIT),
|
|
+ DEFINE_PROP_MIG_CAP("x-dirty-limit", MIGRATION_CAPABILITY_DIRTY_LIMIT),
|
|
|
|
/* Migration capabilities */
|
|
DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
|
|
diff --git a/migration/migration.h b/migration/migration.h
|
|
index 6b546a6ac7..9ce1fc8ea0 100644
|
|
--- a/migration/migration.h
|
|
+++ b/migration/migration.h
|
|
@@ -329,6 +329,7 @@ bool migrate_release_ram(void);
|
|
bool migrate_postcopy_ram(void);
|
|
bool migrate_zero_blocks(void);
|
|
bool migrate_dirty_bitmaps(void);
|
|
+bool migrate_dirty_limit(void);
|
|
bool migrate_ignore_shared(void);
|
|
bool migrate_validate_uuid(void);
|
|
|
|
diff --git a/qapi/migration.json b/qapi/migration.json
|
|
index f35f0377dc..4751c5ee53 100644
|
|
--- a/qapi/migration.json
|
|
+++ b/qapi/migration.json
|
|
@@ -452,6 +452,16 @@
|
|
# procedure starts. The VM RAM is saved with running VM.
|
|
# (since 6.0)
|
|
#
|
|
+# @dirty-limit: If enabled, migration will use the dirty-limit algo to
|
|
+# throttle down guest instead of auto-converge algo.
|
|
+# Throttle algo only works when vCPU's dirtyrate greater
|
|
+# than 'vcpu-dirty-limit', read processes in guest os
|
|
+# aren't penalized any more, so this algo can improve
|
|
+# performance of vCPU during live migration. This is an
|
|
+# optional performance feature and should not affect the
|
|
+# correctness of the existing auto-converge algo.
|
|
+# (since 8.1)
|
|
+#
|
|
# Features:
|
|
# @unstable: Members @x-colo and @x-ignore-shared are experimental.
|
|
#
|
|
@@ -465,7 +475,8 @@
|
|
'block', 'return-path', 'pause-before-switchover', 'multifd',
|
|
'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate',
|
|
{ 'name': 'x-ignore-shared', 'features': [ 'unstable' ] },
|
|
- 'validate-uuid', 'background-snapshot'] }
|
|
+ 'validate-uuid', 'background-snapshot',
|
|
+ 'dirty-limit'] }
|
|
|
|
##
|
|
# @MigrationCapabilityStatus:
|
|
diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c
|
|
index 5041c230d0..4d770aaba4 100644
|
|
--- a/softmmu/dirtylimit.c
|
|
+++ b/softmmu/dirtylimit.c
|
|
@@ -24,6 +24,8 @@
|
|
#include "hw/boards.h"
|
|
#include "sysemu/kvm.h"
|
|
#include "trace.h"
|
|
+#include "migration/misc.h"
|
|
+#include "migration/migration.h"
|
|
|
|
/*
|
|
* Dirtylimit stop working if dirty page rate error
|
|
@@ -75,14 +77,21 @@ static bool dirtylimit_quit;
|
|
|
|
static void vcpu_dirty_rate_stat_collect(void)
|
|
{
|
|
+ MigrationState *s = migrate_get_current();
|
|
VcpuStat stat;
|
|
int i = 0;
|
|
+ int64_t period = DIRTYLIMIT_CALC_TIME_MS;
|
|
+
|
|
+ if (migrate_dirty_limit() &&
|
|
+ migration_is_active(s)) {
|
|
+ period = s->parameters.x_vcpu_dirty_limit_period;
|
|
+ }
|
|
|
|
/* calculate vcpu dirtyrate */
|
|
- vcpu_calculate_dirtyrate(DIRTYLIMIT_CALC_TIME_MS,
|
|
- &stat,
|
|
- GLOBAL_DIRTY_LIMIT,
|
|
- false);
|
|
+ vcpu_calculate_dirtyrate(period,
|
|
+ &stat,
|
|
+ GLOBAL_DIRTY_LIMIT,
|
|
+ false);
|
|
|
|
for (i = 0; i < stat.nvcpu; i++) {
|
|
vcpu_dirty_rate_stat->stat.rates[i].id = i;
|
|
--
|
|
2.27.0
|
|
|