From patchwork Thu Oct 26 15:53:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1855869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZS3h1aE7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SGVjs5y02z23jh for ; Fri, 27 Oct 2023 02:54:57 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qw2gQ-0005sY-0b; Thu, 26 Oct 2023 11:54:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw2gO-0005sO-D8 for qemu-devel@nongnu.org; Thu, 26 Oct 2023 11:54:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw2gM-0000tF-Su for qemu-devel@nongnu.org; Thu, 26 Oct 2023 11:54:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698335642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pVnr5wFaay66KVUCJQ7STeYMkubTSR3EFWIQEUk4fwM=; b=ZS3h1aE7pbhdWdfdl/AAdhENaqpfTqrNeqq6CuNOcPFEkiv7osvTjTw9qBs87WfCbo3KZE PG0WENijEPIsuTP054188jLOphyL1/27A4dWHJXoh7pRKgHRepgfKqo8oxIcwPkS4GcX+r 9PsjJpmvUC4EB3ol+968994+VvJeQeo= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-484-1HGANl37M8SPhnpOjweGmA-1; Thu, 26 Oct 2023 11:53:45 -0400 X-MC-Unique: 1HGANl37M8SPhnpOjweGmA-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-41e1ecf3350so2448031cf.1 for ; Thu, 26 Oct 2023 08:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335625; x=1698940425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pVnr5wFaay66KVUCJQ7STeYMkubTSR3EFWIQEUk4fwM=; b=RrImI0JvIGiwKhbkPQrYcKGiUzIwXY1XVBKXjsXqj04X19qoOiP4Vt1QoB9VGkTe45 pO86fM2VzSFnhaqS3rnPjJFwiu2PiF7XyaSciS3BA9huTI/qeE6Cqos/Q5sDXaDiQjoB 4m7rBt+XP7dAFgZ0AQWNY+6opEKfrDlsdOnsglJcxlbDCykmDW6QiW/6ab+pY04UkjXj Lmh1VQ7RT1L6NqwaFE8V+NiZjUodhbw/6s7fgW/HF6o48nJb6t8UepTBqb81xTVBoRcV hR65cYgt8ERmJjyKbmEtq3SclvLO6HXT7UBWNVdHXz/2GPbQkpuu1DgSP7mx+y4mdJUf /71Q== X-Gm-Message-State: AOJu0Yw4KDz1C/JBAKigeGK7b71J0UUPZiCqGPfbUDih0WK0NAoUMjD1 so1busghHZa5OOM9X7dymztd9GwdGiQLttLNHN18miF48QFHlQrMijHL+HvAHDnB4S6KY6yO4JT C68r6SNOR/O6UtBdtThQ5sxQj5+9sDKHMKb79WN4p/UIKM2U1D5Js5nVOaHV0/LR5mtdC811W X-Received: by 2002:a05:622a:1a05:b0:403:c2fa:83b with SMTP id f5-20020a05622a1a0500b00403c2fa083bmr20194647qtb.4.1698335625096; Thu, 26 Oct 2023 08:53:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4zIbwUKNnmdkDLw7CYaroIPih/iPd9tlAom09vRlxkmDlBp3+fg+NcuDAVwuiDlUyLsRZ4A== X-Received: by 2002:a05:622a:1a05:b0:403:c2fa:83b with SMTP id f5-20020a05622a1a0500b00403c2fa083bmr20194623qtb.4.1698335624743; Thu, 26 Oct 2023 08:53:44 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id f15-20020ac840cf000000b004181f542bcbsm5066580qtm.11.2023.10.26.08.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:53:41 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Juan Quintela , Joao Martins Subject: [PATCH 1/3] migration: Set downtime_start even for postcopy Date: Thu, 26 Oct 2023 11:53:35 -0400 Message-ID: <20231026155337.596281-2-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231026155337.596281-1-peterx@redhat.com> References: <20231026155337.596281-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Postcopy calculates its downtime separately. It always sets MigrationState.downtime properly, but not MigrationState.downtime_start. Make postcopy do the same as other modes on properly recording the timestamp when the VM is going to be stopped. Drop the temporary variable in postcopy_start() along the way. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 67547eb6a1..f8a54ff4d1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2121,7 +2121,6 @@ static int postcopy_start(MigrationState *ms, Error **errp) int ret; QIOChannelBuffer *bioc; QEMUFile *fb; - int64_t time_at_stop = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); uint64_t bandwidth = migrate_max_postcopy_bandwidth(); bool restart_block = false; int cur_state = MIGRATION_STATUS_ACTIVE; @@ -2143,6 +2142,8 @@ static int postcopy_start(MigrationState *ms, Error **errp) qemu_mutex_lock_iothread(); trace_postcopy_start_set_run(); + ms->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); global_state_store(); ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); @@ -2245,7 +2246,7 @@ static int postcopy_start(MigrationState *ms, Error **errp) ms->postcopy_after_devices = true; migration_call_notifiers(ms); - ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop; + ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - ms->downtime_start; qemu_mutex_unlock_iothread(); From patchwork Thu Oct 26 15:53:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1855867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NEL0E/ZR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SGVjJ5vQDz23jr for ; Fri, 27 Oct 2023 02:54:28 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qw2gG-0005ra-7Q; Thu, 26 Oct 2023 11:53:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw2gE-0005rC-AR for qemu-devel@nongnu.org; Thu, 26 Oct 2023 11:53:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw2gC-0000sQ-Np for qemu-devel@nongnu.org; Thu, 26 Oct 2023 11:53:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698335631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zSHyWtkUKU/y1HHFJ9tbynjlp9Czisd65damm2Zn+wQ=; b=NEL0E/ZRQk+L0bpylzYB9POetb8Ez8dlbMVC9s9SJrKE1x56Fp9z/uev5k29/WJdhEQa07 854zfAIM4eZ0zuhDtyGZBcZzs1C1GXm+N+7PVE1sxEhddH3T9Js78Fk+qvPfWxJh98ZnPJ fN4tVep+VH+p3ypLzvd6QHt0Nqgnv/s= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-bjoFXTTfNnCpJE-3aQxKZw-1; Thu, 26 Oct 2023 11:53:49 -0400 X-MC-Unique: bjoFXTTfNnCpJE-3aQxKZw-1 Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-7b9cc998f5fso40433241.1 for ; Thu, 26 Oct 2023 08:53:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335629; x=1698940429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zSHyWtkUKU/y1HHFJ9tbynjlp9Czisd65damm2Zn+wQ=; b=aF/dWg6KMKNaI/bD2cSUCDN/lWX3uI862ONV+tGImrEweKvSNyXQeOc/5JODgOMTP0 HQ/VOdhEZ5SfpOYZAKfEL7G6qM89xQoQMq3Mq9UpEdPQhaaE6h28JA2aPUlF1EYcFgxK IxqvkeNeArSdtNMRFbCRSC6xYBvY+9VGpZ1rw2yuSvkNAykzDu8OR6loMvQ0nwzEclvr 8G6YTwtPpJcGArJXhj/HL3Cqw22oJWAslhkQchHWHyZ/1JX7PR8U65B/ZTAJcAmT9nSF 9ALadAJgqHV8gid7ClDhB8btyFhQslKRvLuA5frBnmoUruCwxgNba+Ov+4vXwMGV8vKD 9D9g== X-Gm-Message-State: AOJu0YyUvYo9oZeTd1auVbk4+eCbftuhlSKLWQGAEU6mJ/KbyLjoLkZI zbBvmQ3LdbMyj/HX5Vmx84eIwa4NNEH4n3FxcFRFKsH1pIHgLuTUspuVT9VtkIIL5OGBf5jPIP5 lTlsE4ZIsvQHd6onCmP9G3JSwJC/Q03vZ5jLhdWXw2zaRB75sLNONsEGq70zBtSg1FbClwS0J X-Received: by 2002:a05:6122:410a:b0:48f:cf1a:fd49 with SMTP id ce10-20020a056122410a00b0048fcf1afd49mr249093vkb.0.1698335629056; Thu, 26 Oct 2023 08:53:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaDFurITucUs8RENeoaOjXscYris+ls9zcVKgR7ZUGfKXVKKXPabFgmamDxkzQ4FpqzNJKaA== X-Received: by 2002:a05:6122:410a:b0:48f:cf1a:fd49 with SMTP id ce10-20020a056122410a00b0048fcf1afd49mr249064vkb.0.1698335628644; Thu, 26 Oct 2023 08:53:48 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id f15-20020ac840cf000000b004181f542bcbsm5066580qtm.11.2023.10.26.08.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:53:46 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Juan Quintela , Joao Martins Subject: [PATCH 2/3] migration: Add migration_downtime_start|end() helpers Date: Thu, 26 Oct 2023 11:53:36 -0400 Message-ID: <20231026155337.596281-3-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231026155337.596281-1-peterx@redhat.com> References: <20231026155337.596281-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Unify the three users on recording downtimes with the same pair of helpers. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/migration.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index f8a54ff4d1..70d775942a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -101,6 +101,24 @@ static int migration_maybe_pause(MigrationState *s, static void migrate_fd_cancel(MigrationState *s); static int close_return_path_on_source(MigrationState *s); +static void migration_downtime_start(MigrationState *s) +{ + s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); +} + +static void migration_downtime_end(MigrationState *s) +{ + int64_t now = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + + /* + * If downtime already set, should mean that postcopy already set it, + * then that should be the real downtime already. + */ + if (!s->downtime) { + s->downtime = now - s->downtime_start; + } +} + static bool migration_needs_multiple_sockets(void) { return migrate_multifd() || migrate_postcopy_preempt(); @@ -2142,7 +2160,7 @@ static int postcopy_start(MigrationState *ms, Error **errp) qemu_mutex_lock_iothread(); trace_postcopy_start_set_run(); - ms->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + migration_downtime_start(ms); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); global_state_store(); @@ -2246,7 +2264,7 @@ static int postcopy_start(MigrationState *ms, Error **errp) ms->postcopy_after_devices = true; migration_call_notifiers(ms); - ms->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - ms->downtime_start; + migration_downtime_end(ms); qemu_mutex_unlock_iothread(); @@ -2342,7 +2360,7 @@ static int migration_completion_precopy(MigrationState *s, int ret; qemu_mutex_lock_iothread(); - s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + migration_downtime_start(s); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_old_state = runstate_get(); @@ -2699,15 +2717,8 @@ static void migration_calculate_complete(MigrationState *s) int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); int64_t transfer_time; + migration_downtime_end(s); s->total_time = end_time - s->start_time; - if (!s->downtime) { - /* - * It's still not set, so we are precopy migration. For - * postcopy, downtime is calculated during postcopy_start(). - */ - s->downtime = end_time - s->downtime_start; - } - transfer_time = s->total_time - s->setup_time; if (transfer_time) { s->mbps = ((double) bytes * 8.0) / transfer_time / 1000; @@ -3126,7 +3137,7 @@ static void bg_migration_vm_start_bh(void *opaque) s->vm_start_bh = NULL; vm_start(); - s->downtime = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - s->downtime_start; + migration_downtime_end(s); } /** @@ -3193,7 +3204,7 @@ static void *bg_migration_thread(void *opaque) s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; trace_migration_thread_setup_complete(); - s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + migration_downtime_start(s); qemu_mutex_lock_iothread(); From patchwork Thu Oct 26 15:53:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1855868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JgKaiXEJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SGVjk0DGMz23jh for ; Fri, 27 Oct 2023 02:54:50 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qw2gI-0005rs-Ql; Thu, 26 Oct 2023 11:53:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw2gI-0005rk-4S for qemu-devel@nongnu.org; Thu, 26 Oct 2023 11:53:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw2gG-0000sb-F8 for qemu-devel@nongnu.org; Thu, 26 Oct 2023 11:53:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698335635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n72f+wW5+nHH0hrvaXv+6sujX9qgSyymTozlBQoTr/0=; b=JgKaiXEJ3vMb6Dejc3xieBSkzXKzCLw2pwQAR30+/+K/GqaWUe1Nw+EDUQjREwuUl6Qd5L WdaubxBULxHP0tUgXTfZSCHcsmfHJ38/kZvGer2LVfju/4K8sq2InV8ZKA+z2NEG0hEp1y ULG2VIwy0hGaVcF78PlGnCwuUM/78B8= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-PSz1so38P0uq4mJSPFL5qg-1; Thu, 26 Oct 2023 11:53:54 -0400 X-MC-Unique: PSz1so38P0uq4mJSPFL5qg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4197468d5caso2536481cf.1 for ; Thu, 26 Oct 2023 08:53:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698335634; x=1698940434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n72f+wW5+nHH0hrvaXv+6sujX9qgSyymTozlBQoTr/0=; b=wPJJfEwF47pMwGO35uCHz253NyuM/zlOYUWzkoQadzGeOLBKY1OWiGjvXWKwmfbSTu BRLaljk46LFPYPwhS089AaBm2OkMRwxnNhv7ycuoymrKczlOl8hZquYmgbQ19D7i/1FN jxUc+6g9AvBFamhMU0bV/XTUNHf3D/2qWkxUok7KyfkZxC1xbFovYEcENtYTHn8DcKNY JGTMiSIenCJUjdfSDwexxAjJv8aGtJB5I7Q1Wqde5ZGO4eyHXMKDmYzQ5N6W/LUyS4v9 vU6qcKtTti7XWuIk6lB1QJmba/CRDPe1oXbF2e3WS0bkv2W90tkxv9R/ppQn2Fw0lA67 M2Xg== X-Gm-Message-State: AOJu0YynjmthDhCSs7IvibztnBCM8GZsKeI9Tz9iMbqtr0kxRwNerNc/ IiPWTRoSQppd1CDK3cEI8xLiLFkdR5zzRMvmnH4sl/30tzgVXVSR78SJkTnYX7dt57r52oI5h4C JbF9xIZSO86m36e7iLcahk+4OnGYW0zy4M8utAJbYDj9hRo9N/hGmPrlGcz0kJAEgCJLTeSV3 X-Received: by 2002:a05:622a:11d3:b0:415:141e:fa21 with SMTP id n19-20020a05622a11d300b00415141efa21mr21450096qtk.6.1698335633695; Thu, 26 Oct 2023 08:53:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFG4w1H5dYiK3bjo9M4QIfSul37sf4LHAdQESwwpu5IvliqOCwf8h+HtG5uHYQKRehavhlyqg== X-Received: by 2002:a05:622a:11d3:b0:415:141e:fa21 with SMTP id n19-20020a05622a11d300b00415141efa21mr21450070qtk.6.1698335633211; Thu, 26 Oct 2023 08:53:53 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id f15-20020ac840cf000000b004181f542bcbsm5066580qtm.11.2023.10.26.08.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 08:53:49 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Fabiano Rosas , Juan Quintela , Joao Martins Subject: [PATCH 3/3] migration: Add per vmstate downtime tracepoints Date: Thu, 26 Oct 2023 11:53:37 -0400 Message-ID: <20231026155337.596281-4-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231026155337.596281-1-peterx@redhat.com> References: <20231026155337.596281-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We have a bunch of savevm_section* tracepoints, they're good to analyze migration stream, but not always suitable if someone would like to analyze the migration downtime. Two major problems: - savevm_section* tracepoints are dumping all sections, we only care about the sections that contribute to the downtime - They don't have an identifier to show the type of sections, so no way to filter downtime information either easily. We can add type into the tracepoints, but instead of doing so, this patch kept them untouched, instead of adding a bunch of downtime specific tracepoints, so one can enable "vmstate_downtime*" tracepoints and get a full picture of how the downtime is distributed across iterative and non-iterative vmstate save/load. Note that here both save() and load() need to be traced, because both of them may contribute to the downtime. The contribution is not a simple "add them together", though: consider when the src is doing a save() of device1 while the dest can be load()ing for device2, so they can happen concurrently. Tracking both sides make sense because device load() and save() can be imbalanced, one device can save() super fast, but load() super slow, vice versa. We can't figure that out without tracing both. Signed-off-by: Peter Xu --- migration/savevm.c | 49 ++++++++++++++++++++++++++++++++++++++---- migration/trace-events | 2 ++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 8622f229e5..cd6d6ba493 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1459,6 +1459,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) static int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy) { + int64_t start_ts_each, end_ts_each; SaveStateEntry *se; int ret; @@ -1475,6 +1476,8 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy) continue; } } + + start_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME); trace_savevm_section_start(se->idstr, se->section_id); save_section_header(f, se, QEMU_VM_SECTION_END); @@ -1486,6 +1489,9 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy) qemu_file_set_error(f, ret); return -1; } + end_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + trace_vmstate_downtime_save("iterable", se->idstr, se->instance_id, + end_ts_each - start_ts_each); } return 0; @@ -1496,6 +1502,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, bool inactivate_disks) { MigrationState *ms = migrate_get_current(); + int64_t start_ts_each, end_ts_each; JSONWriter *vmdesc = ms->vmdesc; int vmdesc_len; SaveStateEntry *se; @@ -1507,11 +1514,17 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, continue; } + start_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + ret = vmstate_save(f, se, vmdesc); if (ret) { qemu_file_set_error(f, ret); return ret; } + + end_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + trace_vmstate_downtime_save("non-iterable", se->idstr, se->instance_id, + end_ts_each - start_ts_each); } if (inactivate_disks) { @@ -2506,9 +2519,12 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) } static int -qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) +qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis, + uint8_t type) { + bool trace_downtime = (type == QEMU_VM_SECTION_FULL); uint32_t instance_id, version_id, section_id; + int64_t start_ts, end_ts; SaveStateEntry *se; char idstr[256]; int ret; @@ -2557,12 +2573,23 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) return -EINVAL; } + if (trace_downtime) { + start_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + } + ret = vmstate_load(f, se); if (ret < 0) { error_report("error while loading state for instance 0x%"PRIx32" of" " device '%s'", instance_id, idstr); return ret; } + + if (trace_downtime) { + end_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + trace_vmstate_downtime_load("non-iterable", se->idstr, + se->instance_id, end_ts - start_ts); + } + if (!check_section_footer(f, se)) { return -EINVAL; } @@ -2571,8 +2598,11 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) } static int -qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) +qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis, + uint8_t type) { + bool trace_downtime = (type == QEMU_VM_SECTION_END); + int64_t start_ts, end_ts; uint32_t section_id; SaveStateEntry *se; int ret; @@ -2597,12 +2627,23 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) return -EINVAL; } + if (trace_downtime) { + start_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + } + ret = vmstate_load(f, se); if (ret < 0) { error_report("error while loading state section id %d(%s)", section_id, se->idstr); return ret; } + + if (trace_downtime) { + end_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME); + trace_vmstate_downtime_load("iterable", se->idstr, + se->instance_id, end_ts - start_ts); + } + if (!check_section_footer(f, se)) { return -EINVAL; } @@ -2791,14 +2832,14 @@ retry: switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret = qemu_loadvm_section_start_full(f, mis); + ret = qemu_loadvm_section_start_full(f, mis, section_type); if (ret < 0) { goto out; } break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: - ret = qemu_loadvm_section_part_end(f, mis); + ret = qemu_loadvm_section_part_end(f, mis, section_type); if (ret < 0) { goto out; } diff --git a/migration/trace-events b/migration/trace-events index fa9486dffe..5820add1f3 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -48,6 +48,8 @@ savevm_state_cleanup(void) "" savevm_state_complete_precopy(void) "" vmstate_save(const char *idstr, const char *vmsd_name) "%s, %s" vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s" +vmstate_downtime_save(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64 +vmstate_downtime_load(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64 postcopy_pause_incoming(void) "" postcopy_pause_incoming_continued(void) "" postcopy_page_req_sync(void *host_addr) "sync page req %p" From patchwork Thu Oct 26 19:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1855959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OJxoro74; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SGZtq412hz23jV for ; Fri, 27 Oct 2023 06:02:58 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qw5cO-0004mh-Nr; Thu, 26 Oct 2023 15:02:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw5cN-0004mY-Io for qemu-devel@nongnu.org; Thu, 26 Oct 2023 15:02:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qw5cL-0000gt-MA for qemu-devel@nongnu.org; Thu, 26 Oct 2023 15:02:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698346924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vFL1F7ghi7vCyEKRRGn2YTu0nWfrog5RK84AmBwWchE=; b=OJxoro74aXNYvCtMlEDXEKYOHDaz4wtWSROjZY7CWmlD6wOjCCXf5HGJHwHAfbG43U+UzV bgTaJaibiqvEhr5NWT5Cy59NUuUUDnmZGlzdcZ+0ZQuhYFi7He+gTuRqPbvulGe8u6lHwp AS9zNg4r7Ae5Il4H/TZjrcoUABKeJZI= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-119-5AQYCzSJMX6GT-ZQ9eY9xg-1; Thu, 26 Oct 2023 15:02:03 -0400 X-MC-Unique: 5AQYCzSJMX6GT-ZQ9eY9xg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-65623d0075aso3841496d6.0 for ; Thu, 26 Oct 2023 12:02:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698346922; x=1698951722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vFL1F7ghi7vCyEKRRGn2YTu0nWfrog5RK84AmBwWchE=; b=A0YM/U55LZmReRZgkaBqRKcHNv30AhgoGpsP7fuBYMIfMBjSyrXTbDGZWPkUgsj2EB /ra9cT2aZGPftMKEkf4/vEx3J7brlcNn9m6B64z9e95U1vnqP5n9XmJjI5sq/zSxf0lw bV2X2U9QbigSpPBedOY18XK+ibvzx7rprZiLVmHj7kzWup4W562xja/YUAV4aIkxPeSI YGhgf5LC3W5s1dMdEZEHU2osZmZe0dqdTgozQcYtJ0vh/BmZRFX7o7Cswdv/mJTTFVlW Q7Fy41mmfyqABVwMv9Lw9UmAHdT/+S/UNXMcI2dLh9kiB+nnP4yLxcHBMfHi1A0pTuud oUig== X-Gm-Message-State: AOJu0Yz1vpc2Xq/vLZbukCKdIOfC6AxBvdnu7i3vkKej6DFA3cw7my21 NaTTeTkugCyVLtj2sZzaD+RH/7jCHClLI+oDi98Tqub+EDPhAL6L5428muwGFBnYT73BYgyNWeR 90beYRESsY3U039f//CxG0Du5C9/wvrUNofbZZTiQxv4vvR0tEEJZz9jMBqnep0ur0NfvYwhp X-Received: by 2002:a05:6214:5346:b0:66d:4994:b79a with SMTP id kv6-20020a056214534600b0066d4994b79amr488308qvb.5.1698346922131; Thu, 26 Oct 2023 12:02:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhX/kZ1LDxh7gXGJ9/wnBuNyvFyZUrbpYDOe0GVFXvT1FrMLK9Uuf8PevcIS/xsotm7drC5A== X-Received: by 2002:a05:6214:5346:b0:66d:4994:b79a with SMTP id kv6-20020a056214534600b0066d4994b79amr488248qvb.5.1698346921100; Thu, 26 Oct 2023 12:02:01 -0700 (PDT) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id t11-20020a0cf98b000000b006655cc8f872sm16257qvn.99.2023.10.26.12.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 12:02:00 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, quintela@redhat.com, joao.m.martins@oracle.com Subject: [PATCH 4/3] migration: Add tracepoints for downtime checkpoints Date: Thu, 26 Oct 2023 15:01:59 -0400 Message-ID: <20231026190159.608025-1-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231026155337.596281-1-peterx@redhat.com> References: <20231026155337.596281-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add tracepoints for major downtime checkpoints on both src and dst. They share the same tracepoint with a string showing its stage. On src, we have these checkpoints added: - downtime-start: right before vm stops on src - vm-stopped: after vm is fully stopped - iterable-saved: after all iterables saved (END sections) - non-iterable-saved: after all non-iterable saved (FULL sections) - downtime-stop: migration fully completed On dst, we have these checkpoints added: - precopy-loadvm-completes: after loadvm all done for precopy - precopy-bh-*: record BH steps to resume VM for precopy - postcopy-bh-*: record BH steps to resume VM for postcopy On dst side, we don't have a good way to trace total time consumed by iterable or non-iterable for now. We can mark it by 1st time receiving a FULL / END section, but rather than that let's just rely on the other tracepoints added for vmstates to back up the information. Until this patch, one can enable "vmstate_downtime*" and it'll enable all tracepoints for downtime measurements. Since the downtime timestamp tracepoints will cover postcopy too, drop loadvm_postcopy_handle_run_bh() tracepoint alongside, because they service the same purpose, but that only for postcopy. We then have unified prefix for all downtime relevant tracepoints. Signed-off-by: Peter Xu --- migration/migration.c | 16 +++++++++++++++- migration/savevm.c | 14 +++++++++----- migration/trace-events | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 9013c1b500..f1f1d2ae2b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -103,6 +103,7 @@ static int close_return_path_on_source(MigrationState *s); static void migration_downtime_start(MigrationState *s) { + trace_vmstate_downtime_timestamp("downtime-start"); s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); } @@ -117,6 +118,8 @@ static void migration_downtime_end(MigrationState *s) if (!s->downtime) { s->downtime = now - s->downtime_start; } + + trace_vmstate_downtime_timestamp("downtime-end"); } static bool migration_needs_multiple_sockets(void) @@ -151,7 +154,11 @@ static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp) int migration_stop_vm(RunState state) { - return vm_stop_force_state(state); + int ret = vm_stop_force_state(state); + + trace_vmstate_downtime_timestamp("vm-stopped"); + + return ret; } void migration_object_init(void) @@ -500,6 +507,8 @@ static void process_incoming_migration_bh(void *opaque) Error *local_err = NULL; MigrationIncomingState *mis = opaque; + trace_vmstate_downtime_timestamp("precopy-bh-enter"); + /* If capability late_block_activate is set: * Only fire up the block code now if we're going to restart the * VM, else 'cont' will do it. @@ -525,6 +534,8 @@ static void process_incoming_migration_bh(void *opaque) */ qemu_announce_self(&mis->announce_timer, migrate_announce_params()); + trace_vmstate_downtime_timestamp("precopy-bh-announced"); + multifd_load_shutdown(); dirty_bitmap_mig_before_vm_start(); @@ -542,6 +553,7 @@ static void process_incoming_migration_bh(void *opaque) } else { runstate_set(global_state_get_runstate()); } + trace_vmstate_downtime_timestamp("precopy-bh-vm-started"); /* * This must happen after any state changes since as soon as an external * observer sees this event they might start to prod at the VM assuming @@ -576,6 +588,8 @@ process_incoming_migration_co(void *opaque) ret = qemu_loadvm_state(mis->from_src_file); mis->loadvm_co = NULL; + trace_vmstate_downtime_timestamp("precopy-loadvm-completed"); + ps = postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); if (ps != POSTCOPY_INCOMING_NONE) { diff --git a/migration/savevm.c b/migration/savevm.c index cd6d6ba493..49cbbd151c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1494,6 +1494,8 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy) end_ts_each - start_ts_each); } + trace_vmstate_downtime_timestamp("iterable-saved"); + return 0; } @@ -1560,6 +1562,8 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, json_writer_free(vmdesc); ms->vmdesc = NULL; + trace_vmstate_downtime_timestamp("non-iterable-saved"); + return 0; } @@ -2102,18 +2106,18 @@ static void loadvm_postcopy_handle_run_bh(void *opaque) Error *local_err = NULL; MigrationIncomingState *mis = opaque; - trace_loadvm_postcopy_handle_run_bh("enter"); + trace_vmstate_downtime_timestamp("postcopy-bh-enter"); /* TODO we should move all of this lot into postcopy_ram.c or a shared code * in migration.c */ cpu_synchronize_all_post_init(); - trace_loadvm_postcopy_handle_run_bh("after cpu sync"); + trace_vmstate_downtime_timestamp("postcopy-bh-cpu-synced"); qemu_announce_self(&mis->announce_timer, migrate_announce_params()); - trace_loadvm_postcopy_handle_run_bh("after announce"); + trace_vmstate_downtime_timestamp("postcopy-bh-announced"); /* Make sure all file formats throw away their mutable metadata. * If we get an error here, just don't restart the VM yet. */ @@ -2124,7 +2128,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaque) autostart = false; } - trace_loadvm_postcopy_handle_run_bh("after invalidate cache"); + trace_vmstate_downtime_timestamp("postcopy-bh-cache-invalidated"); dirty_bitmap_mig_before_vm_start(); @@ -2138,7 +2142,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaque) qemu_bh_delete(mis->bh); - trace_loadvm_postcopy_handle_run_bh("return"); + trace_vmstate_downtime_timestamp("postcopy-bh-vm-started"); } /* After all discards we can start running and asking for pages */ diff --git a/migration/trace-events b/migration/trace-events index 5820add1f3..aebdd939b7 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -17,7 +17,6 @@ loadvm_handle_recv_bitmap(char *s) "%s" loadvm_postcopy_handle_advise(void) "" loadvm_postcopy_handle_listen(const char *str) "%s" loadvm_postcopy_handle_run(void) "" -loadvm_postcopy_handle_run_bh(const char *str) "%s" loadvm_postcopy_handle_resume(void) "" loadvm_postcopy_ram_handle_discard(void) "" loadvm_postcopy_ram_handle_discard_end(void) "" @@ -50,6 +49,7 @@ vmstate_save(const char *idstr, const char *vmsd_name) "%s, %s" vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s" vmstate_downtime_save(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64 vmstate_downtime_load(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64 +vmstate_downtime_timestamp(const char *checkpoint) "%s" postcopy_pause_incoming(void) "" postcopy_pause_incoming_continued(void) "" postcopy_page_req_sync(void *host_addr) "sync page req %p"