All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: Yang Zhang <yang.z.zhang@intel.com>, Liang Li <liang.z.li@intel.com>
Subject: [Qemu-devel] [PULL 12/16] migration: Use an array instead of 3 parameters
Date: Thu,  7 May 2015 13:50:40 +0200	[thread overview]
Message-ID: <1430999444-24315-13-git-send-email-quintela@redhat.com> (raw)
In-Reply-To: <1430999444-24315-1-git-send-email-quintela@redhat.com>

From: Liang Li <liang.z.li@intel.com>

Put the three parameters related to multiple thread (de)compression
into an int array, and use an enum type to index the parameter.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/migration.h |  4 +---
 migration/migration.c         | 31 +++++++++++++++++++------------
 qapi-schema.json              | 23 +++++++++++++++++++++++
 3 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index d4a1062..a6e025a 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -50,9 +50,7 @@ struct MigrationState
     QemuThread thread;
     QEMUBH *cleanup_bh;
     QEMUFile *file;
-    int compress_thread_count;
-    int decompress_thread_count;
-    int compress_level;
+    int parameters[MIGRATION_PARAMETER_MAX];

     int state;
     MigrationParams params;
diff --git a/migration/migration.c b/migration/migration.c
index dc7db87..533717c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -60,9 +60,12 @@ MigrationState *migrate_get_current(void)
         .bandwidth_limit = MAX_THROTTLE,
         .xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
         .mbps = -1,
-        .compress_thread_count = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,
-        .decompress_thread_count = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,
-        .compress_level = DEFAULT_MIGRATE_COMPRESS_LEVEL,
+        .parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] =
+                DEFAULT_MIGRATE_COMPRESS_LEVEL,
+        .parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] =
+                DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT,
+        .parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] =
+                DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT,
     };

     return &current_migration;
@@ -406,9 +409,11 @@ static MigrationState *migrate_init(const MigrationParams *params)
     int64_t bandwidth_limit = s->bandwidth_limit;
     bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
     int64_t xbzrle_cache_size = s->xbzrle_cache_size;
-    int compress_level = s->compress_level;
-    int compress_thread_count = s->compress_thread_count;
-    int decompress_thread_count = s->decompress_thread_count;
+    int compress_level = s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL];
+    int compress_thread_count =
+            s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS];
+    int decompress_thread_count =
+            s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS];

     memcpy(enabled_capabilities, s->enabled_capabilities,
            sizeof(enabled_capabilities));
@@ -419,9 +424,11 @@ static MigrationState *migrate_init(const MigrationParams *params)
            sizeof(enabled_capabilities));
     s->xbzrle_cache_size = xbzrle_cache_size;

-    s->compress_level = compress_level;
-    s->compress_thread_count = compress_thread_count;
-    s->decompress_thread_count = decompress_thread_count;
+    s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level;
+    s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] =
+               compress_thread_count;
+    s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] =
+               decompress_thread_count;
     s->bandwidth_limit = bandwidth_limit;
     s->state = MIGRATION_STATUS_SETUP;
     trace_migrate_set_state(MIGRATION_STATUS_SETUP);
@@ -624,7 +631,7 @@ int migrate_compress_level(void)

     s = migrate_get_current();

-    return s->compress_level;
+    return s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL];
 }

 int migrate_compress_threads(void)
@@ -633,7 +640,7 @@ int migrate_compress_threads(void)

     s = migrate_get_current();

-    return s->compress_thread_count;
+    return s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS];
 }

 int migrate_decompress_threads(void)
@@ -642,7 +649,7 @@ int migrate_decompress_threads(void)

     s = migrate_get_current();

-    return s->decompress_thread_count;
+    return s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS];
 }

 int migrate_use_xbzrle(void)
diff --git a/qapi-schema.json b/qapi-schema.json
index 83f0b4a..9c03e17 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -569,6 +569,29 @@
 ##
 { 'command': 'query-migrate-capabilities', 'returns':   ['MigrationCapabilityStatus']}

+# @MigrationParameter
+#
+# Migration parameters enumeration
+#
+# @compress-level: Set the compression level to be used in live migration,
+#          the compression level is an integer between 0 and 9, where 0 means
+#          no compression, 1 means the best compression speed, and 9 means best
+#          compression ratio which will consume more CPU.
+#
+# @compress-threads: Set compression thread count to be used in live migration,
+#          the compression thread count is an integer between 1 and 255.
+#
+# @decompress-threads: Set decompression thread count to be used in live
+#          migration, the decompression thread count is an integer between 1
+#          and 255. Usually, decompression is at least 4 times as fast as
+#          compression, so set the decompress-threads to the number about 1/4
+#          of compress-threads is adequate.
+#
+# Since: 2.4
+##
+{ 'enum': 'MigrationParameter',
+  'data': ['compress-level', 'compress-threads', 'decompress-threads'] }
+
 ##
 # @MouseInfo:
 #
-- 
2.4.0

  parent reply	other threads:[~2015-05-07 11:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 11:50 [Qemu-devel] [PULL 00/16] Migration pull request (v2) Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 01/16] docs: Add a doc about multiple thread compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 02/16] migration: Add the framework of multi-thread compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 03/16] migration: Add the framework of multi-thread decompression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 04/16] qemu-file: Add compression functions to QEMUFile Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 05/16] arch_init: Alloc and free data struct for compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 06/16] arch_init: Add and free data struct for decompression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 07/16] migration: Split save_zero_page from ram_save_page Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 08/16] migration: Add the core code of multi-thread compression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 09/16] migration: Make compression co-work with xbzrle Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 10/16] migration: Add the core code for decompression Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 11/16] migration: Add interface to control compression Juan Quintela
2015-05-07 11:50 ` Juan Quintela [this message]
2015-05-07 11:50 ` [Qemu-devel] [PULL 13/16] migration: Add qmp commands to set and query parameters Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 14/16] migration: Add hmp interface " Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 15/16] migration: avoid divide by zero in xbzrle cache miss rate Juan Quintela
2015-05-07 11:50 ` [Qemu-devel] [PULL 16/16] migration: Fix migration state update issue Juan Quintela
2015-05-07 12:45 ` [Qemu-devel] [PULL 00/16] Migration pull request (v2) Peter Maydell
2015-05-07 14:43   ` Eric Blake
2015-05-07 14:56     ` Paolo Bonzini
2015-05-07 18:10   ` Amit Shah
2015-05-08  9:31     ` Stefan Hajnoczi
2015-05-11 11:04       ` Amit Shah
2015-05-11 11:37         ` Peter Maydell
2015-05-11 14:29           ` Dr. David Alan Gilbert
2015-05-11 11:47       ` Alex Bennée
2015-05-07 16:46 [Qemu-devel] [PULL 00/16] Migration pull requset (take 3) Juan Quintela
2015-05-07 16:46 ` [Qemu-devel] [PULL 12/16] migration: Use an array instead of 3 parameters Juan Quintela

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=1430999444-24315-13-git-send-email-quintela@redhat.com \
    --to=quintela@redhat.com \
    --cc=liang.z.li@intel.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yang.z.zhang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.