From patchwork Tue Nov 23 23:03:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 72775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F0EEAB6EDF for ; Wed, 24 Nov 2010 10:14:55 +1100 (EST) Received: from localhost ([127.0.0.1]:44397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL24a-00078r-5H for incoming@patchwork.ozlabs.org; Tue, 23 Nov 2010 18:14:52 -0500 Received: from [140.186.70.92] (port=57156 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PL1th-0001I6-9k for qemu-devel@nongnu.org; Tue, 23 Nov 2010 18:03:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PL1tT-0000sU-L5 for qemu-devel@nongnu.org; Tue, 23 Nov 2010 18:03:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PL1tT-0000sH-9R for qemu-devel@nongnu.org; Tue, 23 Nov 2010 18:03:23 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oANN3JY5013257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 23 Nov 2010 18:03:19 -0500 Received: from trasno.mitica (ovpn-113-23.phx2.redhat.com [10.3.113.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oANN3D5X025161; Tue, 23 Nov 2010 18:03:18 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 24 Nov 2010 00:03:00 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Juan Quintela Subject: [Qemu-devel] [PATCH 03/10] Add printf debug to savevm X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Juan Quintela Once there, print all sections that take more than 100ms to migrate. buffered file runs a timer at that 100ms interval. Signed-off-by: Juan Quintela Signed-off-by: Juan Quintela --- savevm.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/savevm.c b/savevm.c index 4e49765..ceed6de 100644 --- a/savevm.c +++ b/savevm.c @@ -83,6 +83,24 @@ #include "migration.h" #include "qemu_socket.h" #include "qemu-queue.h" +#include "buffered_file.h" + +//#define DEBUG_SAVEVM + +#ifdef DEBUG_SAVEVM +#define DPRINTF(fmt, ...) \ + do { printf("savevm: " fmt, ## __VA_ARGS__); } while (0) +static int64_t start, stop; +#define START_SAVEVM_CLOCK() do { start = qemu_get_clock(rt_clock); } while (0) +#define STOP_SAVEVM_CLOCK() \ + do { stop = qemu_get_clock(rt_clock) - start; \ + } while (0) +#else +#define DPRINTF(fmt, ...) \ + do { } while (0) +#define START_SAVEVM_CLOCK() do { } while (0) +#define STOP_SAVEVM_CLOCK() do { } while (0) +#endif #define SELF_ANNOUNCE_ROUNDS 5 @@ -1480,11 +1498,23 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) if (se->save_live_state == NULL) continue; + START_SAVEVM_CLOCK(); + /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_PART); qemu_put_be32(f, se->section_id); ret = se->save_live_state(mon, f, QEMU_VM_SECTION_PART, se->opaque); + STOP_SAVEVM_CLOCK(); +#ifdef DEBUG_SAVEVM + if (stop > buffered_file_interval) { + /* buffered_file run a timer at 100ms */ + static int times_missing = 1; + DPRINTF("save live iterate section id %u name %s took %ld milliseconds %u times\n", + se->section_id, se->idstr, stop, times_missing++); + } +#endif + if (!ret) { /* Do not proceed to the next vmstate before this one reported completion of the current stage. This serializes the migration @@ -1516,13 +1546,18 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) if (se->save_live_state == NULL) continue; + START_SAVEVM_CLOCK(); /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque); + STOP_SAVEVM_CLOCK(); + DPRINTF("save live end section id %u name %s took %ld milliseconds\n", + se->section_id, se->idstr, stop); } + START_SAVEVM_CLOCK(); QTAILQ_FOREACH(se, &savevm_handlers, entry) { int len; @@ -1542,12 +1577,14 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) qemu_put_be32(f, se->version_id); r = vmstate_save(f, se); + DPRINTF("save section id %u name %s\n", se->section_id, se->idstr); if (r < 0) { monitor_printf(mon, "cannot migrate with device '%s'\n", se->idstr); return r; } } - + STOP_SAVEVM_CLOCK(); + DPRINTF("save devices took %ld milliseconds\n", stop); qemu_put_byte(f, QEMU_VM_EOF); if (qemu_file_has_error(f)) @@ -1746,8 +1783,11 @@ int qemu_loadvm_state(QEMUFile *f) le->section_id = section_id; le->version_id = version_id; QLIST_INSERT_HEAD(&loadvm_handlers, le, entry); - + START_SAVEVM_CLOCK(); ret = vmstate_load(f, le->se, le->version_id); + STOP_SAVEVM_CLOCK(); + DPRINTF("load section id %u name %s took %ld milliseconds\n", le->section_id, + le->se->idstr, stop); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", instance_id, idstr); @@ -1769,7 +1809,11 @@ int qemu_loadvm_state(QEMUFile *f) goto out; } + START_SAVEVM_CLOCK(); ret = vmstate_load(f, le->se, le->version_id); + STOP_SAVEVM_CLOCK(); + DPRINTF("load section id %u name %s took %ld milliseconds\n", le->section_id, + le->se->idstr, stop); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state section id %d\n", section_id);