From nobody Sun Apr 28 18:07:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496222431207653.1769942057988; Wed, 31 May 2017 02:20:31 -0700 (PDT) Received: from localhost ([::1]:58055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFznp-0002ff-Es for importer@patchew.org; Wed, 31 May 2017 05:20:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzjI-0007ji-46 for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFzjF-0001qu-Kb for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFzjF-0001qk-CV for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54D7680C07 for ; Wed, 31 May 2017 09:15:44 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB87E4FA40; Wed, 31 May 2017 09:15:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 54D7680C07 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 54D7680C07 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 11:15:34 +0200 Message-Id: <20170531091538.21626-2-quintela@redhat.com> In-Reply-To: <20170531091538.21626-1-quintela@redhat.com> References: <20170531091538.21626-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 09:15:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/5] migration: Create savevm.h for functions exported from savevm.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This removes last trace of migration functions from sysemu/sysemu.h. Signed-off-by: Juan Quintela Reviewed-by: Laurent Vivier --- include/sysemu/sysemu.h | 47 --------------------------------------------= --- migration/colo.c | 1 + migration/migration.c | 1 + migration/postcopy-ram.c | 1 + migration/savevm.c | 29 +++++++++++++++++++++++++---- migration/savevm.h | 41 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 migration/savevm.h diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 69046eb..723c8dc 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -97,53 +97,6 @@ int load_vmstate(const char *name, Error **errp); =20 void qemu_announce_self(void); =20 -/* Subcommands for QEMU_VM_COMMAND */ -enum qemu_vm_cmd { - MIG_CMD_INVALID =3D 0, /* Must be 0 */ - MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */ - MIG_CMD_PING, /* Request a PONG on the RP */ - - MIG_CMD_POSTCOPY_ADVISE, /* Prior to any page transfers, just - warn we might want to do PC */ - MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming - pages as it's running. */ - MIG_CMD_POSTCOPY_RUN, /* Start execution */ - - MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that - were previously sent during - precopy but are dirty. */ - MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream= */ - MIG_CMD_MAX -}; - -#define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24) - -bool qemu_savevm_state_blocked(Error **errp); -void qemu_savevm_state_begin(QEMUFile *f); -void qemu_savevm_state_header(QEMUFile *f); -int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); -void qemu_savevm_state_cleanup(void); -void qemu_savevm_state_complete_postcopy(QEMUFile *f); -void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only); -void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, - uint64_t *res_non_postcopiable, - uint64_t *res_postcopiable); -void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command, - uint16_t len, uint8_t *data); -void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); -void qemu_savevm_send_open_return_path(QEMUFile *f); -int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); -void qemu_savevm_send_postcopy_advise(QEMUFile *f); -void qemu_savevm_send_postcopy_listen(QEMUFile *f); -void qemu_savevm_send_postcopy_run(QEMUFile *f); - -void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, - uint16_t len, - uint64_t *start_list, - uint64_t *length_list); - -int qemu_loadvm_state(QEMUFile *f); - extern int autostart; =20 typedef enum { diff --git a/migration/colo.c b/migration/colo.c index 8c13a3c..3dd1390 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -16,6 +16,7 @@ #include "qemu-file-channel.h" #include "migration/migration.h" #include "migration/qemu-file.h" +#include "savevm.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h" diff --git a/migration/migration.c b/migration/migration.c index ad29e53..7087d1a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -19,6 +19,7 @@ #include "qemu/main-loop.h" #include "migration/blocker.h" #include "migration/migration.h" +#include "savevm.h" #include "qemu-file-channel.h" #include "migration/qemu-file.h" #include "migration/vmstate.h" diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index a37620d..3f9ae1b 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -22,6 +22,7 @@ #include "exec/target_page.h" #include "migration/migration.h" #include "migration/qemu-file.h" +#include "savevm.h" #include "postcopy-ram.h" #include "sysemu/sysemu.h" #include "sysemu/balloon.h" diff --git a/migration/savevm.c b/migration/savevm.c index a4532b6..a2d4f9c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -36,6 +36,7 @@ #include "qemu/timer.h" #include "migration/migration.h" #include "qemu-file-channel.h" +#include "savevm.h" #include "postcopy-ram.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" @@ -63,6 +64,26 @@ const unsigned int postcopy_ram_discard_version =3D 0; =20 static bool skip_section_footers; =20 +/* Subcommands for QEMU_VM_COMMAND */ +enum qemu_vm_cmd { + MIG_CMD_INVALID =3D 0, /* Must be 0 */ + MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */ + MIG_CMD_PING, /* Request a PONG on the RP */ + + MIG_CMD_POSTCOPY_ADVISE, /* Prior to any page transfers, just + warn we might want to do PC */ + MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming + pages as it's running. */ + MIG_CMD_POSTCOPY_RUN, /* Start execution */ + + MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that + were previously sent during + precopy but are dirty. */ + MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream= */ + MIG_CMD_MAX +}; + +#define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24) static struct mig_cmd_args { ssize_t len; /* -1 =3D variable */ const char *name; @@ -807,10 +828,10 @@ static void save_section_footer(QEMUFile *f, SaveStat= eEntry *se) * @len: Length of associated data * @data: Data associated with command. */ -void qemu_savevm_command_send(QEMUFile *f, - enum qemu_vm_cmd command, - uint16_t len, - uint8_t *data) +static void qemu_savevm_command_send(QEMUFile *f, + enum qemu_vm_cmd command, + uint16_t len, + uint8_t *data) { trace_savevm_command_send(command, len); qemu_put_byte(f, QEMU_VM_COMMAND); diff --git a/migration/savevm.h b/migration/savevm.h new file mode 100644 index 0000000..eb44877 --- /dev/null +++ b/migration/savevm.h @@ -0,0 +1,41 @@ +/* + * QEMU save vm functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009-2017 Red Hat Inc + * + * Authors: + * Juan Quintela + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef MIGRATION_SAVEVM_H +#define MIGRATION_SAVEVM_H + +bool qemu_savevm_state_blocked(Error **errp); +void qemu_savevm_state_begin(QEMUFile *f); +void qemu_savevm_state_header(QEMUFile *f); +int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); +void qemu_savevm_state_cleanup(void); +void qemu_savevm_state_complete_postcopy(QEMUFile *f); +void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only); +void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, + uint64_t *res_non_postcopiable, + uint64_t *res_postcopiable); +void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); +void qemu_savevm_send_open_return_path(QEMUFile *f); +int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); +void qemu_savevm_send_postcopy_advise(QEMUFile *f); +void qemu_savevm_send_postcopy_listen(QEMUFile *f); +void qemu_savevm_send_postcopy_run(QEMUFile *f); + +void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, + uint16_t len, + uint64_t *start_list, + uint64_t *length_list); + +int qemu_loadvm_state(QEMUFile *f); + +#endif --=20 2.9.4 From nobody Sun Apr 28 18:07:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496222263208885.3389487616238; Wed, 31 May 2017 02:17:43 -0700 (PDT) Received: from localhost ([::1]:58046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzl6-0000Mg-0g for importer@patchew.org; Wed, 31 May 2017 05:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzjI-0007jk-4H for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFzjH-0001r5-8t for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFzjH-0001qy-2t for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3484F883A4; Wed, 31 May 2017 09:15:46 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id A62B64FA40; Wed, 31 May 2017 09:15:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3484F883A4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3484F883A4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 11:15:35 +0200 Message-Id: <20170531091538.21626-3-quintela@redhat.com> In-Reply-To: <20170531091538.21626-1-quintela@redhat.com> References: <20170531091538.21626-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 09:15:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/5] migration: keep bytes_xfer_prev init'd to zero X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, Felipe Franciosi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Felipe Franciosi The first time migration_bitmap_sync() is called, bytes_xfer_prev is set to ram_state.bytes_transferred which is, at this point, zero. The next time migration_bitmap_sync() is called, an iteration has happened and bytes_xfer_prev is set to 'x' bytes. Most likely, more than one second has passed, so the auto converge logic will be triggered and bytes_xfer_now will also be set to 'x' bytes. This condition is currently masked by dirty_rate_high_cnt, which will wait for a few iterations before throttling. It would otherwise always assume zero bytes have been copied and therefore throttle the guest (possibly) prematurely. Given bytes_xfer_prev is only used by the auto convergence logic, it makes sense to only set its value after a check has been made against bytes_xfer_now. Signed-off-by: Felipe Franciosi Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c07a9c0..36bf720 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -673,10 +673,6 @@ static void migration_bitmap_sync(RAMState *rs) =20 rs->bitmap_sync_count++; =20 - if (!rs->bytes_xfer_prev) { - rs->bytes_xfer_prev =3D ram_bytes_transferred(); - } - if (!rs->time_last_bitmap_sync) { rs->time_last_bitmap_sync =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E); } --=20 2.9.4 From nobody Sun Apr 28 18:07:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496222269277812.7945646765073; Wed, 31 May 2017 02:17:49 -0700 (PDT) Received: from localhost ([::1]:58048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzlD-0000TF-N2 for importer@patchew.org; Wed, 31 May 2017 05:17:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzjK-0007jz-8b for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFzjJ-0001rz-7Q for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFzjI-0001rl-Uc for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F7518123F; Wed, 31 May 2017 09:15:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 859CC4FA40; Wed, 31 May 2017 09:15:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F7518123F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0F7518123F From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 11:15:36 +0200 Message-Id: <20170531091538.21626-4-quintela@redhat.com> In-Reply-To: <20170531091538.21626-1-quintela@redhat.com> References: <20170531091538.21626-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 09:15:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/5] migration: set dirty_pages_rate before autoconverge logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, Felipe Franciosi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Felipe Franciosi Currently, a "period" in the RAM migration logic is at least a second long and accounts for what happened since the last period (or the beginning of the migration). The dirty_pages_rate counter is calculated at the end this logic. If the auto convergence capability is enabled from the start of the migration, it won't be able to use this counter the first time around. This calculates dirty_pages_rate as soon as a period is deemed over, which allows for it to be used immediately. Signed-off-by: Felipe Franciosi Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 36bf720..495ecbe 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -694,6 +694,10 @@ static void migration_bitmap_sync(RAMState *rs) =20 /* more than 1 second =3D 1000 millisecons */ if (end_time > rs->time_last_bitmap_sync + 1000) { + /* calculate period counters */ + rs->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 + / (end_time - rs->time_last_bitmap_sync); + if (migrate_auto_converge()) { /* The following detection logic can be refined later. For now: Check to see if the dirtied bytes is 50% more than the appr= ox. @@ -702,15 +706,14 @@ static void migration_bitmap_sync(RAMState *rs) throttling */ bytes_xfer_now =3D ram_bytes_transferred(); =20 - if (rs->dirty_pages_rate && - (rs->num_dirty_pages_period * TARGET_PAGE_SIZE > + if ((rs->num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - rs->bytes_xfer_prev) / 2) && - (rs->dirty_rate_high_cnt++ >=3D 2)) { + (rs->dirty_rate_high_cnt++ >=3D 2)) { trace_migration_throttle(); rs->dirty_rate_high_cnt =3D 0; mig_throttle_guest_down(); - } - rs->bytes_xfer_prev =3D bytes_xfer_now; + } + rs->bytes_xfer_prev =3D bytes_xfer_now; } =20 if (migrate_use_xbzrle()) { @@ -723,8 +726,8 @@ static void migration_bitmap_sync(RAMState *rs) rs->iterations_prev =3D rs->iterations; rs->xbzrle_cache_miss_prev =3D rs->xbzrle_cache_miss; } - rs->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 - / (end_time - rs->time_last_bitmap_sync); + + /* reset period counters */ rs->time_last_bitmap_sync =3D end_time; rs->num_dirty_pages_period =3D 0; } --=20 2.9.4 From nobody Sun Apr 28 18:07:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149622243769796.46240654152336; Wed, 31 May 2017 02:20:37 -0700 (PDT) Received: from localhost ([::1]:58061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFznw-0002mv-7j for importer@patchew.org; Wed, 31 May 2017 05:20:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzjL-0007lM-Ud for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFzjK-0001uk-W4 for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFzjK-0001tC-PF for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAC4685543; Wed, 31 May 2017 09:15:49 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 606584FA40; Wed, 31 May 2017 09:15:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAC4685543 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DAC4685543 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 11:15:37 +0200 Message-Id: <20170531091538.21626-5-quintela@redhat.com> In-Reply-To: <20170531091538.21626-1-quintela@redhat.com> References: <20170531091538.21626-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 31 May 2017 09:15:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/5] migration: set bytes_xfer_* outside of autoconverge logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, Felipe Franciosi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Felipe Franciosi The bytes_xfer_now/prev counters are only used by the auto convergence logic. However, they are used alongside the dirty_pages_rate counter, which is calculated (and required) outside of this logic. The problem with this approach is that if the auto convergence capability is changed while a migration is ongoing, the relationship of the counters will be broken. This moves the management of bytes_xfer_now/prev counters outside of the auto convergence logic to address this issue. Signed-off-by: Felipe Franciosi Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 495ecbe..1a3d9e6 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -697,6 +697,7 @@ static void migration_bitmap_sync(RAMState *rs) /* calculate period counters */ rs->dirty_pages_rate =3D rs->num_dirty_pages_period * 1000 / (end_time - rs->time_last_bitmap_sync); + bytes_xfer_now =3D ram_bytes_transferred(); =20 if (migrate_auto_converge()) { /* The following detection logic can be refined later. For now: @@ -704,7 +705,6 @@ static void migration_bitmap_sync(RAMState *rs) amount of bytes that just got transferred since the last ti= me we were in this routine. If that happens twice, start or incre= ase throttling */ - bytes_xfer_now =3D ram_bytes_transferred(); =20 if ((rs->num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - rs->bytes_xfer_prev) / 2) && @@ -713,7 +713,6 @@ static void migration_bitmap_sync(RAMState *rs) rs->dirty_rate_high_cnt =3D 0; mig_throttle_guest_down(); } - rs->bytes_xfer_prev =3D bytes_xfer_now; } =20 if (migrate_use_xbzrle()) { @@ -730,6 +729,7 @@ static void migration_bitmap_sync(RAMState *rs) /* reset period counters */ rs->time_last_bitmap_sync =3D end_time; rs->num_dirty_pages_period =3D 0; + rs->bytes_xfer_prev =3D bytes_xfer_now; } if (migrate_use_events()) { qapi_event_send_migration_pass(rs->bitmap_sync_count, NULL); --=20 2.9.4 From nobody Sun Apr 28 18:07:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496222276655455.4764916362875; Wed, 31 May 2017 02:17:56 -0700 (PDT) Received: from localhost ([::1]:58049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzlL-0000bg-1J for importer@patchew.org; Wed, 31 May 2017 05:17:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFzjN-0007n5-LU for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFzjM-0001wc-S1 for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54564) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFzjM-0001wX-Ll for qemu-devel@nongnu.org; Wed, 31 May 2017 05:15:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B468381245; Wed, 31 May 2017 09:15:51 +0000 (UTC) Received: from secure.mitica (ovpn-116-157.ams2.redhat.com [10.36.116.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38E9C5DC1F; Wed, 31 May 2017 09:15:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B468381245 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B468381245 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 11:15:38 +0200 Message-Id: <20170531091538.21626-6-quintela@redhat.com> In-Reply-To: <20170531091538.21626-1-quintela@redhat.com> References: <20170531091538.21626-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 09:15:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/5] migration: use dirty_rate_high_cnt more aggressively X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, Felipe Franciosi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Felipe Franciosi The commit message from 070afca25 suggests that dirty_rate_high_cnt should be used more aggressively to start throttling after two iterations instead of four. The code, however, only changes the auto convergence behaviour to throttle after three iterations. This makes the behaviour more aggressive by kicking off throttling after two iterations as originally intended. Signed-off-by: Felipe Franciosi Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 1a3d9e6..26e03a5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -708,7 +708,7 @@ static void migration_bitmap_sync(RAMState *rs) =20 if ((rs->num_dirty_pages_period * TARGET_PAGE_SIZE > (bytes_xfer_now - rs->bytes_xfer_prev) / 2) && - (rs->dirty_rate_high_cnt++ >=3D 2)) { + (++rs->dirty_rate_high_cnt >=3D 2)) { trace_migration_throttle(); rs->dirty_rate_high_cnt =3D 0; mig_throttle_guest_down(); --=20 2.9.4