From: Liang Li <liang.z.li@intel.com>
To: mst@redhat.com, quintela@redhat.com, amit.shah@redhat.com,
pbonzini@redhat.com, lcapitulino@redhat.com
Cc: armbru@redhat.com, peter.maydell@linaro.org, rth@twiddle.net,
ehabkost@redhat.com, james.hogan@imgtec.com,
aurelien@aurel32.net, leon.alrae@imgtec.com, agraf@suse.de,
borntraeger@de.ibm.com, cornelia.huck@de.ibm.com,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
Liang Li <liang.z.li@intel.com>
Subject: [Qemu-devel] [PATCH QEMU 5/5] migration: Add the interface for cache drop control
Date: Tue, 19 Apr 2016 22:20:43 +0800 [thread overview]
Message-ID: <1461075643-3668-6-git-send-email-liang.z.li@intel.com> (raw)
In-Reply-To: <1461075643-3668-1-git-send-email-liang.z.li@intel.com>
Whether drop the cache and drop what kind of cache depend on the
user, add the related qmp and hmp interface to query and set the
cache control value.
Signed-off-by: Liang Li <liang.z.li@intel.com>
---
hmp.c | 8 ++++++++
include/migration/migration.h | 1 +
migration/migration.c | 31 ++++++++++++++++++++++++++++++-
migration/ram.c | 10 ++--------
qapi-schema.json | 25 ++++++++++++++++++++++---
5 files changed, 63 insertions(+), 12 deletions(-)
diff --git a/hmp.c b/hmp.c
index d510236..17f418e 100644
--- a/hmp.c
+++ b/hmp.c
@@ -286,6 +286,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
monitor_printf(mon, " %s: %" PRId64,
MigrationParameter_lookup[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT],
params->x_cpu_throttle_increment);
+ monitor_printf(mon, " %s: %" PRId64,
+ MigrationParameter_lookup[MIGRATION_PARAMETER_X_DROP_CACHE],
+ params->x_drop_cache);
monitor_printf(mon, "\n");
}
@@ -1242,6 +1245,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
bool has_decompress_threads = false;
bool has_x_cpu_throttle_initial = false;
bool has_x_cpu_throttle_increment = false;
+ bool has_x_drop_cache = false;
int i;
for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) {
@@ -1262,12 +1266,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
case MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT:
has_x_cpu_throttle_increment = true;
break;
+ case MIGRATION_PARAMETER_X_DROP_CACHE:
+ has_x_drop_cache = true;
+ break;
}
qmp_migrate_set_parameters(has_compress_level, value,
has_compress_threads, value,
has_decompress_threads, value,
has_x_cpu_throttle_initial, value,
has_x_cpu_throttle_increment, value,
+ has_x_drop_cache, value,
&err);
break;
}
diff --git a/include/migration/migration.h b/include/migration/migration.h
index ac2c12c..873e3bc 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -283,6 +283,7 @@ bool migrate_use_compression(void);
int migrate_compress_level(void);
int migrate_compress_threads(void);
int migrate_decompress_threads(void);
+int migrate_drop_cache(void);
bool migrate_use_events(void);
/* Sending on the return path - generic and then for each message type */
diff --git a/migration/migration.c b/migration/migration.c
index 991313a..ecd07b8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -52,6 +52,13 @@
/* Define default autoconverge cpu throttle migration parameters */
#define DEFAULT_MIGRATE_X_CPU_THROTTLE_INITIAL 20
#define DEFAULT_MIGRATE_X_CPU_THROTTLE_INCREMENT 10
+/* Default cache drop control
+ * 0: no drop
+ * 1: drop clean page cache
+ * 2: drop slab cache
+ * 3: drop both clean and slab cache
+ */
+#define DEFAULT_MIGRATE_X_DROP_CACHE 0
/* Migration XBZRLE default cache size */
#define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024)
@@ -91,6 +98,8 @@ MigrationState *migrate_get_current(void)
DEFAULT_MIGRATE_X_CPU_THROTTLE_INITIAL,
.parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] =
DEFAULT_MIGRATE_X_CPU_THROTTLE_INCREMENT,
+ .parameters[MIGRATION_PARAMETER_X_DROP_CACHE] =
+ DEFAULT_MIGRATE_X_DROP_CACHE,
};
if (!once) {
@@ -525,6 +534,7 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL];
params->x_cpu_throttle_increment =
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT];
+ params->x_drop_cache = s->parameters[MIGRATION_PARAMETER_X_DROP_CACHE];
return params;
}
@@ -721,7 +731,9 @@ void qmp_migrate_set_parameters(bool has_compress_level,
bool has_x_cpu_throttle_initial,
int64_t x_cpu_throttle_initial,
bool has_x_cpu_throttle_increment,
- int64_t x_cpu_throttle_increment, Error **errp)
+ int64_t x_cpu_throttle_increment,
+ bool has_x_drop_cache,
+ int64_t x_drop_cache, Error **errp)
{
MigrationState *s = migrate_get_current();
@@ -756,6 +768,11 @@ void qmp_migrate_set_parameters(bool has_compress_level,
"x_cpu_throttle_increment",
"an integer in the range of 1 to 99");
}
+ if (has_x_drop_cache && (x_drop_cache < 0 || x_drop_cache > 3)) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ "x_drop_cache",
+ "an integer in the range of 0 to 3");
+ }
if (has_compress_level) {
s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level;
@@ -776,6 +793,9 @@ void qmp_migrate_set_parameters(bool has_compress_level,
s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT] =
x_cpu_throttle_increment;
}
+ if (has_x_drop_cache) {
+ s->parameters[MIGRATION_PARAMETER_X_DROP_CACHE] = x_drop_cache;
+ }
}
void qmp_migrate_start_postcopy(Error **errp)
@@ -1182,6 +1202,15 @@ int migrate_decompress_threads(void)
return s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS];
}
+int migrate_drop_cache(void)
+{
+ MigrationState *s;
+
+ s = migrate_get_current();
+
+ return s->parameters[MIGRATION_PARAMETER_X_DROP_CACHE];
+}
+
bool migrate_use_events(void)
{
MigrationState *s;
diff --git a/migration/ram.c b/migration/ram.c
index 3944426..0d5fc97 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -229,7 +229,6 @@ static uint64_t migration_dirty_pages;
static uint32_t last_version;
static bool ram_bulk_stage;
static bool ignore_freepage_rsp;
-static bool drop_page_cache;
/* used by the search for pages to send */
struct PageSearchStatus {
@@ -1520,12 +1519,7 @@ static void ram_request_free_page(unsigned long *bmap, unsigned long max_pfn)
{
FreePageStatus status;
- /* drop_page_cache should be set by user, the related code will be
- * added later, set it to ture temporarily.
- */
- drop_page_cache = true;
-
- status = balloon_get_free_pages(bmap, max_pfn, drop_page_cache);
+ status = balloon_get_free_pages(bmap, max_pfn, migrate_drop_cache());
switch (status) {
case FREE_PAGE_REQ:
ignore_freepage_rsp = false;
@@ -1546,7 +1540,7 @@ static void ram_handle_free_page(void)
FreePageStatus status;
status = balloon_get_free_pages(migration_bitmap_rcu->free_page_bmap,
- get_guest_max_pfn(), drop_page_cache);
+ get_guest_max_pfn(), migrate_drop_cache());
switch (status) {
case FREE_PAGE_READY:
rcu_read_lock();
diff --git a/qapi-schema.json b/qapi-schema.json
index 54634c4..8674d35 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -612,11 +612,21 @@
# @x-cpu-throttle-increment: throttle percentage increase each time
# auto-converge detects that migration is not making
# progress. The default value is 10. (Since 2.5)
+# @x-drop-cache: drop guest's page cache during live migration, the value can
+# be set to 0, 1, 2, 3. 1 means drop the clean page cache, 2 means
+# drop the slab cache, 3 means to drop both clean page cache, 0 means
+# do not drop any cache. Drop cache can speed up live migration
+# process and reduce the network traffic, the side affect is the
+# performance impact to the guest, 1 is the recommended value for
+# proper balance between speed and performance. The value only takes
+# affect when the virtio-balloon device are enabled and the guest
+# has the related driver. The default value is 0. (Since 2.7)
# Since: 2.4
##
{ 'enum': 'MigrationParameter',
'data': ['compress-level', 'compress-threads', 'decompress-threads',
- 'x-cpu-throttle-initial', 'x-cpu-throttle-increment'] }
+ 'x-cpu-throttle-initial', 'x-cpu-throttle-increment',
+ 'x-drop-cache'] }
#
# @migrate-set-parameters
@@ -636,6 +646,10 @@
# @x-cpu-throttle-increment: throttle percentage increase each time
# auto-converge detects that migration is not making
# progress. The default value is 10. (Since 2.5)
+#
+# @x-drop-cache: guest cache drop control, determine what kind of guest cache
+# to drop during live migration. The default value is 0. (Since 2.7)
+#
# Since: 2.4
##
{ 'command': 'migrate-set-parameters',
@@ -643,7 +657,8 @@
'*compress-threads': 'int',
'*decompress-threads': 'int',
'*x-cpu-throttle-initial': 'int',
- '*x-cpu-throttle-increment': 'int'} }
+ '*x-cpu-throttle-increment': 'int',
+ '*x-drop-cache': 'int'} }
#
# @MigrationParameters
@@ -662,6 +677,9 @@
# auto-converge detects that migration is not making
# progress. The default value is 10. (Since 2.5)
#
+# @x-drop-cache: guest cache drop control, determine what kind of guest cache
+# to drop during live migration. The default value is 0. (Since 2.7)
+#
# Since: 2.4
##
{ 'struct': 'MigrationParameters',
@@ -669,7 +687,8 @@
'compress-threads': 'int',
'decompress-threads': 'int',
'x-cpu-throttle-initial': 'int',
- 'x-cpu-throttle-increment': 'int'} }
+ 'x-cpu-throttle-increment': 'int',
+ 'x-drop-cache': 'int'} }
##
# @query-migrate-parameters
#
--
1.8.3.1
next prev parent reply other threads:[~2016-04-19 14:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 14:20 [Qemu-devel] [PATCH QEMU 0/5] spee up live migration by skipping free pages Liang Li
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 1/5] bitmap: Add a new bitmap_move function Liang Li
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 2/5] kvm: Add two new arch specific functions Liang Li
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 3/5] virtio-balloon: Add a new feature to balloon device Liang Li
2016-04-19 16:32 ` Michael S. Tsirkin
2016-04-19 14:20 ` [Qemu-devel] [PATCH QEMU 4/5] migration: filter out free pages during live migration Liang Li
2016-04-19 14:20 ` Liang Li [this message]
2016-04-19 14:52 ` [Qemu-devel] [PATCH QEMU 5/5] migration: Add the interface for cache drop control Eric Blake
2016-04-19 14:59 ` Li, Liang Z
2016-04-19 14:37 ` [Qemu-devel] [PATCH QEMU 0/5] spee up live migration by skipping free pages Alexander Graf
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=1461075643-3668-6-git-send-email-liang.z.li@intel.com \
--to=liang.z.li@intel.com \
--cc=agraf@suse.de \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=aurelien@aurel32.net \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=ehabkost@redhat.com \
--cc=james.hogan@imgtec.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@redhat.com \
--cc=leon.alrae@imgtec.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=rth@twiddle.net \
/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).