From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334201; cv=none; d=zohomail.com; s=zohoarc; b=ZVhaKLepx/1Qq0DkTKV89RB/upj+GGmqxye/WR4dfoG9sfD08nQy1SeAA99nwagJ1C4WZh28e7tP4kVT7KF9tD0xYJq4H5rh6Iqm2abEGtZ14R02HNvjzeUfkWUZLdCHQd1Zj8c6KH/SoSs6Z9gtX13IcTVCDnNAjPiP2sud6Vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6o32OnKQySspYCv1i0uC98rIrrhiIlUItNYIUCo5zFI=; b=mze9AMc2paAjwkjXmwnDqA86PyHdfKDawhK52fxzWkw2jK/U9OyleKgFGTAvhSBlJkah3X+LXVj4T/XkeiAbY0vXscjoqSChIC5t8j4y9pbMqX9h2nkUCACCPIfPBIik7Ii18wVUoscScxeApomj5ogfCUqS6C11ZupZblLcekg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334201045934.9005541111104; Mon, 24 Apr 2023 04:03:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxH-0006N4-77; Mon, 24 Apr 2023 07:01:59 -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 1pqtxF-0006MC-KQ for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -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 1pqtxD-00005g-7c for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-xCWa3yqgOkWkNRRDakSJHw-1; Mon, 24 Apr 2023 07:01:45 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 586798F52CE; Mon, 24 Apr 2023 11:01:22 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C84A492C3A; Mon, 24 Apr 2023 11:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6o32OnKQySspYCv1i0uC98rIrrhiIlUItNYIUCo5zFI=; b=D5u/ETgsv8+OG+PL3OnbxwUjPlu5wiImY7dY1mKPuh1/8H1Jx8f5VfaDBtikGPjRrAr9Le j9vBVBBuhin42/1Z0Jx/4uqn/e/Ot8QaTkIP1Vx+QBPBlRnSQDTOLxMGOIjmPFzwSDyKDy dtRxNEo1d5Jfb6MUIfHSoTlYPfknY+g= X-MC-Unique: xCWa3yqgOkWkNRRDakSJHw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , =?UTF-8?q?=E6=9D=8E=E7=9A=86=E4=BF=8A?= Subject: [PULL 01/17] migration: remove extra whitespace character for code style Date: Mon, 24 Apr 2023 13:01:03 +0200 Message-Id: <20230424110119.68520-2-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334201674100001 From: =E6=9D=8E=E7=9A=86=E4=BF=8A Fix code style. Signed-off-by: =E6=9D=8E=E7=9A=86=E4=BF=8A 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 79d881f735..0e68099bf9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3293,7 +3293,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) =20 migration_ops =3D g_malloc0(sizeof(MigrationOps)); migration_ops->ram_save_target_page =3D ram_save_target_page_legacy; - ret =3D multifd_send_sync_main(f); + ret =3D multifd_send_sync_main(f); if (ret < 0) { return ret; } --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334201; cv=none; d=zohomail.com; s=zohoarc; b=gyxvHOhxwfmVFDX947V5LF3wAgHkaAyZG3kyWJe7yJm/X7/+8JUZIXZpDnrz+Vb4SzGTisF6n/e9Fr8fJC5RP24zj4JRMh74HSbIuUnl7jY0prUH8gSjuMu4ES5880IwkafgCnN61RqEM5pXY8N8AZaPrJf5oQ/83WW5YRQvv+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334201; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VirGQ9KNoqS+QrqmjH+r2cCMH2niifD5RoldGCmIoDI=; b=fD12JuNb1k2qRM7FIAmLftC45P9h/t29ou9jApMNoePJ9UFTyySysWygPy91O+Ds+yzZqd82RhEwS4J2F+lIsIYTXYxGTNg+FOEf1gJoOmJRBo/CgCFqBQSH2BtZ8wxxulP7uhZAbb43TwUwUDkrd1Hqt+W6iATSdmz6dC9ry+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334201501472.7298734201448; Mon, 24 Apr 2023 04:03:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxC-0006Ks-3i; Mon, 24 Apr 2023 07:01:54 -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 1pqtx9-0006KH-4d for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:51 -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 1pqtx6-0008WD-M7 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:50 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-6jYYhZ_TNbqd1mszxbvt9Q-1; Mon, 24 Apr 2023 07:01:47 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 973A52807D74 for ; Mon, 24 Apr 2023 11:01:23 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97153492C14; Mon, 24 Apr 2023 11:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334108; 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=VirGQ9KNoqS+QrqmjH+r2cCMH2niifD5RoldGCmIoDI=; b=fZEGv1nHltqtWw3qgNpnjFN2Gfu1KncdbRbtKhti0yVGLCpiGi83RboZ7S6Cy5hazwdevN 5WLfH/S7HYl5VNNi14UFhisGKjjhpyDnXkb0shBeSpFgGG9nd/62f2IoVkSGXH4jBy5U7d blUzht7yaF1t4UygglzNyUusDJac5PM= X-MC-Unique: 6jYYhZ_TNbqd1mszxbvt9Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 02/17] migration: Merge ram_counters and ram_atomic_counters Date: Mon, 24 Apr 2023 13:01:04 +0200 Message-Id: <20230424110119.68520-3-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334203702100007 Content-Type: text/plain; charset="utf-8" Using MgrationStats as type for ram_counters mean that we didn't have to re-declare each value in another struct. The need of atomic counters have make us to create MigrationAtomicStats for this atomic counters. Create RAMStats type which is a merge of MigrationStats and MigrationAtomicStats removing unused members. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- Fix typos found by David Edmondson --- migration/migration.c | 8 ++++---- migration/multifd.c | 4 ++-- migration/ram.c | 39 ++++++++++++++++----------------------- migration/ram.h | 28 +++++++++++++++------------- 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index bda4789193..10483f3cab 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1140,12 +1140,12 @@ static void populate_ram_info(MigrationInfo *info, = MigrationState *s) size_t page_size =3D qemu_target_page_size(); =20 info->ram =3D g_malloc0(sizeof(*info->ram)); - info->ram->transferred =3D stat64_get(&ram_atomic_counters.transferred= ); + info->ram->transferred =3D stat64_get(&ram_counters.transferred); info->ram->total =3D ram_bytes_total(); - info->ram->duplicate =3D stat64_get(&ram_atomic_counters.duplicate); + info->ram->duplicate =3D stat64_get(&ram_counters.duplicate); /* legacy value. It is not used anymore */ info->ram->skipped =3D 0; - info->ram->normal =3D stat64_get(&ram_atomic_counters.normal); + info->ram->normal =3D stat64_get(&ram_counters.normal); info->ram->normal_bytes =3D info->ram->normal * page_size; info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D ram_counters.dirty_sync_count; @@ -1157,7 +1157,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->pages_per_second =3D s->pages_per_second; info->ram->precopy_bytes =3D ram_counters.precopy_bytes; info->ram->downtime_bytes =3D ram_counters.downtime_bytes; - info->ram->postcopy_bytes =3D stat64_get(&ram_atomic_counters.postcopy= _bytes); + info->ram->postcopy_bytes =3D stat64_get(&ram_counters.postcopy_bytes); =20 if (migrate_use_xbzrle()) { info->xbzrle_cache =3D g_malloc0(sizeof(*info->xbzrle_cache)); diff --git a/migration/multifd.c b/migration/multifd.c index cbc0dfe39b..01fab01a92 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -433,7 +433,7 @@ static int multifd_send_pages(QEMUFile *f) transferred =3D ((uint64_t) pages->num) * p->page_size + p->packet_len; qemu_file_acct_rate_limit(f, transferred); ram_counters.multifd_bytes +=3D transferred; - stat64_add(&ram_atomic_counters.transferred, transferred); + stat64_add(&ram_counters.transferred, transferred); qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); =20 @@ -628,7 +628,7 @@ int multifd_send_sync_main(QEMUFile *f) p->pending_job++; qemu_file_acct_rate_limit(f, p->packet_len); ram_counters.multifd_bytes +=3D p->packet_len; - stat64_add(&ram_atomic_counters.transferred, p->packet_len); + stat64_add(&ram_counters.transferred, p->packet_len); qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); } diff --git a/migration/ram.c b/migration/ram.c index 0e68099bf9..71320ed27a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -458,25 +458,18 @@ uint64_t ram_bytes_remaining(void) 0; } =20 -/* - * NOTE: not all stats in ram_counters are used in reality. See comments - * for struct MigrationAtomicStats. The ultimate result of ram migration - * counters will be a merged version with both ram_counters and the atomic - * fields in ram_atomic_counters. - */ -MigrationStats ram_counters; -MigrationAtomicStats ram_atomic_counters; +RAMStats ram_counters; =20 void ram_transferred_add(uint64_t bytes) { if (runstate_is_running()) { ram_counters.precopy_bytes +=3D bytes; } else if (migration_in_postcopy()) { - stat64_add(&ram_atomic_counters.postcopy_bytes, bytes); + stat64_add(&ram_counters.postcopy_bytes, bytes); } else { ram_counters.downtime_bytes +=3D bytes; } - stat64_add(&ram_atomic_counters.transferred, bytes); + stat64_add(&ram_counters.transferred, bytes); } =20 void dirty_sync_missed_zero_copy(void) @@ -756,7 +749,7 @@ void mig_throttle_counter_reset(void) =20 rs->time_last_bitmap_sync =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); rs->num_dirty_pages_period =3D 0; - rs->bytes_xfer_prev =3D stat64_get(&ram_atomic_counters.transferred); + rs->bytes_xfer_prev =3D stat64_get(&ram_counters.transferred); } =20 /** @@ -1130,8 +1123,8 @@ uint64_t ram_pagesize_summary(void) =20 uint64_t ram_get_total_transferred_pages(void) { - return stat64_get(&ram_atomic_counters.normal) + - stat64_get(&ram_atomic_counters.duplicate) + + return stat64_get(&ram_counters.normal) + + stat64_get(&ram_counters.duplicate) + compression_counters.pages + xbzrle_counters.pages; } =20 @@ -1192,7 +1185,7 @@ static void migration_trigger_throttle(RAMState *rs) MigrationState *s =3D migrate_get_current(); uint64_t threshold =3D s->parameters.throttle_trigger_threshold; uint64_t bytes_xfer_period =3D - stat64_get(&ram_atomic_counters.transferred) - rs->bytes_xfer_prev; + stat64_get(&ram_counters.transferred) - rs->bytes_xfer_prev; uint64_t bytes_dirty_period =3D rs->num_dirty_pages_period * TARGET_PA= GE_SIZE; uint64_t bytes_dirty_threshold =3D bytes_xfer_period * threshold / 100; =20 @@ -1255,7 +1248,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 stat64_get(&ram_atomic_counters.transferre= d); + rs->bytes_xfer_prev =3D stat64_get(&ram_counters.transferred); } if (migrate_use_events()) { qapi_event_send_migration_pass(ram_counters.dirty_sync_count); @@ -1331,7 +1324,7 @@ static int save_zero_page(PageSearchStatus *pss, QEMU= File *f, RAMBlock *block, int len =3D save_zero_page_to_file(pss, f, block, offset); =20 if (len) { - stat64_add(&ram_atomic_counters.duplicate, 1); + stat64_add(&ram_counters.duplicate, 1); ram_transferred_add(len); return 1; } @@ -1368,9 +1361,9 @@ static bool control_save_page(PageSearchStatus *pss, = RAMBlock *block, } =20 if (bytes_xmit > 0) { - stat64_add(&ram_atomic_counters.normal, 1); + stat64_add(&ram_counters.normal, 1); } else if (bytes_xmit =3D=3D 0) { - stat64_add(&ram_atomic_counters.duplicate, 1); + stat64_add(&ram_counters.duplicate, 1); } =20 return true; @@ -1402,7 +1395,7 @@ static int save_normal_page(PageSearchStatus *pss, RA= MBlock *block, qemu_put_buffer(file, buf, TARGET_PAGE_SIZE); } ram_transferred_add(TARGET_PAGE_SIZE); - stat64_add(&ram_atomic_counters.normal, 1); + stat64_add(&ram_counters.normal, 1); return 1; } =20 @@ -1458,7 +1451,7 @@ static int ram_save_multifd_page(QEMUFile *file, RAMB= lock *block, if (multifd_queue_page(file, block, offset) < 0) { return -1; } - stat64_add(&ram_atomic_counters.normal, 1); + stat64_add(&ram_counters.normal, 1); =20 return 1; } @@ -1497,7 +1490,7 @@ update_compress_thread_counts(const CompressParam *pa= ram, int bytes_xmit) ram_transferred_add(bytes_xmit); =20 if (param->zero_page) { - stat64_add(&ram_atomic_counters.duplicate, 1); + stat64_add(&ram_counters.duplicate, 1); return; } =20 @@ -2632,9 +2625,9 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) uint64_t pages =3D size / TARGET_PAGE_SIZE; =20 if (zero) { - stat64_add(&ram_atomic_counters.duplicate, pages); + stat64_add(&ram_counters.duplicate, pages); } else { - stat64_add(&ram_atomic_counters.normal, pages); + stat64_add(&ram_counters.normal, pages); ram_transferred_add(size); qemu_file_credit_transfer(f, size); } diff --git a/migration/ram.h b/migration/ram.h index 81cbb0947c..7c026b5242 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -35,25 +35,27 @@ #include "qemu/stats64.h" =20 /* - * These are the migration statistic counters that need to be updated using - * atomic ops (can be accessed by more than one thread). Here since we - * cannot modify MigrationStats directly to use Stat64 as it was defined in - * the QAPI scheme, we define an internal structure to hold them, and we - * propagate the real values when QMP queries happen. - * - * IOW, the corresponding fields within ram_counters on these specific - * fields will be always zero and not being used at all; they're just - * placeholders to make it QAPI-compatible. + * These are the ram migration statistic counters. It is loosely + * based on MigrationStats. We change to Stat64 any counter that + * needs to be updated using atomic ops (can be accessed by more than + * one thread). */ typedef struct { - Stat64 transferred; + int64_t dirty_pages_rate; + int64_t dirty_sync_count; + uint64_t dirty_sync_missed_zero_copy; + uint64_t downtime_bytes; Stat64 duplicate; + uint64_t multifd_bytes; Stat64 normal; Stat64 postcopy_bytes; -} MigrationAtomicStats; + int64_t postcopy_requests; + uint64_t precopy_bytes; + int64_t remaining; + Stat64 transferred; +} RAMStats; =20 -extern MigrationAtomicStats ram_atomic_counters; -extern MigrationStats ram_counters; +extern RAMStats ram_counters; extern XBZRLECacheStats xbzrle_counters; extern CompressionStats compression_counters; =20 --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334120; cv=none; d=zohomail.com; s=zohoarc; b=GSxS18rJ4bzxEE7hG3CzVBrr4SGJyy9uAoyfqBMv1AFUUjm/RzalU8ENDC//SuNQ5m20pAcPRLPm1bwd8XbtaYJKgO9zDOb2wSK8injPCwNgwz+jhVOrM/3CgQjCylujaje3ozs+tHkV8N3NUF1l0rXbx+dk3ZXBzaTLeozqegQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334120; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eTO429KLqwUbEQU+ZtqrLHI39e9KpeLfEvHvRX65iNQ=; b=S9up4AessVotKqPVf5HfUnvy0lXGHBlU1Mg9EI74OtABYqoFYKm9Bxfy2JJ20ERIpbShPZbu7sAsx0DPh7TJNLMxUTWNrleG8HmMa8sm9ton8qZHTZXzFtqKP16UVcR87QLaoIUXCZ2Rcmgw7eiJSqzG1Tp5XXLjTqo005NCAMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334120526248.22783251427597; Mon, 24 Apr 2023 04:02:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtwy-0006If-DC; Mon, 24 Apr 2023 07:01:40 -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 1pqtwp-0006EU-PF for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:33 -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 1pqtwo-0008LE-3A for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:31 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-595--kixc75jP864xd13vm2LJw-1; Mon, 24 Apr 2023 07:01:26 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D86101C06904; Mon, 24 Apr 2023 11:01:24 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5E50492C14; Mon, 24 Apr 2023 11:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334087; 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=eTO429KLqwUbEQU+ZtqrLHI39e9KpeLfEvHvRX65iNQ=; b=ZtlpeszAr+zt1ZcyIISODIkeWOftUiS84hJ4sr3jTI/MiRXbbvtS3dgAH2Fksqyvmb8rUL TGITU/8cZVUQI/+2jeZpGxRTAtcymyyuXJe6ERx7/i697l/l5nYGC681Vbfia+x20WZ6tp q9UDir6uzxwXB6h5RYXsWivJCSbyMTI= X-MC-Unique: -kixc75jP864xd13vm2LJw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , David Edmondson Subject: [PULL 03/17] migration: Update atomic stats out of the mutex Date: Mon, 24 Apr 2023 13:01:05 +0200 Message-Id: <20230424110119.68520-4-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334121000100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: David Edmondson Reviewed-by: Peter Xu Signed-off-by: Juan Quintela --- migration/multifd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 01fab01a92..6ef3a27938 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -433,8 +433,8 @@ static int multifd_send_pages(QEMUFile *f) transferred =3D ((uint64_t) pages->num) * p->page_size + p->packet_len; qemu_file_acct_rate_limit(f, transferred); ram_counters.multifd_bytes +=3D transferred; + qemu_mutex_unlock(&p->mutex); stat64_add(&ram_counters.transferred, transferred); - qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); =20 return 1; @@ -628,8 +628,8 @@ int multifd_send_sync_main(QEMUFile *f) p->pending_job++; qemu_file_acct_rate_limit(f, p->packet_len); ram_counters.multifd_bytes +=3D p->packet_len; + qemu_mutex_unlock(&p->mutex); stat64_add(&ram_counters.transferred, p->packet_len); - qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); } for (i =3D 0; i < migrate_multifd_channels(); i++) { --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334174; cv=none; d=zohomail.com; s=zohoarc; b=HpxqqTjhIDaAB7MuwBt9APXxmXt8B7anN7IPAVSZjiP2UkfpXyDzP2+F9Z3ZMipeQuj4RGfZ+K3Be9+2quQAxKu9mieb9dVz0RWbIzTHndWB8HscBePYUVIylkljiDtRELlJUXHYwDiyJxycl3O2rJk7PjO4x9NiiSCqf/Yr6AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334174; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PIZiNP4HVa8w9fFOyLZGSLJknz7pMkuwv3sznNSWh58=; b=C3H52wrQiWplLLKUmj8TMsnZ5bmjbCwKryFI+WOFDm5fFlMBkGATFh1q4YryjkQClp935wwvpEc9atiwnpO380AROKlzu5CSScmESeFeuKm2reyo/b3aEvhd4zoo6CREPUVdDDZl+XDPQkFHfzmpCIZ4xque4TR5Y+p1eZs3FMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168233417470713.785688765571763; Mon, 24 Apr 2023 04:02:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxN-0006WV-Bo; Mon, 24 Apr 2023 07:02:05 -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 1pqtxF-0006MU-Uv for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -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 1pqtxD-00005m-Bl for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-l-U2-_5pM_yzvis5iNRBOA-1; Mon, 24 Apr 2023 07:01:51 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 245002812546; Mon, 24 Apr 2023 11:01:26 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 219EB492C13; Mon, 24 Apr 2023 11:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334114; 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=PIZiNP4HVa8w9fFOyLZGSLJknz7pMkuwv3sznNSWh58=; b=cvJc3Hg3gCwG4gNoL80kwVnUPGsa8NOMnwcF6jZXwxrzh+/rGZFjYitBu0HOnePEnWNrbl 5FoiLbSmpfIJh116yuhK8c+ldtlSshGwqGUfOwNgXtRWGL4kjO3wku7ghkUnf964+qIGsd xdV5VAy0XSLX6R+g+40Q4AkyLc86dp4= X-MC-Unique: l-U2-_5pM_yzvis5iNRBOA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , David Edmondson Subject: [PULL 04/17] migration: Make multifd_bytes atomic Date: Mon, 24 Apr 2023 13:01:06 +0200 Message-Id: <20230424110119.68520-5-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334175069100001 Content-Type: text/plain; charset="utf-8" In the spirit of: commit 394d323bc3451e4d07f13341cb8817fac8dfbadd Author: Peter Xu Date: Tue Oct 11 17:55:51 2022 -0400 migration: Use atomic ops properly for page accountings Reviewed-by: David Edmondson Reviewed-by: Peter Xu Signed-off-by: Juan Quintela --- migration/migration.c | 4 ++-- migration/multifd.c | 4 ++-- migration/ram.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 10483f3cab..c3debe71f6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1153,7 +1153,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) ram_counters.dirty_sync_missed_zero_copy; info->ram->postcopy_requests =3D ram_counters.postcopy_requests; info->ram->page_size =3D page_size; - info->ram->multifd_bytes =3D ram_counters.multifd_bytes; + info->ram->multifd_bytes =3D stat64_get(&ram_counters.multifd_bytes); info->ram->pages_per_second =3D s->pages_per_second; info->ram->precopy_bytes =3D ram_counters.precopy_bytes; info->ram->downtime_bytes =3D ram_counters.downtime_bytes; @@ -3778,7 +3778,7 @@ static MigThrError migration_detect_error(MigrationSt= ate *s) static uint64_t migration_total_bytes(MigrationState *s) { return qemu_file_total_transferred(s->to_dst_file) + - ram_counters.multifd_bytes; + stat64_get(&ram_counters.multifd_bytes); } =20 static void migration_calculate_complete(MigrationState *s) diff --git a/migration/multifd.c b/migration/multifd.c index 6ef3a27938..1c992abf53 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -432,9 +432,9 @@ static int multifd_send_pages(QEMUFile *f) p->pages =3D pages; transferred =3D ((uint64_t) pages->num) * p->page_size + p->packet_len; qemu_file_acct_rate_limit(f, transferred); - ram_counters.multifd_bytes +=3D transferred; qemu_mutex_unlock(&p->mutex); stat64_add(&ram_counters.transferred, transferred); + stat64_add(&ram_counters.multifd_bytes, transferred); qemu_sem_post(&p->sem); =20 return 1; @@ -627,9 +627,9 @@ int multifd_send_sync_main(QEMUFile *f) p->flags |=3D MULTIFD_FLAG_SYNC; p->pending_job++; qemu_file_acct_rate_limit(f, p->packet_len); - ram_counters.multifd_bytes +=3D p->packet_len; qemu_mutex_unlock(&p->mutex); stat64_add(&ram_counters.transferred, p->packet_len); + stat64_add(&ram_counters.multifd_bytes, p->packet_len); qemu_sem_post(&p->sem); } for (i =3D 0; i < migrate_multifd_channels(); i++) { diff --git a/migration/ram.h b/migration/ram.h index 7c026b5242..ed70391317 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -46,7 +46,7 @@ typedef struct { uint64_t dirty_sync_missed_zero_copy; uint64_t downtime_bytes; Stat64 duplicate; - uint64_t multifd_bytes; + Stat64 multifd_bytes; Stat64 normal; Stat64 postcopy_bytes; int64_t postcopy_requests; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334310; cv=none; d=zohomail.com; s=zohoarc; b=eetQ5wEeBWcRQi5v0onu6llbbcog5Jhxy414xXqzTZs7yLzTKeBAS6E5R/hmI5vS1b8iMN0sFGbLNub6yt6kJLq4VV9lP8jzc2rSqvrHbD8obfhXtYWbEH6sH/2fHsMDlP3AtrAm3fdczODAU96hZhmHfShf67ejYioQetlMbAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334310; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gL0ykmtNo3ZxZwrOtOTDv2wucS3IWqU34lcBpNTCV7s=; b=UQ2zSF2j+Gaq+2zrEtheuexW0/VdcZ+zwtnPAxNaZ1Pymmm5MuM3cZT4tufVdEON/hYAwFQamQV5R8QY/bqHS2v360h4iiPZvQQDvNoYvwZYnAcrD+4QxzntE8u/MsBnnmoT3iRz4L5oAqiZmgGS6BbBNoa81WWNdUrIe9r2Syo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334309990879.2603845078861; Mon, 24 Apr 2023 04:05:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxG-0006MZ-50; Mon, 24 Apr 2023 07:01: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 1pqtxC-0006LA-4s for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:54 -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 1pqtx9-00004r-Dy for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:53 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-j9vGfmqqOw6J11-gzcGuHg-1; Mon, 24 Apr 2023 07:01:48 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F9FB3847C47 for ; Mon, 24 Apr 2023 11:01:27 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 625D4492C13; Mon, 24 Apr 2023 11:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334110; 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=gL0ykmtNo3ZxZwrOtOTDv2wucS3IWqU34lcBpNTCV7s=; b=Kh++DeX49JjSLl1xVdz2z7xd1dV6qq3SFigCRvxeGGVR+itdYvhPwBCpwb9Q5qlxsVY+r1 M1ZQWPMUuEc0JexQ1lIWclC1sEgrU4yTPInDYFLDft6VrIj38ksSzK6eb6MdGLy4ZUgwij VMWwSXbJwEZdGxbjjqvNFfgCUdduZQI= X-MC-Unique: j9vGfmqqOw6J11-gzcGuHg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 05/17] migration: Make dirty_sync_missed_zero_copy atomic Date: Mon, 24 Apr 2023 13:01:07 +0200 Message-Id: <20230424110119.68520-6-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334310243100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 2 +- migration/multifd.c | 2 +- migration/ram.c | 5 ----- migration/ram.h | 4 +--- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c3debe71f6..66e5197b77 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1150,7 +1150,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D ram_counters.dirty_sync_count; info->ram->dirty_sync_missed_zero_copy =3D - ram_counters.dirty_sync_missed_zero_copy; + stat64_get(&ram_counters.dirty_sync_missed_zero_copy); info->ram->postcopy_requests =3D ram_counters.postcopy_requests; info->ram->page_size =3D page_size; info->ram->multifd_bytes =3D stat64_get(&ram_counters.multifd_bytes); diff --git a/migration/multifd.c b/migration/multifd.c index 1c992abf53..903df2117b 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -576,7 +576,7 @@ static int multifd_zero_copy_flush(QIOChannel *c) return -1; } if (ret =3D=3D 1) { - dirty_sync_missed_zero_copy(); + stat64_add(&ram_counters.dirty_sync_missed_zero_copy, 1); } =20 return ret; diff --git a/migration/ram.c b/migration/ram.c index 71320ed27a..93e0a48af4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -472,11 +472,6 @@ void ram_transferred_add(uint64_t bytes) stat64_add(&ram_counters.transferred, bytes); } =20 -void dirty_sync_missed_zero_copy(void) -{ - ram_counters.dirty_sync_missed_zero_copy++; -} - struct MigrationOps { int (*ram_save_target_page)(RAMState *rs, PageSearchStatus *pss); }; diff --git a/migration/ram.h b/migration/ram.h index ed70391317..2170c55e67 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -43,7 +43,7 @@ typedef struct { int64_t dirty_pages_rate; int64_t dirty_sync_count; - uint64_t dirty_sync_missed_zero_copy; + Stat64 dirty_sync_missed_zero_copy; uint64_t downtime_bytes; Stat64 duplicate; Stat64 multifd_bytes; @@ -114,6 +114,4 @@ void ram_write_tracking_prepare(void); int ram_write_tracking_start(void); void ram_write_tracking_stop(void); =20 -void dirty_sync_missed_zero_copy(void); - #endif --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334127; cv=none; d=zohomail.com; s=zohoarc; b=lJDgS3xnFCEdaDsqGAveCRe8cV9WDMoTpFVVC1UaudrvhuG7LtucZJTB0sg4fmGrY2Fz3VvE/ZXK/3AO1KqLQosSt1MRTaK/iZPeIhiuBJqAjZSoZJ+2c+I/fFCwR9bhnF2sdeK1ZBG6bESaD2Q4sA/4ebtPPt63fcpttOjk6WM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334127; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cT9l59Y4GSadWstb/Go/h8p2mUI+dL2YBlwxDVEEcfI=; b=IRfyBh9Rohpq6cZkp+pIrlv3BAgs10gfWcXoJyGIzkUeFDpBb/EKhcGSXNr0yNwMPf2bBW0yPHSCFy3wcIcW+bLB1gBUOi/gc3csAMokS/zKBZNq1OtpYE/81AJ7oRjy9aFkRMwZnIn0xVcrBXgOAY4ngQZBpvTnRqB+M2NbiXs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16823341272141011.6728426648386; Mon, 24 Apr 2023 04:02:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtx9-0006KX-Rr; Mon, 24 Apr 2023 07:01:51 -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 1pqtx7-0006Jz-W0 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:50 -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 1pqtx6-0008W3-3d for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:49 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-315-ouT5qPMCOsGRDi2m1xLz9A-1; Mon, 24 Apr 2023 07:01:45 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C2D9183F564 for ; Mon, 24 Apr 2023 11:01:28 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DCC5492C13; Mon, 24 Apr 2023 11:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334107; 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=cT9l59Y4GSadWstb/Go/h8p2mUI+dL2YBlwxDVEEcfI=; b=Mfqy1ooQhFMDYPCQM34MnAnXc4Xopch0hXHpAAZCnBIb+lqlvX+vGcZrlrf8yei1EM2wZ4 hI5LcQAGWAxc//jmTdZ2qRzE8XnMMAHm2s22fFd5WsNYqO/wUXZGoEPTqhs7QPBhFxdVEI hMZ7kcbPEkASdJT4du8pCJ0wQ4kGXJs= X-MC-Unique: ouT5qPMCOsGRDi2m1xLz9A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 06/17] migration: Make precopy_bytes atomic Date: Mon, 24 Apr 2023 13:01:08 +0200 Message-Id: <20230424110119.68520-7-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334128455100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 2 +- migration/ram.c | 2 +- migration/ram.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 66e5197b77..cbd6f6f235 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1155,7 +1155,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->page_size =3D page_size; info->ram->multifd_bytes =3D stat64_get(&ram_counters.multifd_bytes); info->ram->pages_per_second =3D s->pages_per_second; - info->ram->precopy_bytes =3D ram_counters.precopy_bytes; + info->ram->precopy_bytes =3D stat64_get(&ram_counters.precopy_bytes); info->ram->downtime_bytes =3D ram_counters.downtime_bytes; info->ram->postcopy_bytes =3D stat64_get(&ram_counters.postcopy_bytes); =20 diff --git a/migration/ram.c b/migration/ram.c index 93e0a48af4..0b4693215e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -463,7 +463,7 @@ RAMStats ram_counters; void ram_transferred_add(uint64_t bytes) { if (runstate_is_running()) { - ram_counters.precopy_bytes +=3D bytes; + stat64_add(&ram_counters.precopy_bytes, bytes); } else if (migration_in_postcopy()) { stat64_add(&ram_counters.postcopy_bytes, bytes); } else { diff --git a/migration/ram.h b/migration/ram.h index 2170c55e67..a766b895fa 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -50,7 +50,7 @@ typedef struct { Stat64 normal; Stat64 postcopy_bytes; int64_t postcopy_requests; - uint64_t precopy_bytes; + Stat64 precopy_bytes; int64_t remaining; Stat64 transferred; } RAMStats; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334305; cv=none; d=zohomail.com; s=zohoarc; b=IYDUSOydI8r84LZbE52akZmGOEIlF/HcxA3xySJiMkWf3NWj0I+NFm6cZNsj6mIUWKTg0ypEWxCkp3IpjA7N4SseHFsAXriDIh/GiDneV8VlW2IpV4rJF35l5pWqh8WBaB9ZnGWkbReKAZuO4slpM0VtM2igc4UPiVEIRKzhFdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334305; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b8nktDbQGhyng8rEyggk/WN70WXELiml8F6XRH+ytTY=; b=kGrQ8lz06siNfr0ceenzecj1yWs4fXPqtJ8dkc0AJmfbQQB+XwQbKyV9qp0E3/qkOJe0ehxi1ke5cFN2H+zcaxDsiCsaSPHQ/qUIdrgjfZ6FYb7VGSH1exCGrwF9DB1xJ9C9TkYvs2OipyjZy+e5vOkLs2CXRXPVH4jGNvwsRjM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334305260284.3130145537772; Mon, 24 Apr 2023 04:05:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxE-0006Lm-Nd; Mon, 24 Apr 2023 07:01: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 1pqtx9-0006KM-DW for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:51 -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 1pqtx7-0008W8-E3 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:51 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-H1Oshjl0Mj6DvKCPAKoBKw-1; Mon, 24 Apr 2023 07:01:46 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 794711C0E539 for ; Mon, 24 Apr 2023 11:01:29 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A329492C13; Mon, 24 Apr 2023 11:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334107; 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=b8nktDbQGhyng8rEyggk/WN70WXELiml8F6XRH+ytTY=; b=gBPXbwZGYgCunzXQWSnqNT9kgC47svGE+9S125Q1/yEW1WdmY4CyB8iinf/yVLHfm6iUJi jKSFuMfXcuIdaQSCQslFFJxAj5nWauxfBbW5+JFdRSeWxbRwgSy4rMeDZh+CVHBAmBRhct 4BtHtewy+Iw7av2MZUxNBFemtfgwzAw= X-MC-Unique: H1Oshjl0Mj6DvKCPAKoBKw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 07/17] migration: Make downtime_bytes atomic Date: Mon, 24 Apr 2023 13:01:09 +0200 Message-Id: <20230424110119.68520-8-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334306762100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 2 +- migration/ram.c | 2 +- migration/ram.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index cbd6f6f235..4ca2173d85 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1156,7 +1156,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->multifd_bytes =3D stat64_get(&ram_counters.multifd_bytes); info->ram->pages_per_second =3D s->pages_per_second; info->ram->precopy_bytes =3D stat64_get(&ram_counters.precopy_bytes); - info->ram->downtime_bytes =3D ram_counters.downtime_bytes; + info->ram->downtime_bytes =3D stat64_get(&ram_counters.downtime_bytes); info->ram->postcopy_bytes =3D stat64_get(&ram_counters.postcopy_bytes); =20 if (migrate_use_xbzrle()) { diff --git a/migration/ram.c b/migration/ram.c index 0b4693215e..b1722b6071 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -467,7 +467,7 @@ void ram_transferred_add(uint64_t bytes) } else if (migration_in_postcopy()) { stat64_add(&ram_counters.postcopy_bytes, bytes); } else { - ram_counters.downtime_bytes +=3D bytes; + stat64_add(&ram_counters.downtime_bytes, bytes); } stat64_add(&ram_counters.transferred, bytes); } diff --git a/migration/ram.h b/migration/ram.h index a766b895fa..bb52632424 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -44,7 +44,7 @@ typedef struct { int64_t dirty_pages_rate; int64_t dirty_sync_count; Stat64 dirty_sync_missed_zero_copy; - uint64_t downtime_bytes; + Stat64 downtime_bytes; Stat64 duplicate; Stat64 multifd_bytes; Stat64 normal; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334302; cv=none; d=zohomail.com; s=zohoarc; b=cNjMJrZFHPYH+UafInzVArJwF9GHF6cXqD2R7rB0QCsBVwYPooAuiY7/EH8XG65+lgMS1GAwDssMGPSfPJGEjQAiAa6u8lnuv1O3ImKicuzDQSUDtSFYIBfKsaVoCOEqAvpmrqUVr7/St0WCjPMzdK6zZJkg5sBd2m5ZvUZJhtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334302; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GjcTrAksCxmbiPlNvbjUXnHDSgjwXW8MBUgNQYev5Eg=; b=aZwCCNRkC6AKyhwHbUIgBEW3enoixfVk9Hmmfsd/AcUKm8s6XO6noHaLAdmxBKedGejjXbuNJGoudzNBa8Fv4emAvq4snsGuCaSPxMaov3i0tyvJfIqdkTt9Q8/JheoywQ2x9MVwvr88eYfDFiJekb0vkzsf8GOZx9NLWpwsYlU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334302406787.0700011645331; Mon, 24 Apr 2023 04:05:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxI-0006Qg-7f; Mon, 24 Apr 2023 07:02:00 -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 1pqtxF-0006MF-QB for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -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 1pqtxC-00005a-SS for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-8yzzXYw6PJWR2JcC__l7zA-1; Mon, 24 Apr 2023 07:01:52 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 998EC108C492 for ; Mon, 24 Apr 2023 11:01:30 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id B85C1492C14; Mon, 24 Apr 2023 11:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334114; 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=GjcTrAksCxmbiPlNvbjUXnHDSgjwXW8MBUgNQYev5Eg=; b=FjiX5LHdF2/y+bsOPB2wvEsqSeAvihTnnGzY9Ov28d1nX/wDv2PcqSGvhlAz0aUJhNRx57 z6fre4fdkutCcm/0+ZkICRH2LT66olqw1ilDrSU+QIM56KyuvyCNQ9b3weKFeYKTwghBsU 6PPKfOZ0LgIZDfL7h5s7hIebQX2uTiE= X-MC-Unique: 8yzzXYw6PJWR2JcC__l7zA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 08/17] migration: Make dirty_sync_count atomic Date: Mon, 24 Apr 2023 13:01:10 +0200 Message-Id: <20230424110119.68520-9-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334304291100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 3 ++- migration/ram.c | 13 +++++++------ migration/ram.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 4ca2173d85..97c227aa85 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1148,7 +1148,8 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->normal =3D stat64_get(&ram_counters.normal); info->ram->normal_bytes =3D info->ram->normal * page_size; info->ram->mbps =3D s->mbps; - info->ram->dirty_sync_count =3D ram_counters.dirty_sync_count; + info->ram->dirty_sync_count =3D + stat64_get(&ram_counters.dirty_sync_count); info->ram->dirty_sync_missed_zero_copy =3D stat64_get(&ram_counters.dirty_sync_missed_zero_copy); info->ram->postcopy_requests =3D ram_counters.postcopy_requests; diff --git a/migration/ram.c b/migration/ram.c index b1722b6071..3c13136559 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -764,7 +764,7 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_ad= dr_t current_addr) /* We don't care if this fails to allocate a new cache page * as long as it updated an old one */ cache_insert(XBZRLE.cache, current_addr, XBZRLE.zero_target_page, - ram_counters.dirty_sync_count); + stat64_get(&ram_counters.dirty_sync_count)); } =20 #define ENCODING_FLAG_XBZRLE 0x1 @@ -790,13 +790,13 @@ static int save_xbzrle_page(RAMState *rs, PageSearchS= tatus *pss, int encoded_len =3D 0, bytes_xbzrle; uint8_t *prev_cached_page; QEMUFile *file =3D pss->pss_channel; + uint64_t generation =3D stat64_get(&ram_counters.dirty_sync_count); =20 - if (!cache_is_cached(XBZRLE.cache, current_addr, - ram_counters.dirty_sync_count)) { + if (!cache_is_cached(XBZRLE.cache, current_addr, generation)) { xbzrle_counters.cache_miss++; if (!rs->last_stage) { if (cache_insert(XBZRLE.cache, current_addr, *current_data, - ram_counters.dirty_sync_count) =3D=3D -1) { + generation) =3D=3D -1) { return -1; } else { /* update *current_data when the page has been @@ -1209,7 +1209,7 @@ static void migration_bitmap_sync(RAMState *rs) RAMBlock *block; int64_t end_time; =20 - ram_counters.dirty_sync_count++; + stat64_add(&ram_counters.dirty_sync_count, 1); =20 if (!rs->time_last_bitmap_sync) { rs->time_last_bitmap_sync =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E); @@ -1246,7 +1246,8 @@ static void migration_bitmap_sync(RAMState *rs) rs->bytes_xfer_prev =3D stat64_get(&ram_counters.transferred); } if (migrate_use_events()) { - qapi_event_send_migration_pass(ram_counters.dirty_sync_count); + uint64_t generation =3D stat64_get(&ram_counters.dirty_sync_count); + qapi_event_send_migration_pass(generation); } } =20 diff --git a/migration/ram.h b/migration/ram.h index bb52632424..8c0d07c43a 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -42,7 +42,7 @@ */ typedef struct { int64_t dirty_pages_rate; - int64_t dirty_sync_count; + Stat64 dirty_sync_count; Stat64 dirty_sync_missed_zero_copy; Stat64 downtime_bytes; Stat64 duplicate; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334168; cv=none; d=zohomail.com; s=zohoarc; b=BUZhyHLlQMyCXXyc/6kr9bDzP8DDrKF6weBKrwFqWr+rbTYeOtX2yJ1fUIOF6s6gCOjnfofWVZFGpp6eiZk3fPqa69IgzY2Ggyjqp3qCAouxS1mivnQyqHZ+DluHZM8QbFXGCcSzzOeCOmQ4mmFT+ohuqlRSbqR4hbrXvbbEsp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334168; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Onh57vrnmdF/fkaMzeSarm7LYi+lYdgF6rW+lcbE5rM=; b=dEGVg7D7KXxtfvawlKr2RM5daf+C0K5qRQurhYqu3q+eNCJ8XE6lxnN9n6KPmNyxyugOSklzvbpOiwLj02AbuEvB6eadE8Ay1whPp6l90Yem4zTUoGwDQAsrbqdV8L6yVZn8rz0Fq8C5AEt7IZeVAOVngYuhwuQVPArqNU+fPAo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334168672195.52603336057246; Mon, 24 Apr 2023 04:02:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxI-0006R3-PI; Mon, 24 Apr 2023 07:02:00 -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 1pqtxG-0006Ma-0f for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:58 -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 1pqtxE-00006p-FW for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-629-WVaKmXK0ODqLhXtUFXrzNQ-1; Mon, 24 Apr 2023 07:01:54 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B55E7877CD0 for ; Mon, 24 Apr 2023 11:01:31 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4ED2492C13; Mon, 24 Apr 2023 11:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334115; 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=Onh57vrnmdF/fkaMzeSarm7LYi+lYdgF6rW+lcbE5rM=; b=eoU33PkPZ9zeS+dedFeUBd3WtV7Nt5tL9m+bkfnJSgwDYDhqwatFXRYHmv0+ZJb311A3Hx hfci0CVm4xBeuu+GL1hvHxSg0qkcXIX6glvLKK3vGe2zsyf76BVfE5HbdLmpH0m/rYwl4R t08Zyzu8+80cTTGpv1cQbSCRBdPE3EY= X-MC-Unique: WVaKmXK0ODqLhXtUFXrzNQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 09/17] migration: Make postcopy_requests atomic Date: Mon, 24 Apr 2023 13:01:11 +0200 Message-Id: <20230424110119.68520-10-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334170784100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 3 ++- migration/ram.c | 2 +- migration/ram.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 97c227aa85..09b37a6603 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1152,7 +1152,8 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) stat64_get(&ram_counters.dirty_sync_count); info->ram->dirty_sync_missed_zero_copy =3D stat64_get(&ram_counters.dirty_sync_missed_zero_copy); - info->ram->postcopy_requests =3D ram_counters.postcopy_requests; + info->ram->postcopy_requests =3D + stat64_get(&ram_counters.postcopy_requests); info->ram->page_size =3D page_size; info->ram->multifd_bytes =3D stat64_get(&ram_counters.multifd_bytes); info->ram->pages_per_second =3D s->pages_per_second; diff --git a/migration/ram.c b/migration/ram.c index 3c13136559..fe69ecaef4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2169,7 +2169,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) RAMBlock *ramblock; RAMState *rs =3D ram_state; =20 - ram_counters.postcopy_requests++; + stat64_add(&ram_counters.postcopy_requests, 1); RCU_READ_LOCK_GUARD(); =20 if (!rbname) { diff --git a/migration/ram.h b/migration/ram.h index 8c0d07c43a..afa68521d7 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -49,7 +49,7 @@ typedef struct { Stat64 multifd_bytes; Stat64 normal; Stat64 postcopy_bytes; - int64_t postcopy_requests; + Stat64 postcopy_requests; Stat64 precopy_bytes; int64_t remaining; Stat64 transferred; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334364; cv=none; d=zohomail.com; s=zohoarc; b=G7QvnqIJ3BCMjXsbUBxwJkbsaM2FLkUyYUuGqxm475NzQ6yJnfl7e4/WQ/lLkSXgKYpawpOlOBUURqcYfvk5toxJL8wyJpAcFLpuYuu78E1qhkv6YF58hDmUpCfBgsKyMk83Ht+sQzgZCGfcqcm08jSftL6wHtv28LOrFmQgO0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334364; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oAzy9si/jMA37GnbGAXLG/QcG7k1YO+xVO8d5UViEw0=; b=VKwd0ppm6F93ykFIvKK+xxP1G0gT4p3Mg/8jrUI8PGYMLsZVWCvz3pZlfrOTW5emEN2hXbtnLlfy7irAURhNpJM1ELhhrAdp8mTEJMP5eYYSZG+gACzVizWqaFmtR2dL3Pl//aWCp127dqAyqkj/TWTmIpZBMv5qo/WrXeihuZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16823343643151017.1086171808903; Mon, 24 Apr 2023 04:06:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxM-0006W0-9h; Mon, 24 Apr 2023 07:02:04 -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 1pqtxI-0006RA-Bw for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:00 -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 1pqtxG-00007f-Jk for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:00 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-454-WqEYC8d3PBiQ6Dw9MYVs8w-1; Mon, 24 Apr 2023 07:01:56 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D14B58F61FA for ; Mon, 24 Apr 2023 11:01:32 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2CCD492C13; Mon, 24 Apr 2023 11:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334117; 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=oAzy9si/jMA37GnbGAXLG/QcG7k1YO+xVO8d5UViEw0=; b=gDdPNjd42++LOaKNdCWyIH2LwdFAgdHAGtkq7U24WTqRyBRtstJrk0bWTuim6jRCDB+2uY V37JudE6uXm546g3B80c7pWL+/V0A4CUHRxbIaetxE/kO2mjRN75hfOYAh5ltHRYCI1he0 6bhkqut2hz+t8yeeQ6UUPAYEsCRBGfc= X-MC-Unique: WqEYC8d3PBiQ6Dw9MYVs8w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 10/17] migration: Rename duplicate to zero_pages Date: Mon, 24 Apr 2023 13:01:12 +0200 Message-Id: <20230424110119.68520-11-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334364571100001 Content-Type: text/plain; charset="utf-8" Rest of counters that refer to pages has a _pages suffix. And historically, this showed the number of pages composed of the same character, here comes the name "duplicated". But since years ago, it refers to the number of zero_pages. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 2 +- migration/ram.c | 10 +++++----- migration/ram.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 09b37a6603..c8b360a2df 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1142,7 +1142,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram =3D g_malloc0(sizeof(*info->ram)); info->ram->transferred =3D stat64_get(&ram_counters.transferred); info->ram->total =3D ram_bytes_total(); - info->ram->duplicate =3D stat64_get(&ram_counters.duplicate); + info->ram->duplicate =3D stat64_get(&ram_counters.zero_pages); /* legacy value. It is not used anymore */ info->ram->skipped =3D 0; info->ram->normal =3D stat64_get(&ram_counters.normal); diff --git a/migration/ram.c b/migration/ram.c index fe69ecaef4..19d345a030 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1119,7 +1119,7 @@ uint64_t ram_pagesize_summary(void) uint64_t ram_get_total_transferred_pages(void) { return stat64_get(&ram_counters.normal) + - stat64_get(&ram_counters.duplicate) + + stat64_get(&ram_counters.zero_pages) + compression_counters.pages + xbzrle_counters.pages; } =20 @@ -1320,7 +1320,7 @@ static int save_zero_page(PageSearchStatus *pss, QEMU= File *f, RAMBlock *block, int len =3D save_zero_page_to_file(pss, f, block, offset); =20 if (len) { - stat64_add(&ram_counters.duplicate, 1); + stat64_add(&ram_counters.zero_pages, 1); ram_transferred_add(len); return 1; } @@ -1359,7 +1359,7 @@ static bool control_save_page(PageSearchStatus *pss, = RAMBlock *block, if (bytes_xmit > 0) { stat64_add(&ram_counters.normal, 1); } else if (bytes_xmit =3D=3D 0) { - stat64_add(&ram_counters.duplicate, 1); + stat64_add(&ram_counters.zero_pages, 1); } =20 return true; @@ -1486,7 +1486,7 @@ update_compress_thread_counts(const CompressParam *pa= ram, int bytes_xmit) ram_transferred_add(bytes_xmit); =20 if (param->zero_page) { - stat64_add(&ram_counters.duplicate, 1); + stat64_add(&ram_counters.zero_pages, 1); return; } =20 @@ -2621,7 +2621,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) uint64_t pages =3D size / TARGET_PAGE_SIZE; =20 if (zero) { - stat64_add(&ram_counters.duplicate, pages); + stat64_add(&ram_counters.zero_pages, pages); } else { stat64_add(&ram_counters.normal, pages); ram_transferred_add(size); diff --git a/migration/ram.h b/migration/ram.h index afa68521d7..55258334fe 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -45,7 +45,7 @@ typedef struct { Stat64 dirty_sync_count; Stat64 dirty_sync_missed_zero_copy; Stat64 downtime_bytes; - Stat64 duplicate; + Stat64 zero_pages; Stat64 multifd_bytes; Stat64 normal; Stat64 postcopy_bytes; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334155; cv=none; d=zohomail.com; s=zohoarc; b=IWnLRPzaHZ3xAsEFuE4IF1MmGPFeqOIiUKoLXSr5zltCSpDNXkGUSzXuj3BSmw5vFKDwrUDoUpFQAVjeDo6xCd3grdkpp64L0kfrX7cgUYEh9bLJtEKjw/xnJaQvrzRVQF87tQ6CL9THO73Da0LJh3lkm/eKNh1hezEISblBdlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334155; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o/b6BXR2tvRkk6dsejhwCcSg7kr31TPLDejWAL+HL1k=; b=SgpyIuw0aBtTThyucpo/z8Q8PEk6n0kJbFXiEirnbPgLcML09txKogXgwa74wTQYwh2UvbnR7tY8q0odqHk6vp/RPj4iWlY6FjrnVe+XyYIMvliQLFu2PehvJmBzi2ie4PbzA/6Wi2JmusYvJ2jXdzGpNdzD1gvvff3mqCGoNb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334155592804.2722606463373; Mon, 24 Apr 2023 04:02:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxN-0006WW-CK; Mon, 24 Apr 2023 07:02:05 -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 1pqtxH-0006ND-CS for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:59 -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 1pqtxF-000078-Oo for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:59 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-BkkMz3BpMYq56UhtzrptvQ-1; Mon, 24 Apr 2023 07:01:54 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05082886067 for ; Mon, 24 Apr 2023 11:01:34 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BF1E492C13; Mon, 24 Apr 2023 11:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334117; 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=o/b6BXR2tvRkk6dsejhwCcSg7kr31TPLDejWAL+HL1k=; b=ZiMigPvU7cBTlmWiBoGPxdlS5MYvc6UQrCKRjWMRXteFkZtowD4l82RWdyXkuWZ1VCvnIu 6P8MSRFP5uru6ECM/QvT1r74xWd2hA+bRvhtJxqa6F1jSw8ryDD2DJtMwBZe4yr9EcfCHI pWmKexgrOMcIx+Je+sERN46XfWnE9JU= X-MC-Unique: BkkMz3BpMYq56UhtzrptvQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 11/17] migration: Rename normal to normal_pages Date: Mon, 24 Apr 2023 13:01:13 +0200 Message-Id: <20230424110119.68520-12-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334156641100001 Content-Type: text/plain; charset="utf-8" Rest of counters that refer to pages has a _pages suffix. And historically, this showed the number of full pages transferred. The name "normal" refered to the fact that they were sent without any optimization (compression, xbzrle, zero_page, ...). Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 2 +- migration/ram.c | 10 +++++----- migration/ram.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c8b360a2df..5543a7f896 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1145,7 +1145,7 @@ static void populate_ram_info(MigrationInfo *info, Mi= grationState *s) info->ram->duplicate =3D stat64_get(&ram_counters.zero_pages); /* legacy value. It is not used anymore */ info->ram->skipped =3D 0; - info->ram->normal =3D stat64_get(&ram_counters.normal); + info->ram->normal =3D stat64_get(&ram_counters.normal_pages); info->ram->normal_bytes =3D info->ram->normal * page_size; info->ram->mbps =3D s->mbps; info->ram->dirty_sync_count =3D diff --git a/migration/ram.c b/migration/ram.c index 19d345a030..229714045a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1118,7 +1118,7 @@ uint64_t ram_pagesize_summary(void) =20 uint64_t ram_get_total_transferred_pages(void) { - return stat64_get(&ram_counters.normal) + + return stat64_get(&ram_counters.normal_pages) + stat64_get(&ram_counters.zero_pages) + compression_counters.pages + xbzrle_counters.pages; } @@ -1357,7 +1357,7 @@ static bool control_save_page(PageSearchStatus *pss, = RAMBlock *block, } =20 if (bytes_xmit > 0) { - stat64_add(&ram_counters.normal, 1); + stat64_add(&ram_counters.normal_pages, 1); } else if (bytes_xmit =3D=3D 0) { stat64_add(&ram_counters.zero_pages, 1); } @@ -1391,7 +1391,7 @@ static int save_normal_page(PageSearchStatus *pss, RA= MBlock *block, qemu_put_buffer(file, buf, TARGET_PAGE_SIZE); } ram_transferred_add(TARGET_PAGE_SIZE); - stat64_add(&ram_counters.normal, 1); + stat64_add(&ram_counters.normal_pages, 1); return 1; } =20 @@ -1447,7 +1447,7 @@ static int ram_save_multifd_page(QEMUFile *file, RAMB= lock *block, if (multifd_queue_page(file, block, offset) < 0) { return -1; } - stat64_add(&ram_counters.normal, 1); + stat64_add(&ram_counters.normal_pages, 1); =20 return 1; } @@ -2623,7 +2623,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) if (zero) { stat64_add(&ram_counters.zero_pages, pages); } else { - stat64_add(&ram_counters.normal, pages); + stat64_add(&ram_counters.normal_pages, pages); ram_transferred_add(size); qemu_file_credit_transfer(f, size); } diff --git a/migration/ram.h b/migration/ram.h index 55258334fe..a6e0d70226 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -47,7 +47,7 @@ typedef struct { Stat64 downtime_bytes; Stat64 zero_pages; Stat64 multifd_bytes; - Stat64 normal; + Stat64 normal_pages; Stat64 postcopy_bytes; Stat64 postcopy_requests; Stat64 precopy_bytes; --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334377; cv=none; d=zohomail.com; s=zohoarc; b=oA7aS0MTzGS7bVyyt+4ifYSIpXeK/IYsjqWPW+pcU4lntQCuR5yJL0O5UvnxvQwCEP7g+sPOGeqB1fzFWPVY13YicNLt9W0MzJfDiEq3B3dYTmwsWc3VrCek6NETpJcSABT4tz53uYaqcugLX3EiNJEYBmAc2V67u6TmSajXaMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334377; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kDD07bUVfgcxUkWFwK4WDIq54Bd6/eTopsF30v60fTk=; b=a7EIA99gnGiFZ8GuxMTI4gAOVOkU4wJNIpGok1j7096zu0xtmbCDNFrW2gkPQj8xA5JNUYWaEJZ0EZY8BWuKHUTN+up5KggQI2MbOsVBGBAMjGflbGwFbMyLwNNuvnlCsAvfj3WHwBKIb30AQMER7qmDzonDxBHsomk+PSBJZPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334377789509.35513053938155; Mon, 24 Apr 2023 04:06:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxF-0006MD-QQ; Mon, 24 Apr 2023 07:01:57 -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 1pqtxE-0006Ll-H4 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:56 -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 1pqtxC-00005K-8J for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:56 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-j-stzAE2NiOX7pyhPV4OSA-1; Mon, 24 Apr 2023 07:01:52 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E96B3C10141; Mon, 24 Apr 2023 11:01:35 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44238492C13; Mon, 24 Apr 2023 11:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334113; 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=kDD07bUVfgcxUkWFwK4WDIq54Bd6/eTopsF30v60fTk=; b=XidkMLfTKOcQA2djI+ESSungunPtLTesGeKBKGsX2UeTYLxdeKVMQBwZRN/YiGJP1/6fpd NnYe7A2W3drBGypEqUiiZC0xW8w8r9hBV6PveXXbTr58XIcpRo/abvGUioATuEXAxqJi6F Jy9YILsEn3ya8w3nNDQjeFga6T341jc= X-MC-Unique: j-stzAE2NiOX7pyhPV4OSA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Eric Blake , Lukas Straub Subject: [PULL 12/17] migration: Handle block device inactivation failures better Date: Mon, 24 Apr 2023 13:01:14 +0200 Message-Id: <20230424110119.68520-13-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334378713100003 Content-Type: text/plain; charset="utf-8" From: Eric Blake Consider what happens when performing a migration between two host machines connected to an NFS server serving multiple block devices to the guest, when the NFS server becomes unavailable. The migration attempts to inactivate all block devices on the source (a necessary step before the destination can take over); but if the NFS server is non-responsive, the attempt to inactivate can itself fail. When that happens, the destination fails to get the migrated guest (good, because the source wasn't able to flush everything properly): (qemu) qemu-kvm: load of migration failed: Input/output error at which point, our only hope for the guest is for the source to take back control. With the current code base, the host outputs a message, but = then appears to resume: (qemu) qemu-kvm: qemu_savevm_state_complete_precopy_non_iterable: bdrv_in= activate_all() failed (-1) (src qemu)info status VM status: running but a second migration attempt now asserts: (src qemu) qemu-kvm: ../block.c:6738: int bdrv_inactivate_recurse(BlockDr= iverState *): Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed. Whether the guest is recoverable on the source after the first failure is debatable, but what we do not want is to have qemu itself fail due to an assertion. It looks like the problem is as follows: In migration.c:migration_completion(), the source sets 'inactivate' to true (since COLO is not enabled), then tries savevm.c:qemu_savevm_state_complete_precopy() with a request to inactivate block devices. In turn, this calls block.c:bdrv_inactivate_all(), which fails when flushing runs up against the non-responsive NFS server. With savevm failing, we are now left in a state where some, but not all, of the block devices have been inactivated; but migration_completion() then jumps to 'fail' rather than 'fail_invalidate' and skips an attempt to reclaim those those disks by calling bdrv_activate_all(). Even if we do attempt to reclaim disks, we aren't taking note of failure there, either. Thus, we have reached a state where the migration engine has forgotten all state about whether a block device is inactive, because we did not set s->block_inactive in enough places; so migration allows the source to reach vm_start() and resume execution, violating the block layer invariant that the guest CPUs should not be restarted while a device is inactive. Note that the code in migration.c:migrate_fd_cancel() will also try to reactivate all block devices if s->block_inactive was set, but because we failed to set that flag after the first failure, the source assumes it has reclaimed all devices, even though it still has remaining inactivated devices and does not try again. Normally, qmp_cont() will also try to reactivate all disks (or correctly fail if the disks are not reclaimable because NFS is not yet back up), but the auto-resumption of the source after a migration failure does not go through qmp_cont(). And because we have left the block layer in an inconsistent state with devices still inactivated, the later migration attempt is hitting the assertion failure. Since it is important to not resume the source with inactive disks, this patch marks s->block_inactive before attempting inactivation, rather than after succeeding, in order to prevent any vm_start() until it has successfully reactivated all devices. See also https://bugzilla.redhat.com/show_bug.cgi?id=3D2058982 Signed-off-by: Eric Blake Reviewed-by: Juan Quintela Acked-by: Lukas Straub Tested-by: Lukas Straub Signed-off-by: Juan Quintela --- migration/migration.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5543a7f896..298fe16e27 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3446,13 +3446,11 @@ static void migration_completion(MigrationState *s) MIGRATION_STATUS_DEVICE); } if (ret >=3D 0) { + s->block_inactive =3D inactivate; qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, inactivate); } - if (inactivate && ret >=3D 0) { - s->block_inactive =3D true; - } } qemu_mutex_unlock_iothread(); =20 @@ -3524,6 +3522,7 @@ fail_invalidate: bdrv_activate_all(&local_err); if (local_err) { error_report_err(local_err); + s->block_inactive =3D true; } else { s->block_inactive =3D false; } --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334278; cv=none; d=zohomail.com; s=zohoarc; b=RZA7pEW/kJngqAAioGBe4JZln22ycV5J7rSQONDWL6TftonSE6jyy5ARDqx/y271TmkSLNs1W+QM12fyHj3HYN58NAQ6RF+jaPyk26PWF7cFyX2DaD+xR2YSzkoOT8jFnT1eppcsp2VyplfjhXbVzNibKmu865bBoGHn8Szyr1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334278; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ciIcbPI9hOjqUEVUJJbQtIKfDfIvPSrlIPnUOzP0G8A=; b=idtoyrtcGx67Mr0d08CeOt1Mi8LxezTItjgsqt8TOELnCyKZOfjvsslncFMAPFHcqrHic4CmhPXkDPfgbAVXlisERPaVkElffLmCy1M6zanMrywMCIN2nHotNr1PlSTcMq9PZ14XQmoMoSp119TYzRgsAC7LrT1omle2zzjBsEk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334278008881.0102383997723; Mon, 24 Apr 2023 04:04:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxK-0006TO-6k; Mon, 24 Apr 2023 07:02:02 -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 1pqtxI-0006R0-9C for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:00 -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 1pqtxG-00007V-BF for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:01:59 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-AWv-ANPwM66GRJhnxVtN6g-1; Mon, 24 Apr 2023 07:01:56 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 054CB3813F50 for ; Mon, 24 Apr 2023 11:01:37 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDC3B492C13; Mon, 24 Apr 2023 11:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334117; 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=ciIcbPI9hOjqUEVUJJbQtIKfDfIvPSrlIPnUOzP0G8A=; b=DY25rihmMPWUhhnQU7K+sLdoDqsrFKYg3KgZ/Ptv9AvGFQtqDzr16p7kJ1b9+y0bzHUO/g DkE86+EX0z4Q4G4jIfdQL9JBIYSHCKdrYYGe+z6q1bXJf6ASSLJow8zAqq6lzjBaAXg4kt liSpFhtqq+GZN/2ApFVe4tI/088+f1Y= X-MC-Unique: AWv-ANPwM66GRJhnxVtN6g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , David Hildenbrand Subject: [PULL 13/17] util/mmap-alloc: qemu_fd_getfs() Date: Mon, 24 Apr 2023 13:01:15 +0200 Message-Id: <20230424110119.68520-14-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334279987100007 Content-Type: text/plain; charset="utf-8" From: Peter Xu This new helper fetches file system type for a fd. Only Linux is implemented so far. Currently only tmpfs and hugetlbfs are defined, but it can grow as needed. Signed-off-by: Peter Xu Reviewed-by: David Hildenbrand Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/qemu/mmap-alloc.h | 7 +++++++ util/mmap-alloc.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h index 2825e231a7..8344daaa03 100644 --- a/include/qemu/mmap-alloc.h +++ b/include/qemu/mmap-alloc.h @@ -1,8 +1,15 @@ #ifndef QEMU_MMAP_ALLOC_H #define QEMU_MMAP_ALLOC_H =20 +typedef enum { + QEMU_FS_TYPE_UNKNOWN =3D 0, + QEMU_FS_TYPE_TMPFS, + QEMU_FS_TYPE_HUGETLBFS, + QEMU_FS_TYPE_NUM, +} QemuFsType; =20 size_t qemu_fd_getpagesize(int fd); +QemuFsType qemu_fd_getfs(int fd); =20 /** * qemu_ram_mmap: mmap anonymous memory, the specified file or device. diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 5ed7d29183..ed14f9c64d 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -27,8 +27,36 @@ =20 #ifdef CONFIG_LINUX #include +#include #endif =20 +QemuFsType qemu_fd_getfs(int fd) +{ +#ifdef CONFIG_LINUX + struct statfs fs; + int ret; + + if (fd < 0) { + return QEMU_FS_TYPE_UNKNOWN; + } + + do { + ret =3D fstatfs(fd, &fs); + } while (ret !=3D 0 && errno =3D=3D EINTR); + + switch (fs.f_type) { + case TMPFS_MAGIC: + return QEMU_FS_TYPE_TMPFS; + case HUGETLBFS_MAGIC: + return QEMU_FS_TYPE_HUGETLBFS; + default: + return QEMU_FS_TYPE_UNKNOWN; + } +#else + return QEMU_FS_TYPE_UNKNOWN; +#endif +} + size_t qemu_fd_getpagesize(int fd) { #ifdef CONFIG_LINUX --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334155; cv=none; d=zohomail.com; s=zohoarc; b=eBAxz/96Yt0+2N+saek+x7+77nOsLxxFHQeu/2vB1LrNlgGqbBNtuThZ1JU+/pR0l849MKZGAP7UOexTvDgOone4ulqdBm+45yHH4mYr5mE+qt2WyXoG5GMVE2NDym+MXN32uzRLoJxZ0GRIXotDmnTUyCGgldVlb/EdR6u33aU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334155; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YOfyxq/209QEewXqA5moiiz05QRvpHublewrXjjxMBs=; b=gNDfgBpu32K20PTP1ACGSpaqA1iT9l3iiXa5o7OxmPoy2BqOhb82CzMQVZhx1He3yiUX0xUlF/2DHb0NgjmDlT0txKZwaIf8pQT47QnuPguu4o783izUg0Hds1Z4N6+TQUQ+O2HvZGrIUH6AuLD6qdUQSF9qfSsNDb6wvn4DITQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334155721439.478019298851; Mon, 24 Apr 2023 04:02:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxS-0006aX-40; Mon, 24 Apr 2023 07:02:20 -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 1pqtxQ-0006Z7-07 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:08 -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 1pqtxM-00008x-RI for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-JDTgCK0hM4CM9HvLii81lg-1; Mon, 24 Apr 2023 07:01:54 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7ED9988718F for ; Mon, 24 Apr 2023 11:01:38 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43E72492C1B; Mon, 24 Apr 2023 11:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334124; 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=YOfyxq/209QEewXqA5moiiz05QRvpHublewrXjjxMBs=; b=hxznCQ4Vu4su0E8F5MKGMbljjqA1Xf0a3Fr0/IQpA/lSu9LRWJ3/TsRO8ZnB573FyWnw7H EuwPho21hsaF1ghcPj4pjiTFBCX6VJHXMNQZuhdjM2FB54C7bGXYYnGglQi4vuY1vBxFCO FZ0gRnTljYGEGM9T/3vDurYcCgCkNr8= X-MC-Unique: JDTgCK0hM4CM9HvLii81lg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , David Hildenbrand Subject: [PULL 14/17] vl.c: Create late backends before migration object Date: Mon, 24 Apr 2023 13:01:16 +0200 Message-Id: <20230424110119.68520-15-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334156689100002 Content-Type: text/plain; charset="utf-8" From: Peter Xu The migration object may want to check against different types of memory when initialized. Delay the creation to be after late backends. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Reviewed-by: David Hildenbrand Signed-off-by: Juan Quintela --- softmmu/vl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 5cb72a56fc..fb6c221e8e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3583,14 +3583,19 @@ void qemu_init(int argc, char **argv) machine_class->name, machine_class->deprecation_reaso= n); } =20 + /* + * Create backends before creating migration objects, so that it can + * check against compatibilities on the backend memories (e.g. postcopy + * over memory-backend-file objects). + */ + qemu_create_late_backends(); + /* * Note: creates a QOM object, must run only after global and * compat properties have been set up. */ migration_object_init(); =20 - qemu_create_late_backends(); - /* parse features once if machine provides default cpu_type */ current_machine->cpu_type =3D machine_class->default_cpu_type; if (cpu_option) { --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334259; cv=none; d=zohomail.com; s=zohoarc; b=Gm8mPYuRXHO/81ru1npC4WAs4X88VpuzdlTnBMZrSUiBtKL4yzidQKSWCVdQIp/rT6609HDXqBuB0UrXas7PGDzyrhL4CMga0kkU+KkL4KJPHRrc0ExeWTijjh0azYVoCdNoTqMb006OcBfLC6J8HKllTGCeC0+6vrqrvEBF/Ls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334259; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qTpIH6J0Oeu1R8sR8xhP8NxkFo3ADKWp+t7Ys+B7VIs=; b=UVdsTpPVI6e+rdz3Zc5UftFKpA8Bnbc0K0vq7H4TSttTSzqPYL9WescVhGWdn7bcpYAQ+jTPNtakMowAwXsBqMRgnKaeVrELGnmzTGGehUzZDHmm+a3Hbt13oLSWV9LGmAMUDzAjQZnphnnnh5dcYW5/Pl9U5TEr26EoilWD7is= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334259335692.1813126086514; Mon, 24 Apr 2023 04:04:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxO-0006Xk-Ma; Mon, 24 Apr 2023 07:02: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 1pqtxM-0006W2-H1 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02: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 1pqtxK-00008g-QB for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:04 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-258--OwmNNIaM52G5MtnuMf7Yw-1; Mon, 24 Apr 2023 07:02:00 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C334A847723 for ; Mon, 24 Apr 2023 11:01:39 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE3BA492C13; Mon, 24 Apr 2023 11:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334122; 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=qTpIH6J0Oeu1R8sR8xhP8NxkFo3ADKWp+t7Ys+B7VIs=; b=OVjzexrDpv8aXJDbBwIo2UiZGe6GXXszP5r2KVulUzYGZyylERFHm5F1z2XM9P2tSQp+bm zFMJQmHLsoprzDuRoSxbdLXD3zI9hRyGqMFw8JF5fWErqq4Hi6ndLhZ4cjYQiJKQYgaEOs iyPdkl8GR1c5A42oEcEJ/8v5b9LoSFg= X-MC-Unique: -OwmNNIaM52G5MtnuMf7Yw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini Subject: [PULL 15/17] migration/postcopy: Detect file system on dest host Date: Mon, 24 Apr 2023 13:01:17 +0200 Message-Id: <20230424110119.68520-16-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334260004100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Postcopy requires the memory support userfaultfd to work. Right now we check it but it's a bit too late (when switching to postcopy migration). Do that early right at enabling of postcopy. Note that this is still only a best effort because ramblocks can be dynamically created. We can add check in hostmem creations and fail if postcopy enabled, but maybe that's too aggressive. Still, we have chance to fail the most obvious where we know there's an existing unsupported ramblock. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/postcopy-ram.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 7d24dac397..d7b48dd920 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -36,6 +36,7 @@ #include "yank_functions.h" #include "tls.h" #include "qemu/userfaultfd.h" +#include "qemu/mmap-alloc.h" =20 /* Arbitrary limit on size of each discard command, * keeps them around ~200 bytes @@ -336,11 +337,12 @@ static bool ufd_check_and_apply(int ufd, MigrationInc= omingState *mis) =20 /* Callback from postcopy_ram_supported_by_host block iterator. */ -static int test_ramblock_postcopiable(RAMBlock *rb, void *opaque) +static int test_ramblock_postcopiable(RAMBlock *rb) { const char *block_name =3D qemu_ram_get_idstr(rb); ram_addr_t length =3D qemu_ram_get_used_length(rb); size_t pagesize =3D qemu_ram_pagesize(rb); + QemuFsType fs; =20 if (length % pagesize) { error_report("Postcopy requires RAM blocks to be a page size multi= ple," @@ -348,6 +350,15 @@ static int test_ramblock_postcopiable(RAMBlock *rb, vo= id *opaque) "page size of 0x%zx", block_name, length, pagesize); return 1; } + + if (rb->fd >=3D 0) { + fs =3D qemu_fd_getfs(rb->fd); + if (fs !=3D QEMU_FS_TYPE_TMPFS && fs !=3D QEMU_FS_TYPE_HUGETLBFS) { + error_report("Host backend files need to be TMPFS or HUGETLBFS= only"); + return 1; + } + } + return 0; } =20 @@ -366,6 +377,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis) struct uffdio_range range_struct; uint64_t feature_mask; Error *local_err =3D NULL; + RAMBlock *block; =20 if (qemu_target_page_size() > pagesize) { error_report("Target page size bigger than host page size"); @@ -390,9 +402,23 @@ bool postcopy_ram_supported_by_host(MigrationIncomingS= tate *mis) goto out; } =20 - /* We don't support postcopy with shared RAM yet */ - if (foreach_not_ignored_block(test_ramblock_postcopiable, NULL)) { - goto out; + /* + * We don't support postcopy with some type of ramblocks. + * + * NOTE: we explicitly ignored ramblock_is_ignored() instead we checked + * all possible ramblocks. This is because this function can be called + * when creating the migration object, during the phase RAM_MIGRATABLE + * is not even properly set for all the ramblocks. + * + * A side effect of this is we'll also check against RAM_SHARED + * ramblocks even if migrate_ignore_shared() is set (in which case + * we'll never migrate RAM_SHARED at all), but normally this shouldn't + * affect in reality, or we can revisit. + */ + RAMBLOCK_FOREACH(block) { + if (test_ramblock_postcopiable(block)) { + goto out; + } } =20 /* --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334277; cv=none; d=zohomail.com; s=zohoarc; b=Z0T3GkIiTRicE22nPDAu7skuC8i1QN2mIjcomPqNzGMSJOZaD8LuEj81ut4V1+hznyqPTshBY+zhIyEOIYzBKyKbGYZ+tEe8+cunI+fiWxvKHkrIGg84xEiGbVZWW/a3wcAR87KzenG8CM5CMZ1imKxWvl8k2FtXgGMP1NwzOs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334277; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nlw+lO7toXgY0J4vZfg+BUJ/1IXjAn7Kg7ktbnz0ORQ=; b=VDroFmsQQDqkon8NIlXN6y5N+sssanwBpx/jHUR61586ZJvZIBheKLadbykR5xUYNM3+32DJuYqMHLRDoIPFwLs0fvY7DuDnFjzPDUONU0D/5iSW3ULhlnVRHCL0b/boE3yHfXWsDjm7XteROEa+beWY2FnXEd5c6Y8l6Pac/0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334276982554.5227912688315; Mon, 24 Apr 2023 04:04:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxo-00071y-4I; Mon, 24 Apr 2023 07:02:32 -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 1pqtxT-0006at-OX for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:24 -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 1pqtxP-00009U-Ep for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-64-SjU96gvMMfKR1gq-N0ohqA-1; Mon, 24 Apr 2023 07:01:58 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90A5A8533BA; Mon, 24 Apr 2023 11:01:41 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DEC3492C13; Mon, 24 Apr 2023 11:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334126; 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=nlw+lO7toXgY0J4vZfg+BUJ/1IXjAn7Kg7ktbnz0ORQ=; b=afWM9yikZ1Qxdqisfx5Wi/N8RZpa/HxExEaBaZTZC2fLVI8kHZK81RESsL+sBdiqmKf4/Y f/bTsgWGcMZu/F3pJ0MFdggwM3eYbxce12+mpFP4BuKkIVficGyLN7M/PVtt+zPs9N+ddx CPsVsFKzQB3tDCm2QFuHa76mKNO9M8E= X-MC-Unique: SjU96gvMMfKR1gq-N0ohqA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 16/17] migration: rename enabled_capabilities to capabilities Date: Mon, 24 Apr 2023 13:01:18 +0200 Message-Id: <20230424110119.68520-17-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334278734100003 Content-Type: text/plain; charset="utf-8" It is clear from the context what that means, and such a long name with the extra long names of the capabilities make very difficilut to stay inside the 80 columns limit. Signed-off-by: Juan Quintela Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/migration.c | 52 +++++++++++++++++++++---------------------- migration/migration.h | 2 +- migration/rdma.c | 4 ++-- migration/savevm.c | 6 ++--- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 298fe16e27..16d3609527 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -364,8 +364,7 @@ static bool migrate_late_block_activate(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[ - MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE]; + return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE]; } =20 /* @@ -944,7 +943,7 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabi= lities(Error **errp) #endif caps =3D g_malloc0(sizeof(*caps)); caps->capability =3D i; - caps->state =3D s->enabled_capabilities[i]; + caps->state =3D s->capabilities[i]; QAPI_LIST_APPEND(tail, caps); } =20 @@ -1494,13 +1493,13 @@ void qmp_migrate_set_capabilities(MigrationCapabili= tyStatusList *params, return; } =20 - memcpy(cap_list, s->enabled_capabilities, sizeof(cap_list)); + memcpy(cap_list, s->capabilities, sizeof(cap_list)); if (!migrate_caps_check(cap_list, params, errp)) { return; } =20 for (cap =3D params; cap; cap =3D cap->next) { - s->enabled_capabilities[cap->value->capability] =3D cap->value->st= ate; + s->capabilities[cap->value->capability] =3D cap->value->state; } } =20 @@ -2569,7 +2568,7 @@ bool migrate_release_ram(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_RELEASE_RAM]; + return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM]; } =20 bool migrate_postcopy_ram(void) @@ -2578,7 +2577,7 @@ bool migrate_postcopy_ram(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM]; + return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM]; } =20 bool migrate_postcopy(void) @@ -2592,7 +2591,7 @@ bool migrate_auto_converge(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE]; + return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE]; } =20 bool migrate_zero_blocks(void) @@ -2601,7 +2600,7 @@ bool migrate_zero_blocks(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS]; + return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS]; } =20 bool migrate_postcopy_blocktime(void) @@ -2610,7 +2609,7 @@ bool migrate_postcopy_blocktime(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME= ]; + return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME]; } =20 bool migrate_use_compression(void) @@ -2619,7 +2618,7 @@ bool migrate_use_compression(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_COMPRESS]; + return s->capabilities[MIGRATION_CAPABILITY_COMPRESS]; } =20 int migrate_compress_level(void) @@ -2664,7 +2663,7 @@ bool migrate_dirty_bitmaps(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS]; + return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS]; } =20 bool migrate_ignore_shared(void) @@ -2673,7 +2672,7 @@ bool migrate_ignore_shared(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED]; + return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED]; } =20 bool migrate_validate_uuid(void) @@ -2682,7 +2681,7 @@ bool migrate_validate_uuid(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID]; + return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID]; } =20 bool migrate_use_events(void) @@ -2691,7 +2690,7 @@ bool migrate_use_events(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_EVENTS]; + return s->capabilities[MIGRATION_CAPABILITY_EVENTS]; } =20 bool migrate_use_multifd(void) @@ -2700,7 +2699,7 @@ bool migrate_use_multifd(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_MULTIFD]; + return s->capabilities[MIGRATION_CAPABILITY_MULTIFD]; } =20 bool migrate_pause_before_switchover(void) @@ -2709,8 +2708,7 @@ bool migrate_pause_before_switchover(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[ - MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER]; + return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER]; } =20 int migrate_multifd_channels(void) @@ -2757,7 +2755,7 @@ bool migrate_use_zero_copy_send(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND]; + return s->capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND]; } #endif =20 @@ -2776,7 +2774,7 @@ int migrate_use_xbzrle(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_XBZRLE]; + return s->capabilities[MIGRATION_CAPABILITY_XBZRLE]; } =20 uint64_t migrate_xbzrle_cache_size(void) @@ -2803,7 +2801,7 @@ bool migrate_use_block(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK]; + return s->capabilities[MIGRATION_CAPABILITY_BLOCK]; } =20 bool migrate_use_return_path(void) @@ -2812,7 +2810,7 @@ bool migrate_use_return_path(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_RETURN_PATH]; + return s->capabilities[MIGRATION_CAPABILITY_RETURN_PATH]; } =20 bool migrate_use_block_incremental(void) @@ -2830,7 +2828,7 @@ bool migrate_background_snapshot(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHO= T]; + return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]; } =20 bool migrate_postcopy_preempt(void) @@ -2839,7 +2837,7 @@ bool migrate_postcopy_preempt(void) =20 s =3D migrate_get_current(); =20 - return s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]; + return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]; } =20 /* migration thread support */ @@ -3581,7 +3579,7 @@ fail: bool migrate_colo_enabled(void) { MigrationState *s =3D migrate_get_current(); - return s->enabled_capabilities[MIGRATION_CAPABILITY_X_COLO]; + return s->capabilities[MIGRATION_CAPABILITY_X_COLO]; } =20 typedef enum MigThrError { @@ -4444,7 +4442,7 @@ void migration_global_dump(Monitor *mon) } =20 #define DEFINE_PROP_MIG_CAP(name, x) \ - DEFINE_PROP_BOOL(name, MigrationState, enabled_capabilities[x], false) + DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false) =20 static Property migration_properties[] =3D { DEFINE_PROP_BOOL("store-global-state", MigrationState, @@ -4643,7 +4641,7 @@ static bool migration_object_check(MigrationState *ms= , Error **errp) } =20 for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { - if (ms->enabled_capabilities[i]) { + if (ms->capabilities[i]) { QAPI_LIST_PREPEND(head, migrate_cap_add(i, true)); } } diff --git a/migration/migration.h b/migration/migration.h index 310ae8901b..04e0860b4e 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -310,7 +310,7 @@ struct MigrationState { int64_t downtime_start; int64_t downtime; int64_t expected_downtime; - bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; + bool capabilities[MIGRATION_CAPABILITY__MAX]; int64_t setup_time; /* * Whether guest was running when we enter the completion stage. diff --git a/migration/rdma.c b/migration/rdma.c index df646be35e..f35f021963 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4179,7 +4179,7 @@ void rdma_start_outgoing_migration(void *opaque, } =20 ret =3D qemu_rdma_source_init(rdma, - s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], errp); + s->capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], errp); =20 if (ret) { goto err; @@ -4201,7 +4201,7 @@ void rdma_start_outgoing_migration(void *opaque, } =20 ret =3D qemu_rdma_source_init(rdma_return_path, - s->enabled_capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], er= rp); + s->capabilities[MIGRATION_CAPABILITY_RDMA_PIN_ALL], errp); =20 if (ret) { goto return_path_err; diff --git a/migration/savevm.c b/migration/savevm.c index aa54a67fda..589ef926ab 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -253,7 +253,7 @@ static uint32_t get_validatable_capabilities_count(void) uint32_t result =3D 0; int i; for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { - if (should_validate_capability(i) && s->enabled_capabilities[i]) { + if (should_validate_capability(i) && s->capabilities[i]) { result++; } } @@ -275,7 +275,7 @@ static int configuration_pre_save(void *opaque) state->capabilities =3D g_renew(MigrationCapability, state->capabiliti= es, state->caps_count); for (i =3D j =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { - if (should_validate_capability(i) && s->enabled_capabilities[i]) { + if (should_validate_capability(i) && s->capabilities[i]) { state->capabilities[j++] =3D i; } } @@ -325,7 +325,7 @@ static bool configuration_validate_capabilities(SaveSta= te *state) continue; } source_state =3D test_bit(i, source_caps_bm); - target_state =3D s->enabled_capabilities[i]; + target_state =3D s->capabilities[i]; if (source_state !=3D target_state) { error_report("Capability %s is %s, but received capability is = %s", MigrationCapability_str(i), --=20 2.39.2 From nobody Sat May 11 21:30:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682334407; cv=none; d=zohomail.com; s=zohoarc; b=JlMUmu76GAsJ6YotljZwEBVZnI+QEx7BbJ44yaw0DcWH0SDYM+jVfM9q8AvRLXlEhIsFk2844KJEJG5gr/oum91LP5D6MeYUtkvT1WWHBTZnHPNoxfBCHKdjxD7BmcUWixLlCnNW2MaNpItHQi1txsY/loiNDvAgIOa/DVNQ+RU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682334407; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tf4up+wOwivmpo8zXzNYJR/G/cnwh6NxnkPbb7ngPRU=; b=AJrGZlruLqkx40iwkJo4Wem/QnfWhsq6K+4Xr6WpRifSS2sSfZvKo7G3vDkGaj3xZn1frH1DirkrB7nEIX7iH841QsOvGrQjGiJ6Uz7HjhKElk/k+yQtTc6sWWmBOc01mOMvXMBvgbiGDrY7m4ouburHpK6ChAVesBm33dCmxQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682334407719485.5847338066583; Mon, 24 Apr 2023 04:06:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqtxn-0006wt-5n; Mon, 24 Apr 2023 07:02:31 -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 1pqtxR-0006aC-3N for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:09 -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 1pqtxP-00009N-16 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 07:02:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-iugtuvyEMLiqItQ7AP24wA-1; Mon, 24 Apr 2023 07:02:03 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D4B088D122; Mon, 24 Apr 2023 11:01:43 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF084492B00; Mon, 24 Apr 2023 11:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682334126; 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=tf4up+wOwivmpo8zXzNYJR/G/cnwh6NxnkPbb7ngPRU=; b=C/96JSWIx/a3gzQNtyW/pgVcnksTMfbAvxj9IrZAjcVbQ1XyTmWxyGTNsmrJTFYnuLSmcz DKiJfPvnGRlTLBwe20OzHQ0XwiExdRaMlPIHyfIAQXKsgtY7kcWAQGZOuLQXYsyDStQEwn 4S70ylc/7AFjKr/HY654CVmXdoYxUCg= X-MC-Unique: iugtuvyEMLiqItQ7AP24wA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 17/17] migration: Pass migrate_caps_check() the old and new caps Date: Mon, 24 Apr 2023 13:01:19 +0200 Message-Id: <20230424110119.68520-18-quintela@redhat.com> In-Reply-To: <20230424110119.68520-1-quintela@redhat.com> References: <20230424110119.68520-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.172, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682334408824100003 Content-Type: text/plain; charset="utf-8" We used to pass the old capabilities array and the new capabilities as a list. Signed-off-by: Juan Quintela Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/migration.c | 80 +++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 16d3609527..d91fe9fd86 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1299,30 +1299,20 @@ WriteTrackingSupport migrate_query_write_tracking(v= oid) } =20 /** - * @migration_caps_check - check capability validity + * @migration_caps_check - check capability compatibility * - * @cap_list: old capability list, array of bool - * @params: new capabilities to be applied soon + * @old_caps: old capability list + * @new_caps: new capability list * @errp: set *errp if the check failed, with reason * * Returns true if check passed, otherwise false. */ -static bool migrate_caps_check(bool *cap_list, - MigrationCapabilityStatusList *params, - Error **errp) +static bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **err= p) { - MigrationCapabilityStatusList *cap; - bool old_postcopy_cap; MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - old_postcopy_cap =3D cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]; - - for (cap =3D params; cap; cap =3D cap->next) { - cap_list[cap->value->capability] =3D cap->value->state; - } - #ifndef CONFIG_LIVE_BLOCK_MIGRATION - if (cap_list[MIGRATION_CAPABILITY_BLOCK]) { + if (new_caps[MIGRATION_CAPABILITY_BLOCK]) { error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i)= " "block migration"); error_append_hint(errp, "Use drive_mirror+NBD instead.\n"); @@ -1331,7 +1321,7 @@ static bool migrate_caps_check(bool *cap_list, #endif =20 #ifndef CONFIG_REPLICATION - if (cap_list[MIGRATION_CAPABILITY_X_COLO]) { + if (new_caps[MIGRATION_CAPABILITY_X_COLO]) { error_setg(errp, "QEMU compiled without replication module" " can't enable COLO"); error_append_hint(errp, "Please enable replication before COLO.\n"= ); @@ -1339,12 +1329,13 @@ static bool migrate_caps_check(bool *cap_list, } #endif =20 - if (cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { + if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { /* This check is reasonably expensive, so only when it's being * set the first time, also it's only the destination that needs * special support. */ - if (!old_postcopy_cap && runstate_check(RUN_STATE_INMIGRATE) && + if (!old_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM] && + runstate_check(RUN_STATE_INMIGRATE) && !postcopy_ram_supported_by_host(mis)) { /* postcopy_ram_supported_by_host will have emitted a more * detailed message @@ -1353,13 +1344,13 @@ static bool migrate_caps_check(bool *cap_list, return false; } =20 - if (cap_list[MIGRATION_CAPABILITY_X_IGNORE_SHARED]) { + if (new_caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED]) { error_setg(errp, "Postcopy is not compatible with ignore-share= d"); return false; } } =20 - if (cap_list[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]) { + if (new_caps[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT]) { WriteTrackingSupport wt_support; int idx; /* @@ -1383,7 +1374,7 @@ static bool migrate_caps_check(bool *cap_list, */ for (idx =3D 0; idx < check_caps_background_snapshot.size; idx++) { int incomp_cap =3D check_caps_background_snapshot.caps[idx]; - if (cap_list[incomp_cap]) { + if (new_caps[incomp_cap]) { error_setg(errp, "Background-snapshot is not compatible with %s", MigrationCapability_str(incomp_cap)); @@ -1393,10 +1384,10 @@ static bool migrate_caps_check(bool *cap_list, } =20 #ifdef CONFIG_LINUX - if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] && - (!cap_list[MIGRATION_CAPABILITY_MULTIFD] || - cap_list[MIGRATION_CAPABILITY_COMPRESS] || - cap_list[MIGRATION_CAPABILITY_XBZRLE] || + if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND] && + (!new_caps[MIGRATION_CAPABILITY_MULTIFD] || + new_caps[MIGRATION_CAPABILITY_COMPRESS] || + new_caps[MIGRATION_CAPABILITY_XBZRLE] || migrate_multifd_compression() || migrate_use_tls())) { error_setg(errp, @@ -1404,15 +1395,15 @@ static bool migrate_caps_check(bool *cap_list, return false; } #else - if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) { + if (new_caps[MIGRATION_CAPABILITY_ZERO_COPY_SEND]) { error_setg(errp, "Zero copy currently only available on Linux"); return false; } #endif =20 - if (cap_list[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) { - if (!cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { + if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) { + if (!new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { error_setg(errp, "Postcopy preempt requires postcopy-ram"); return false; } @@ -1423,14 +1414,14 @@ static bool migrate_caps_check(bool *cap_list, * different compression channels, which is not compatible with the * preempt assumptions on channel assignments. */ - if (cap_list[MIGRATION_CAPABILITY_COMPRESS]) { + if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) { error_setg(errp, "Postcopy preempt not compatible with compres= s"); return false; } } =20 - if (cap_list[MIGRATION_CAPABILITY_MULTIFD]) { - if (cap_list[MIGRATION_CAPABILITY_COMPRESS]) { + if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) { + if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) { error_setg(errp, "Multifd is not compatible with compress"); return false; } @@ -1486,15 +1477,19 @@ void qmp_migrate_set_capabilities(MigrationCapabili= tyStatusList *params, { MigrationState *s =3D migrate_get_current(); MigrationCapabilityStatusList *cap; - bool cap_list[MIGRATION_CAPABILITY__MAX]; + bool new_caps[MIGRATION_CAPABILITY__MAX]; =20 if (migration_is_running(s->state)) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } =20 - memcpy(cap_list, s->capabilities, sizeof(cap_list)); - if (!migrate_caps_check(cap_list, params, errp)) { + memcpy(new_caps, s->capabilities, sizeof(new_caps)); + for (cap =3D params; cap; cap =3D cap->next) { + new_caps[cap->value->capability] =3D cap->value->state; + } + + if (!migrate_caps_check(s->capabilities, new_caps, errp)) { return; } =20 @@ -4631,27 +4626,14 @@ static void migration_instance_init(Object *obj) */ static bool migration_object_check(MigrationState *ms, Error **errp) { - MigrationCapabilityStatusList *head =3D NULL; /* Assuming all off */ - bool cap_list[MIGRATION_CAPABILITY__MAX] =3D { 0 }, ret; - int i; + bool old_caps[MIGRATION_CAPABILITY__MAX] =3D { 0 }; =20 if (!migrate_params_check(&ms->parameters, errp)) { return false; } =20 - for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { - if (ms->capabilities[i]) { - QAPI_LIST_PREPEND(head, migrate_cap_add(i, true)); - } - } - - ret =3D migrate_caps_check(cap_list, head, errp); - - /* It works with head =3D=3D NULL */ - qapi_free_MigrationCapabilityStatusList(head); - - return ret; + return migrate_caps_check(old_caps, ms->capabilities, errp); } =20 static const TypeInfo migration_type =3D { --=20 2.39.2