From patchwork Wed Oct 30 15:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EF06D6B6A0 for ; Wed, 30 Oct 2024 16:02:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B4s-0003Vz-Ek; Wed, 30 Oct 2024 11:57:46 -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 1t6B4q-0003VV-G6 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:44 -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 1t6B4o-0007ke-F4 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303861; 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=Fq34e+xBKmQ7ga4DrHPUzO43nYUW5RRJHXBVVJfk/Ig=; b=fdO2vxhwQuEK1YQAxcxg24y/FKHnyy4ZqaC14ZWKYyxhnN9N2R1Jwe1UtpWdKJUw9j3wJ/ qFSLMs5hG47unPPi9ZYuUMfcPPByiXzonsjJ3sBpgxsRcXVGBRAQ+uGaTp7I8gASD27s2d k63dxx8aGmnq+md4W8WxowZctoTYB8w= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674--EU3NgS7OGqrhYd2gIngfQ-1; Wed, 30 Oct 2024 11:57:39 -0400 X-MC-Unique: -EU3NgS7OGqrhYd2gIngfQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6d19597cee0so49692256d6.3 for ; Wed, 30 Oct 2024 08:57:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303858; x=1730908658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fq34e+xBKmQ7ga4DrHPUzO43nYUW5RRJHXBVVJfk/Ig=; b=kOclD0fG/CZ6/fpeofbN8MB2trUG4QAORzh48+aorX2RirFy1RPb6MJ9tt+PIvmxMV VCu1b4XOFiK955EutQDOf+6d9aEH4DHgaadZudupilOl/5SZa19nRoRr8Kh7ITBCYyCP rDyp4dHfql7JBuQ1bhaC/8HhCrnRK/dom2E2IDBn586A9QhqM0aHB6p5lZlo95bLWeyQ dG6QIukseu/7JTqIBIyoJZVLqIFRs/pM8LKMEQm2l29zI2gag15TMNTfLNUL4WI4TdBK DGoCKa1Lr992P6llnOx+wgYhp6k4q/EpKvyB8y/KXrkXFG9gjSKEhAeR7Wg7XrU/TtGe wCAQ== X-Gm-Message-State: AOJu0YypMJcKTIydF0ZWKWXc+6Rqb6GezyecbZqZL0RD5x16kLn8+92t IGMmYwYXc5Ilk1KhYAFh2DSFa5Q9vwK/EkD0fsRdmoXxg48naRbGFllMwTKIkl8Qjsz4W2TBy0+ TVeyCAbKTzkr5n0e58wBzGSi7uihDUWsydBYezCasMUCtm7L53zjdL1y6EdE0y7f978UIAMwAoS n8FzK6YB7N6tlyb6UE+H3mRjUynEdwpcoLog== X-Received: by 2002:a05:6214:568c:b0:6d1:939f:d861 with SMTP id 6a1803df08f44-6d346020777mr52962706d6.26.1730303858004; Wed, 30 Oct 2024 08:57:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyEdN9R8MUVctyLByAlUSpYHSmqO/oODMoLGF/V9rG16auW8l9Mt3FR/CmTzRY86q2lq1TTg== X-Received: by 2002:a05:6214:568c:b0:6d1:939f:d861 with SMTP id 6a1803df08f44-6d346020777mr52962396d6.26.1730303857658; Wed, 30 Oct 2024 08:57:37 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:36 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu Subject: [PULL 01/18] migration: Cleanup migrate_fd_cleanup() on accessing to_dst_file Date: Wed, 30 Oct 2024 11:57:17 -0400 Message-ID: <20241030155734.2141398-2-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The cleanup function can in many cases needs cleanup on its own. The major thing we want to do here is not referencing to_dst_file when without the file mutex. When at it, touch things elsewhere too to make it look slightly better in general. One thing to mention is, migration_thread has its own "running" boolean, so it doesn't need to rely on to_dst_file being non-NULL. Multifd has a dependency so it needs to be skipped if to_dst_file is not yet set; add a richer comment for such reason. Resolves: Coverity CID 1527402 Reported-by: Peter Maydell Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240919163042.116767-1-peterx@redhat.com Signed-off-by: Peter Xu --- migration/migration.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 021faee2f3..f5f428e764 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1405,6 +1405,9 @@ void migrate_set_state(MigrationStatus *state, MigrationStatus old_state, static void migrate_fd_cleanup(MigrationState *s) { MigrationEventType type; + QEMUFile *tmp = NULL; + + trace_migrate_fd_cleanup(); g_free(s->hostname); s->hostname = NULL; @@ -1415,26 +1418,29 @@ static void migrate_fd_cleanup(MigrationState *s) close_return_path_on_source(s); - if (s->to_dst_file) { - QEMUFile *tmp; - - trace_migrate_fd_cleanup(); + if (s->migration_thread_running) { bql_unlock(); - if (s->migration_thread_running) { - qemu_thread_join(&s->thread); - s->migration_thread_running = false; - } + qemu_thread_join(&s->thread); + s->migration_thread_running = false; bql_lock(); + } - multifd_send_shutdown(); - qemu_mutex_lock(&s->qemu_file_lock); + WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { + /* + * Close the file handle without the lock to make sure the critical + * section won't block for long. + */ tmp = s->to_dst_file; s->to_dst_file = NULL; - qemu_mutex_unlock(&s->qemu_file_lock); + } + + if (tmp) { /* - * Close the file handle without the lock to make sure the - * critical section won't block for long. + * We only need to shutdown multifd if tmp!=NULL, because if + * tmp==NULL, it means the main channel isn't established, while + * multifd is only setup after that (in migration_thread()). */ + multifd_send_shutdown(); migration_ioc_unregister_yank_from_file(tmp); qemu_fclose(tmp); } From patchwork Wed Oct 30 15:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E2AAD5CCB9 for ; Wed, 30 Oct 2024 15:58:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B4u-0003Wo-L8; Wed, 30 Oct 2024 11:57:48 -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 1t6B4t-0003WK-9t for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:47 -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 1t6B4r-0007kw-Dp for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303863; 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=0vMR4PZBXrmLnClQwHD7/3wsuLKI6SWDpGLbddmcqLQ=; b=YuAtitvqbj4DBiAp0QpcEk02799id0ArK7KlkwQKq7EjKOs3ls6E/lKM4UjdmO0ZGDZCxU 1ZO17eabKzrUEDomoGw4NmoVyTbsaKo24gsHXvGXJvfM0UA5gKaKPRkibXcxp3qQSMz6M7 ILej6//Mxv2DNsKOE+YfjsVrcapP/mM= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-livDLeWnOECYpL3ZZpQfsA-1; Wed, 30 Oct 2024 11:57:41 -0400 X-MC-Unique: livDLeWnOECYpL3ZZpQfsA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6ce2d91fa3bso45166d6.3 for ; Wed, 30 Oct 2024 08:57:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303860; x=1730908660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0vMR4PZBXrmLnClQwHD7/3wsuLKI6SWDpGLbddmcqLQ=; b=Y0xFB6u3uzMTKcAAdlwCLa4//J21Znzl166VK3E5psE1MNpgcW3BogbWRulmmEiKMM QJpLoL/nIs93P/DJhH7tVcBLtVIluCR3X8QB+Tp6y4TIvQdfyZuC50c5npvkgMh2HQa5 rmbg0sjqzDk4V79TsVdEfM9gN8EjWbQTbmW1r4b6T3Rp1/69jXzfQdurBc+HGpy5BK0f 0eBcdHUvKzKvzz8kGuw99H4bYVaT5KTKNRE+ivZbBk7fLuU4TDaEq+3OXLDJSoUVzIsF zXQ350jysT4hh0s3v5+Pw3CNynabAjNsqHn2TSryexuloCGtSNLCsEawNN9O0JcQSP42 F6OA== X-Gm-Message-State: AOJu0YyCZbx/hS6Yv/T16FmKut/kGmkT2L1/w18ox35FbgOfaL8BHcGj JUp8MB8Ff3NHHhSNErNCzuDCBG7mjwoIx2ZYrGO+raWHv6t/9g7K91Gb68GP9+wZi8LllAWEFBC 71K48+SjaOy2KcXQPXmp1E5MendU1Tm7qd6mYAJBTEF+NMlpk+Q7LU9cjPzBAYJDrqgOOe4OtSO jbmtk+4v5n94U+EN2frZUq3U0Jk0q4sfKC2w== X-Received: by 2002:a05:6214:3a84:b0:6cd:4972:59b1 with SMTP id 6a1803df08f44-6d1857030c9mr293618656d6.27.1730303859960; Wed, 30 Oct 2024 08:57:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJ3lzXQOtkJYycChb+Is7T0Qi2/KhanOvAXJ+Sl+MgVkUkrTIKAFOQX9l1IoszHg9uyrteAw== X-Received: by 2002:a05:6214:3a84:b0:6cd:4972:59b1 with SMTP id 6a1803df08f44-6d1857030c9mr293618346d6.27.1730303859570; Wed, 30 Oct 2024 08:57:39 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:38 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , Hyman Huang , Zhang Chen Subject: [PULL 02/18] migration: Put thread names together with macros Date: Wed, 30 Oct 2024 11:57:18 -0400 Message-ID: <20241030155734.2141398-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Keep migration thread names together, so it's easier to see a list of all possible migration threads. Still two functional changes below besides the macro defintions: - There's one dirty rate thread that we overlooked before, now we add that too and name it as "mig/dirtyrate" following the old rules. - The old name "mig/src/rp-thr" has "-thr" but it may not be useful if it's a thread name anyway, while "rp" can be slightly hard to read. Taking this chance to rename it to "mig/src/return", hopefully a better name. Reviewed-by: Fabiano Rosas Acked-by: Hyman Huang Reviewed-by: Zhang Chen Link: https://lore.kernel.org/r/20241011153652.517440-1-peterx@redhat.com Signed-off-by: Peter Xu --- migration/migration.h | 14 ++++++++++++++ migration/colo.c | 3 ++- migration/dirtyrate.c | 6 ++++-- migration/migration.c | 9 +++++---- migration/multifd.c | 6 +++--- migration/postcopy-ram.c | 6 ++++-- migration/savevm.c | 3 ++- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 38aa1402d5..b9ce5aa4ff 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -28,6 +28,20 @@ #include "sysemu/runstate.h" #include "migration/misc.h" +#define MIGRATION_THREAD_SNAPSHOT "mig/snapshot" +#define MIGRATION_THREAD_DIRTY_RATE "mig/dirtyrate" + +#define MIGRATION_THREAD_SRC_MAIN "mig/src/main" +#define MIGRATION_THREAD_SRC_MULTIFD "mig/src/send_%d" +#define MIGRATION_THREAD_SRC_RETURN "mig/src/return" +#define MIGRATION_THREAD_SRC_TLS "mig/src/tls" + +#define MIGRATION_THREAD_DST_COLO "mig/dst/colo" +#define MIGRATION_THREAD_DST_MULTIFD "mig/src/recv_%d" +#define MIGRATION_THREAD_DST_FAULT "mig/dst/fault" +#define MIGRATION_THREAD_DST_LISTEN "mig/dst/listen" +#define MIGRATION_THREAD_DST_PREEMPT "mig/dst/preempt" + struct PostcopyBlocktimeContext; #define MIGRATION_RESUME_ACK_VALUE (1) diff --git a/migration/colo.c b/migration/colo.c index 6449490221..9590f281d0 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -935,7 +935,8 @@ void coroutine_fn colo_incoming_co(void) assert(bql_locked()); assert(migration_incoming_colo_enabled()); - qemu_thread_create(&th, "mig/dst/colo", colo_process_incoming_thread, + qemu_thread_create(&th, MIGRATION_THREAD_DST_COLO, + colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); mis->colo_incoming_co = qemu_coroutine_self(); diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index 233acb0855..a74a6aeb56 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -29,6 +29,7 @@ #include "sysemu/runstate.h" #include "exec/memory.h" #include "qemu/xxhash.h" +#include "migration.h" /* * total_dirty_pages is procted by BQL and is used @@ -839,8 +840,9 @@ void qmp_calc_dirty_rate(int64_t calc_time, init_dirtyrate_stat(config); - qemu_thread_create(&thread, "get_dirtyrate", get_dirtyrate_thread, - (void *)&config, QEMU_THREAD_DETACHED); + qemu_thread_create(&thread, MIGRATION_THREAD_DIRTY_RATE, + get_dirtyrate_thread, (void *)&config, + QEMU_THREAD_DETACHED); } diff --git a/migration/migration.c b/migration/migration.c index f5f428e764..7609e0feed 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2484,7 +2484,7 @@ static int open_return_path_on_source(MigrationState *ms) trace_open_return_path_on_source(); - qemu_thread_create(&ms->rp_state.rp_thread, "mig/src/rp-thr", + qemu_thread_create(&ms->rp_state.rp_thread, MIGRATION_THREAD_SRC_RETURN, source_return_path_thread, ms, QEMU_THREAD_JOINABLE); ms->rp_state.rp_thread_created = true; @@ -3473,7 +3473,8 @@ static void *migration_thread(void *opaque) Error *local_err = NULL; int ret; - thread = migration_threads_add("live_migration", qemu_get_thread_id()); + thread = migration_threads_add(MIGRATION_THREAD_SRC_MAIN, + qemu_get_thread_id()); rcu_register_thread(); @@ -3823,10 +3824,10 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) } if (migrate_background_snapshot()) { - qemu_thread_create(&s->thread, "mig/snapshot", + qemu_thread_create(&s->thread, MIGRATION_THREAD_SNAPSHOT, bg_migration_thread, s, QEMU_THREAD_JOINABLE); } else { - qemu_thread_create(&s->thread, "mig/src/main", + qemu_thread_create(&s->thread, MIGRATION_THREAD_SRC_MAIN, migration_thread, s, QEMU_THREAD_JOINABLE); } s->migration_thread_running = true; diff --git a/migration/multifd.c b/migration/multifd.c index 9b200f4ad9..697fe86fdf 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -723,7 +723,7 @@ static bool multifd_tls_channel_connect(MultiFDSendParams *p, args->p = p; p->tls_thread_created = true; - qemu_thread_create(&p->tls_thread, "mig/src/tls", + qemu_thread_create(&p->tls_thread, MIGRATION_THREAD_SRC_TLS, multifd_tls_handshake_thread, args, QEMU_THREAD_JOINABLE); return true; @@ -841,7 +841,7 @@ bool multifd_send_setup(void) + sizeof(uint64_t) * page_count; p->packet = g_malloc0(p->packet_len); } - p->name = g_strdup_printf("mig/src/send_%d", i); + p->name = g_strdup_printf(MIGRATION_THREAD_SRC_MULTIFD, i); p->write_flags = 0; if (!multifd_new_send_channel_create(p, &local_err)) { @@ -1259,7 +1259,7 @@ int multifd_recv_setup(Error **errp) + sizeof(uint64_t) * page_count; p->packet = g_malloc0(p->packet_len); } - p->name = g_strdup_printf("mig/dst/recv_%d", i); + p->name = g_strdup_printf(MIGRATION_THREAD_DST_MULTIFD, i); p->normal = g_new0(ram_addr_t, page_count); p->zero = g_new0(ram_addr_t, page_count); } diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 83f6160a36..a535fd2e30 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1230,7 +1230,8 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis) return -1; } - postcopy_thread_create(mis, &mis->fault_thread, "mig/dst/fault", + postcopy_thread_create(mis, &mis->fault_thread, + MIGRATION_THREAD_DST_FAULT, postcopy_ram_fault_thread, QEMU_THREAD_JOINABLE); mis->have_fault_thread = true; @@ -1250,7 +1251,8 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis) * This thread needs to be created after the temp pages because * it'll fetch RAM_CHANNEL_POSTCOPY PostcopyTmpPage immediately. */ - postcopy_thread_create(mis, &mis->postcopy_prio_thread, "mig/dst/preempt", + postcopy_thread_create(mis, &mis->postcopy_prio_thread, + MIGRATION_THREAD_DST_PREEMPT, postcopy_preempt_thread, QEMU_THREAD_JOINABLE); mis->preempt_thread_status = PREEMPT_THREAD_CREATED; } diff --git a/migration/savevm.c b/migration/savevm.c index 7e1e27182a..e796436979 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2131,7 +2131,8 @@ static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) } mis->have_listen_thread = true; - postcopy_thread_create(mis, &mis->listen_thread, "mig/dst/listen", + postcopy_thread_create(mis, &mis->listen_thread, + MIGRATION_THREAD_DST_LISTEN, postcopy_ram_listen_thread, QEMU_THREAD_DETACHED); trace_loadvm_postcopy_handle_listen("return"); From patchwork Wed Oct 30 15:57:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D516D5B86D for ; Wed, 30 Oct 2024 15:59:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B4v-0003XA-Q1; Wed, 30 Oct 2024 11:57:49 -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 1t6B4t-0003WI-6J for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:47 -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 1t6B4r-0007lL-Df for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303864; 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=eLmfXxT/DLKKNW5bJqVMU68mP3Y9rc7URGbbAHO3xiw=; b=XHh6A3BgcpGpjOG9zCU2YO5Qnjr6FReMSecwhpbnkTqCc+wep+lp5xFvfypyusvsgQ/hZv T76m4CrR8t2Tf73n0y0KR43B28rrgtAPYI0WiccW9aLSO9aKyux2p4Iv8lnBq6HxB7mJkZ xbHCzhFmqJujV2mDDmGofa4MJdrUItY= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-daP6YJLGPoS1nr4zShGGbw-1; Wed, 30 Oct 2024 11:57:43 -0400 X-MC-Unique: daP6YJLGPoS1nr4zShGGbw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6cbe933e877so166076d6.1 for ; Wed, 30 Oct 2024 08:57:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303862; x=1730908662; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eLmfXxT/DLKKNW5bJqVMU68mP3Y9rc7URGbbAHO3xiw=; b=Pc/xCueM5uNw0Q/iHb+oh0BmCO3BKVt7SJEPzLvuEZS1X96/QvZP/dJHzhwvpqXAZx LGwMvPkgK49suxUP7SrxXyVnGqaAdYZi/vmFWW8M9bsMKx9QU9qgr6IOk4H6s1L7mSGD aISSPGhdbIdKiKVHjf+U295A1xqukf39RkT5gMY7NfIb6fxQDXp5/W3lyoGss8hkorQW 24clm/JR1leyH6WQAwcZYGjn7//FpP0JJuniri0qoyhoWkNHZkU0k8AWekBuO/5Q4eCL JSoL+DJIHOHBm8vV796s0V2Mn4aH7lYVoh78cfXSqPnH/vb0Ne6/6FQc/tlNs8F5k5iR uCbA== X-Gm-Message-State: AOJu0Yxs+KpKI90j+ruAebhzSLaic4++D1EJ4seytMQu0AzjzcTWVZUQ zTgCNto1jVNJjXaxHsSCzUxvlrVU4kzZCXRdftKFFawhQM4cMKTqrP/g14ojaedTnTropUsySjv WLmqTBk/KmAF9iGlOnWG2B070SPVwO22PpC/5ouvjpUZjayeHJd6WncmHDMCEhYlE1d2rTdP4dD lsDKD2E3yTktdzpMYwRbTRfPQ9lVhYVz4xRw== X-Received: by 2002:a05:6214:4305:b0:6cb:e53d:dd7 with SMTP id 6a1803df08f44-6d1856e6b8bmr179609066d6.19.1730303861969; Wed, 30 Oct 2024 08:57:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnviHexEz2UeiXDo12oy/A+rfrNlg3wuIuaqp6JVOyBblkIp8xqc67ZFRVY8/vY6arTtYzWg== X-Received: by 2002:a05:6214:4305:b0:6cb:e53d:dd7 with SMTP id 6a1803df08f44-6d1856e6b8bmr179608876d6.19.1730303861565; Wed, 30 Oct 2024 08:57:41 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:40 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hanna Czenczek , Peter Xu Subject: [PULL 03/18] migration: Ensure vmstate_save() sets errp Date: Wed, 30 Oct 2024 11:57:19 -0400 Message-ID: <20241030155734.2141398-4-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hanna Czenczek migration/savevm.c contains some calls to vmstate_save() that are followed by migrate_set_error() if the integer return value indicates an error. migrate_set_error() requires that the `Error *` object passed to it is set. Therefore, vmstate_save() is assumed to always set *errp on error. Right now, that assumption is not met: vmstate_save_state_v() (called internally by vmstate_save()) will not set *errp if vmstate_subsection_save() or vmsd->post_save() fail. Fix that by adding an *errp parameter to vmstate_subsection_save(), and by generating a generic error in case post_save() fails (as is already done for pre_save()). Without this patch, qemu will crash after vmstate_subsection_save() or post_save() have failed inside of a vmstate_save() call (unless migrate_set_error() then happen to discard the new error because s->error is already set). This happens e.g. when receiving the state from a virtio-fs back-end (virtiofsd) fails. Signed-off-by: Hanna Czenczek Link: https://lore.kernel.org/r/20241015170437.310358-1-hreitz@redhat.com Signed-off-by: Peter Xu --- migration/vmstate.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index ff5d589a6d..fa002b24e8 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -22,7 +22,8 @@ #include "trace.h" static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc); + void *opaque, JSONWriter *vmdesc, + Error **errp); static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd, void *opaque); @@ -441,12 +442,13 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, json_writer_end_array(vmdesc); } - ret = vmstate_subsection_save(f, vmsd, opaque, vmdesc); + ret = vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp); if (vmsd->post_save) { int ps_ret = vmsd->post_save(opaque); - if (!ret) { + if (!ret && ps_ret) { ret = ps_ret; + error_setg(errp, "post-save failed: %s", vmsd->name); } } return ret; @@ -518,7 +520,8 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd, } static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, JSONWriter *vmdesc) + void *opaque, JSONWriter *vmdesc, + Error **errp) { const VMStateDescription * const *sub = vmsd->subsections; bool vmdesc_has_subsections = false; @@ -546,7 +549,7 @@ static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, qemu_put_byte(f, len); qemu_put_buffer(f, (uint8_t *)vmsdsub->name, len); qemu_put_be32(f, vmsdsub->version_id); - ret = vmstate_save_state(f, vmsdsub, opaque, vmdesc); + ret = vmstate_save_state_with_err(f, vmsdsub, opaque, vmdesc, errp); if (ret) { return ret; } From patchwork Wed Oct 30 15:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA4C9D5CCB9 for ; Wed, 30 Oct 2024 15:59:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B4x-0003XU-BE; Wed, 30 Oct 2024 11:57: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 1t6B4w-0003XC-Bc for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:50 -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 1t6B4u-0007m1-VF for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303868; 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=+OC04zWrmLQv9jlMFCWvGBK923Zpyicv5m+dwVSdRYg=; b=Sf/bMb0kmbR4AokovOe9prJN5ydwTbg20Z0jEqzSmdObLLJzWZ161jEcHg7WYwdjbmz5RN UxcEJ03GJHMjbW9QFOvTlQcaDXjABiau07FuM4pSjerpin/5QwZMDVWffQHgtuUXyiXgKw RZtXZEplBFxYQiy4oI/o05R2Yba1clg= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-aj5LybM6OcqsWRz0pnEzpA-1; Wed, 30 Oct 2024 11:57:45 -0400 X-MC-Unique: aj5LybM6OcqsWRz0pnEzpA-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3e60970ed1dso31291b6e.0 for ; Wed, 30 Oct 2024 08:57:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303864; x=1730908664; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+OC04zWrmLQv9jlMFCWvGBK923Zpyicv5m+dwVSdRYg=; b=oW4VMqZcFz1rrtPidxUiUIjFXbYJpyQ0hkModsvuwmpGcwbEZueG5vcwlf65IgNIQC OrrF60KodZXIGiYK/vuGtOanDRuLpIxzvgUwTrHg/iifKinOrv8E5Ak9u5s72eszA+E3 FhqKVY7gzL63SQW3XamJjejFEsk50QfOLgENJGAemy1Ne7vhGnmE7kaSyaYgEp6HEMaO 8jQ4UZ9nSidAvNYEQo7hmaQ9hedPPBlelCrSWtUxoZW5O8kQAcyLdRIQ3xpD7MBbdHkD ZgckCchJlCi2c/i/aNizWU+7nhL+kd/btd46hJHyh75JbhB1ry9PzDYEitl3n56cqKrt 74EQ== X-Gm-Message-State: AOJu0YxK+JPfY1RTr1+B7JSmgF8gvdS84c28bFaY26ZT1XsyxiqKXjgQ to/8o0wVd+035Dh4evmAecNp7hsq9OFAaUdI+Jaq7wNTrgiR7UzxxGyv3p6pq8lXoAc22ZB0CaM tD6M5V7cgDgiuq/FRDu03/jKu+KRTNg/93ymQS0uxv0QKzeKjpMvkiwiyjljr9wBfCTn9egON4J dEL1xZf2q44wKwTwDkGA4skWodHyIWUSCb3w== X-Received: by 2002:a05:6808:1487:b0:3e6:77d:2ea1 with SMTP id 5614622812f47-3e6384b9564mr13946819b6e.45.1730303863788; Wed, 30 Oct 2024 08:57:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwb7zFYkHxM6wk6In87GHjFcARRYE4qSE/uLqcjwNOdUP4FcyGQfpy56ffwQp4s4S6u2SneQ== X-Received: by 2002:a05:6808:1487:b0:3e6:77d:2ea1 with SMTP id 5614622812f47-3e6384b9564mr13946787b6e.45.1730303863338; Wed, 30 Oct 2024 08:57:43 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:42 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hyman Huang , Peter Xu Subject: [PULL 04/18] accel/tcg/icount-common: Remove the reference to the unused header file Date: Wed, 30 Oct 2024 11:57:20 -0400 Message-ID: <20241030155734.2141398-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hyman Huang Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/5e33b423d0b8506e5cb33fff42b50aa301b7731b.1729146786.git.yong.huang@smartx.com Signed-off-by: Peter Xu --- accel/tcg/icount-common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/accel/tcg/icount-common.c b/accel/tcg/icount-common.c index 8d3d3a7e9d..30bf8500dc 100644 --- a/accel/tcg/icount-common.c +++ b/accel/tcg/icount-common.c @@ -36,7 +36,6 @@ #include "sysemu/runstate.h" #include "hw/core/cpu.h" #include "sysemu/cpu-timers.h" -#include "sysemu/cpu-throttle.h" #include "sysemu/cpu-timers-internal.h" /* From patchwork Wed Oct 30 15:57:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9EAFD5B86D for ; Wed, 30 Oct 2024 15:59:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B4y-0003Xk-A6; Wed, 30 Oct 2024 11:57:52 -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 1t6B4w-0003XL-Si for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57: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 1t6B4v-0007lx-CK for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303868; 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=LPVTPWOgvdRxt04d1ASLhb7X2V2plDFvoFd5bfX+Z30=; b=O/JT2bM97RQHgvm1la8F2gOteDQ0eGCqAm6gFKc0keXLvUJY0ZvzQEVKzVGqLnqMuW4217 bNC3QHSR/wPaBKjx5ETRn4dYp5ozFhJDDdiRSpJxVvJTqB3+8SHE0E78fP/sK45f/fZc4d 9bWM+rDaahs/8YIWMKtkBZEqhcnLwD4= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-vRu3npNEMiygzj8w3sbVcg-1; Wed, 30 Oct 2024 11:57:46 -0400 X-MC-Unique: vRu3npNEMiygzj8w3sbVcg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6d35062e1fcso59336d6.1 for ; Wed, 30 Oct 2024 08:57:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303866; x=1730908666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LPVTPWOgvdRxt04d1ASLhb7X2V2plDFvoFd5bfX+Z30=; b=PGvmSkb+L/hqdFd88kxeH3c+HQnqRaT6PAzp2kOm7oRQwlu6cbQxE++Ph39NasgjF3 zY20NJoNKrQCm+eSKJu2wPb+yjYoKPdVpJ6Lrr9QzMJFJiSokA6NphFZfiUzbz2oebbU DVgJG1hh1b3XBS3mDWGCoEwK5tySwMgGI2pCTITyKNcfghQ723MoZHTvt1Hf7gZRcbVD Jbki48e7tvdpZP/LVFkgcyqitMxH6dGTHCJQH/ZhgchVpXzQ/Xgd8EwFsfWagTQNimou H5UPX3RyyAmG/ByyUNj5w98l75sjtmElHTQ3YqjI4VQ7Jd5q741Jf/5oPfEJxsLO2YFO qiwA== X-Gm-Message-State: AOJu0YyK2/wj0u++WunCu9P8NxoBeD0ukyM41gwgzd92CK2nB7tTNMce ZCCSQkO25icRjvH9yp/xEEge4NJNCJn8zpbxQX4EkysP0ipDPG5QS+zCy8NtwncoUIZ/7LsLLZx Gzs6vvs0W82ukb8YI4JQYIaljJ8r7LTi19/HGBKLGQZHZwCGK97HNo39T5elkbKio0tV9Iqy+8Z BMoAtKGaeyesHcPhdjgwWudrvwwlwJV9bVVQ== X-Received: by 2002:a05:6214:5a0b:b0:6cc:2d3c:6472 with SMTP id 6a1803df08f44-6d1856b4898mr207007696d6.14.1730303865797; Wed, 30 Oct 2024 08:57:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIszSgVBjS+zerSZyizB+9+ynJ/mMCVgJPmtbKtXxBQCXLHsgEuEo4q3PtErowkRb+Df7Ezw== X-Received: by 2002:a05:6214:5a0b:b0:6cc:2d3c:6472 with SMTP id 6a1803df08f44-6d1856b4898mr207007416d6.14.1730303865389; Wed, 30 Oct 2024 08:57:45 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:43 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hyman Huang , Peter Xu Subject: [PULL 05/18] migration: Stop CPU throttling conditionally Date: Wed, 30 Oct 2024 11:57:21 -0400 Message-ID: <20241030155734.2141398-6-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hyman Huang Since CPU throttling only occurs when auto-converge is on, stop it conditionally. Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/f0c787080bb9ab0c37952f0ca5bfaa525d5ddd14.1729146786.git.yong.huang@smartx.com Signed-off-by: Peter Xu --- migration/migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 7609e0feed..e81c70b9d2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3295,7 +3295,9 @@ static MigIterateState migration_iteration_run(MigrationState *s) static void migration_iteration_finish(MigrationState *s) { /* If we enabled cpu throttling for auto-converge, turn it off. */ - cpu_throttle_stop(); + if (migrate_auto_converge()) { + cpu_throttle_stop(); + } bql_lock(); switch (s->state) { From patchwork Wed Oct 30 15:57:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7383CD5B86D for ; Wed, 30 Oct 2024 16:00:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B51-0003Zo-7U; Wed, 30 Oct 2024 11:57:55 -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 1t6B4z-0003YB-Nk for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:53 -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 1t6B4y-0007mZ-04 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303871; 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=C2Ri6ieB7IwH4p+D8nROEDVqJEEWkYMxiCblf72V1A4=; b=M8ZvIm+1V3ajEhjE/yJjNMR28MssMwYGcy58kfwqwc+ZAKHez/PCaL7aO4YGAnO613YcVO Nj6oPBldBcmjpMyfezHVkwn+h/7mYDy5zPR+S1QYYfF+a4+N51paXav4sRSSk4Y0TXhxBp JFaVDek+fPgRfd1p05zJ//8HbEwXSFc= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-UwO7QnpoNOKEG5l20Y9itQ-1; Wed, 30 Oct 2024 11:57:48 -0400 X-MC-Unique: UwO7QnpoNOKEG5l20Y9itQ-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-71804a17e53so6878140a34.3 for ; Wed, 30 Oct 2024 08:57:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303867; x=1730908667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C2Ri6ieB7IwH4p+D8nROEDVqJEEWkYMxiCblf72V1A4=; b=Dvd1TCCBkZOczNMEb32ugM+8IeD+jsxjB6xUURJCtSenRcVEeE0cMhWMZwZkzsAUMR H96rBvWoeB+NATJJ9Ne3JI0fKp86lCLKju58jO01QuMUApagyq1VV8UioDiCVxzf7Vll Owg0SouvgVlYmNDqhtvsSFUiYjpLNkC5ObliN9No7huKrQ2dkM8BiMxW21+hPVgDngpJ GZYa2snjDl0Vk3OLK+5Uw1VqcyqPdF5TgK9ChJy7LRv/YDGgE2mSvo0qCVKgmnIss0r/ gbuvA1Jxbag4iCNFnzChNP98BJ8UEhXLa35Qcd8OEt/SVIroxbu8+WWSblKvYQRhy+dy ZUXw== X-Gm-Message-State: AOJu0Yx34J9AJaB8sKDZjNtEEO2/wSLUGh3SuWCga7NdFqc8tl06CWzt DCZcwuG1pl8GelBqZflnXZ2reMPeiei7pfhZvxGaPB2C2IZT545D1ZMJUDCCgRt5O224CKBufGv JsEBcNajX67lEX73H9umobuQ5I91ecyKjOAVXgjfei3GLz9FAOUIHgwH0KIDd6ZfIBNT+8ulMen PhmBhzvzFnHH0saREr8+Cw+fE2lMBwhcOTcw== X-Received: by 2002:a05:6830:6d86:b0:70f:716c:7d4a with SMTP id 46e09a7af769-718920b61e1mr4206091a34.27.1730303867334; Wed, 30 Oct 2024 08:57:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgSW46v0JmeV6C3Cnu5g7Tu7DuHsVCpVPcKY9Mll5jfD4mk+aCpf/vf4ggdbVddvWKGlcQTg== X-Received: by 2002:a05:6830:6d86:b0:70f:716c:7d4a with SMTP id 46e09a7af769-718920b61e1mr4206065a34.27.1730303866928; Wed, 30 Oct 2024 08:57:46 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:45 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hyman Huang , Peter Xu Subject: [PULL 06/18] migration: Move cpu-throttole.c from system to migration Date: Wed, 30 Oct 2024 11:57:22 -0400 Message-ID: <20241030155734.2141398-7-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hyman Huang Move cpu-throttle.c from system to migration since it's only used for migration; this makes us avoid exporting the util functions and variables in misc.h but export them in migration.h when implementing the periodic ramblock dirty sync feature in the upcoming commits. Since CPU throttle timers are only used in migration, move their registry to migration_object_init. Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/c1b3efaa0cb49e03d422e9da97bdb65cc3d234d1.1729146786.git.yong.huang@smartx.com Signed-off-by: Peter Xu --- {include/sysemu => migration}/cpu-throttle.h | 0 {system => migration}/cpu-throttle.c | 2 +- migration/migration.c | 5 ++++- migration/ram.c | 2 +- system/cpu-timers.c | 3 --- migration/meson.build | 1 + migration/trace-events | 3 +++ system/meson.build | 1 - system/trace-events | 3 --- 9 files changed, 10 insertions(+), 10 deletions(-) rename {include/sysemu => migration}/cpu-throttle.h (100%) rename {system => migration}/cpu-throttle.c (99%) diff --git a/include/sysemu/cpu-throttle.h b/migration/cpu-throttle.h similarity index 100% rename from include/sysemu/cpu-throttle.h rename to migration/cpu-throttle.h diff --git a/system/cpu-throttle.c b/migration/cpu-throttle.c similarity index 99% rename from system/cpu-throttle.c rename to migration/cpu-throttle.c index 7632dc6143..fa47ee2e21 100644 --- a/system/cpu-throttle.c +++ b/migration/cpu-throttle.c @@ -27,7 +27,7 @@ #include "hw/core/cpu.h" #include "qemu/main-loop.h" #include "sysemu/cpus.h" -#include "sysemu/cpu-throttle.h" +#include "cpu-throttle.h" #include "trace.h" /* vcpu throttling controls */ diff --git a/migration/migration.c b/migration/migration.c index e81c70b9d2..05c8cd50b4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -24,7 +24,7 @@ #include "socket.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" -#include "sysemu/cpu-throttle.h" +#include "cpu-throttle.h" #include "rdma.h" #include "ram.h" #include "migration/global_state.h" @@ -263,6 +263,9 @@ void migration_object_init(void) ram_mig_init(); dirty_bitmap_mig_init(); + + /* Initialize cpu throttle timers */ + cpu_throttle_init(); } typedef struct { diff --git a/migration/ram.c b/migration/ram.c index 326ce7eb79..54d352b152 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -52,7 +52,7 @@ #include "exec/target_page.h" #include "qemu/rcu_queue.h" #include "migration/colo.h" -#include "sysemu/cpu-throttle.h" +#include "cpu-throttle.h" #include "savevm.h" #include "qemu/iov.h" #include "multifd.h" diff --git a/system/cpu-timers.c b/system/cpu-timers.c index 0b31c9a1b6..856e502e34 100644 --- a/system/cpu-timers.c +++ b/system/cpu-timers.c @@ -35,7 +35,6 @@ #include "sysemu/runstate.h" #include "hw/core/cpu.h" #include "sysemu/cpu-timers.h" -#include "sysemu/cpu-throttle.h" #include "sysemu/cpu-timers-internal.h" /* clock and ticks */ @@ -272,6 +271,4 @@ void cpu_timers_init(void) seqlock_init(&timers_state.vm_clock_seqlock); qemu_spin_init(&timers_state.vm_clock_lock); vmstate_register(NULL, 0, &vmstate_timers, &timers_state); - - cpu_throttle_init(); } diff --git a/migration/meson.build b/migration/meson.build index 66d3de86f0..d53cf3417a 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -13,6 +13,7 @@ system_ss.add(files( 'block-dirty-bitmap.c', 'channel.c', 'channel-block.c', + 'cpu-throttle.c', 'dirtyrate.c', 'exec.c', 'fd.c', diff --git a/migration/trace-events b/migration/trace-events index c65902f042..9a19599804 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -378,3 +378,6 @@ migration_block_progression(unsigned percent) "Completed %u%%" # page_cache.c migration_pagecache_init(int64_t max_num_items) "Setting cache buckets to %" PRId64 migration_pagecache_insert(void) "Error allocating page" + +# cpu-throttle.c +cpu_throttle_set(int new_throttle_pct) "set guest CPU throttled by %d%%" diff --git a/system/meson.build b/system/meson.build index a296270cb0..4952f4b2c7 100644 --- a/system/meson.build +++ b/system/meson.build @@ -10,7 +10,6 @@ system_ss.add(files( 'balloon.c', 'bootdevice.c', 'cpus.c', - 'cpu-throttle.c', 'cpu-timers.c', 'datadir.c', 'dirtylimit.c', diff --git a/system/trace-events b/system/trace-events index 074d001e90..2ed1d59b1f 100644 --- a/system/trace-events +++ b/system/trace-events @@ -44,6 +44,3 @@ dirtylimit_state_finalize(void) dirtylimit_throttle_pct(int cpu_index, uint64_t pct, int64_t time_us) "CPU[%d] throttle percent: %" PRIu64 ", throttle adjust time %"PRIi64 " us" dirtylimit_set_vcpu(int cpu_index, uint64_t quota) "CPU[%d] set dirty page rate limit %"PRIu64 dirtylimit_vcpu_execute(int cpu_index, int64_t sleep_time_us) "CPU[%d] sleep %"PRIi64 " us" - -# cpu-throttle.c -cpu_throttle_set(int new_throttle_pct) "set guest CPU throttled by %d%%" From patchwork Wed Oct 30 15:57:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D68BD5CCB9 for ; Wed, 30 Oct 2024 15:59:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B51-0003Zk-1S; Wed, 30 Oct 2024 11:57:55 -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 1t6B4z-0003Y3-Gd for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:53 -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 1t6B4y-0007mg-1S for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303871; 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=VZ5QodDwv3ORch5PcuAUwF6k+gefMHdTNqxMB123ETI=; b=gOlpkz5Ya4USrMwPs3OavJcJOGlUwDD88IhxFPJRq0g3W9UuHGdAgWU7kUSPfnvXKEjxWE EDAto0ZUYHR+HIlXmKtLQb0Py249mfRzpBgG46k5iqxz0HUoQJE2YJhUnHfTjC7Jekvk6t ILyKoCd2MiBni+jzEkI5UuEo72TDjDY= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-8A_QMoIfO9yxYq788YYSqw-1; Wed, 30 Oct 2024 11:57:50 -0400 X-MC-Unique: 8A_QMoIfO9yxYq788YYSqw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6cbebfc1725so186466d6.1 for ; Wed, 30 Oct 2024 08:57:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303869; x=1730908669; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VZ5QodDwv3ORch5PcuAUwF6k+gefMHdTNqxMB123ETI=; b=pvUdrdh6vSs3K7bcFeYfJt1hng8CzxeW1WIvDatvx+yNbNNix0zxzSI+m6b2hzpGpe ZoA+NdOhSoZ+BJKTeyYVD+eyKOJ1dM8tcphUkTld7WDy75RBF1r/9UE+IYkZlJTO314Y S6zZTqUjFrLV5YHtgtNMXDX85+DqPT5SLvz1GSakV/GvEulTFI9CYy2XA0Ue+iF15km1 IEDrzqx6S8XasWTd34nb8kXoXNv3XTEhELz0hpT83O7fmjQD7KHSosbBubIZq1hEwwKR iNPDS2hD3n0bgblzziptmmlAm1tGHzadEhpwuJvRGvmYkoW/kXjHgwKDkdwbfTtJt19f P8sA== X-Gm-Message-State: AOJu0YzHP4/8cWWT/eO8RRq4xR0NC2tUVR5lhl8iFjGg6EZkCX8Qh7RN C8lOwhelvQBACZUEnEvDTp8hnT56BkS2SFKLSWp/8VuXn3NfN+I1/uhMqb37wULrGM+S37ib2B7 f5v1PvwRy2njPqxzDoQWHI2p9m4R1ztAiaD6KCZ5SqV0yRXbBgCzuj6lOoRo/EBFPQoWHMw2ycx 7arqqdSfUFO096ZkaoqZwK4oAAYGO2Rdah1Q== X-Received: by 2002:a05:6214:53c4:b0:6cd:7a2e:4611 with SMTP id 6a1803df08f44-6d18586cb75mr289116286d6.47.1730303869026; Wed, 30 Oct 2024 08:57:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/wv7qlh6f7/e5ugfrqDXUMEEq5p/T3MBZIEc4Xt3a/cFaMRDBYx6M7SOUO4AMpF4erNSNfA== X-Received: by 2002:a05:6214:53c4:b0:6cd:7a2e:4611 with SMTP id 6a1803df08f44-6d18586cb75mr289115996d6.47.1730303868674; Wed, 30 Oct 2024 08:57:48 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:47 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hyman Huang , Peter Xu Subject: [PULL 07/18] migration: Remove "rs" parameter in migration_bitmap_sync_precopy Date: Wed, 30 Oct 2024 11:57:23 -0400 Message-ID: <20241030155734.2141398-8-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hyman Huang The global static variable ram_state in fact is referred to by the "rs" parameter in migration_bitmap_sync_precopy. For ease of calling by the callees, use the global variable directly in migration_bitmap_sync_precopy and remove "rs" parameter. The migration_bitmap_sync_precopy will be exported in the next commit. Signed-off-by: Hyman Huang Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/283c335d61463bf477160da91b24da45cdaf3e43.1729146786.git.yong.huang@smartx.com Signed-off-by: Peter Xu --- migration/ram.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 54d352b152..9b5b350405 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1088,9 +1088,10 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage) } } -static void migration_bitmap_sync_precopy(RAMState *rs, bool last_stage) +static void migration_bitmap_sync_precopy(bool last_stage) { Error *local_err = NULL; + assert(ram_state); /* * The current notifier usage is just an optimization to migration, so we @@ -1101,7 +1102,7 @@ static void migration_bitmap_sync_precopy(RAMState *rs, bool last_stage) local_err = NULL; } - migration_bitmap_sync(rs, last_stage); + migration_bitmap_sync(ram_state, last_stage); if (precopy_notify(PRECOPY_NOTIFY_AFTER_BITMAP_SYNC, &local_err)) { error_report_err(local_err); @@ -2782,7 +2783,7 @@ static bool ram_init_bitmaps(RAMState *rs, Error **errp) if (!ret) { goto out_unlock; } - migration_bitmap_sync_precopy(rs, false); + migration_bitmap_sync_precopy(false); } } out_unlock: @@ -3248,7 +3249,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) WITH_RCU_READ_LOCK_GUARD() { if (!migration_in_postcopy()) { - migration_bitmap_sync_precopy(rs, true); + migration_bitmap_sync_precopy(true); } ret = rdma_registration_start(f, RAM_CONTROL_FINISH); @@ -3330,7 +3331,7 @@ static void ram_state_pending_exact(void *opaque, uint64_t *must_precopy, if (!migration_in_postcopy()) { bql_lock(); WITH_RCU_READ_LOCK_GUARD() { - migration_bitmap_sync_precopy(rs, false); + migration_bitmap_sync_precopy(false); } bql_unlock(); } From patchwork Wed Oct 30 15:57:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71248D5B86D for ; Wed, 30 Oct 2024 15:58:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B54-0003aZ-Pc; Wed, 30 Oct 2024 11:57: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 1t6B53-0003aH-33 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57: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 1t6B51-0007nA-6i for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303874; 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=gLN0f4cofvuVt5w14C5bOhSxhfhHTWPcx/PY6JtfmaI=; b=LjRjPsxGWhxXRPyHcP1AXqQwHKqxb5p9Sr/lwUCBEjLA+TaHtEBP/8oajIZNwEn+X9MSpg gwAwBDePDWoytyWLebKRuopp3d1sfbfjYTv8PKj3bGZlU2Wjq/chE3Hawmm56pwR85cIAs /xfXogDi1Hhhy1xhyJQhRU09nJGH5w0= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-so2wkUe_NHmAcLrDJ4D35w-1; Wed, 30 Oct 2024 11:57:52 -0400 X-MC-Unique: so2wkUe_NHmAcLrDJ4D35w-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3e5f2dab4a8so6864935b6e.2 for ; Wed, 30 Oct 2024 08:57:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303871; x=1730908671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gLN0f4cofvuVt5w14C5bOhSxhfhHTWPcx/PY6JtfmaI=; b=fByQVMTkSF7bU27tb8QNgxhIMMgzcebCn+4Gia1wifGelct9xl7/g3pmDBShF+XKe4 W47GNn3SqS83zIWd4VvM5E8wJVhGcUZZClXMpqZLmwIc9F4DBHl65IShRJjYtVgCAaic TLMZgogmNti6uTGY/bCcr9OdwZuevwiTC6VCCQGZPelfDXAuE8mzh0wtXdEMjvHyGgbZ aAWRM1O81Vg0oNfmVo9fHn0YvfG2URB6n5qWbIwebqnpe0WuMxtWOV+iPBRq+UUP5Nso Xb8FVh2ufHrg39wrOqxcJeSpO+wb7ELca7fua6GqTftytSuIAZ/ily4U8hmYxOLugvay ZPMg== X-Gm-Message-State: AOJu0Yywkgc+xsoe+wa9HaZTEosVlFAlJtlpVFAT5SgZfuLCAG4hZW1s CD7XMg11YCpuurHt3VG9Q1DhDalG+X4n1ScaaCHyNsEpdMFLRmdXUSy+B8++jAxXda9us7/8TxB 22sqzoQqQ0mVSil1Nzll2/erCqsLkwHjpWOkNUd0YLo+NrauArEsS+AWaB5ol17pXCIlz91OQr6 CwrdYg0r4p26yZH7Das0gLAG52ogyRY3Webg== X-Received: by 2002:a05:6808:13d2:b0:3e6:2ae7:a2a4 with SMTP id 5614622812f47-3e6384ce490mr12940905b6e.44.1730303871007; Wed, 30 Oct 2024 08:57:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk1OezfiDMmVDAxXFgPiS1aYvSubfil7QFlAu/XczRVBzR4qS+d9OqavvKcm+27frMuW/giA== X-Received: by 2002:a05:6808:13d2:b0:3e6:2ae7:a2a4 with SMTP id 5614622812f47-3e6384ce490mr12940877b6e.44.1730303870561; Wed, 30 Oct 2024 08:57:50 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:49 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hyman Huang , Peter Xu Subject: [PULL 08/18] migration: Support periodic RAMBlock dirty bitmap sync Date: Wed, 30 Oct 2024 11:57:24 -0400 Message-ID: <20241030155734.2141398-9-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hyman Huang When VM is configured with huge memory, the current throttle logic doesn't look like to scale, because migration_trigger_throttle() is only called for each iteration, so it won't be invoked for a long time if one iteration can take a long time. The periodic dirty sync aims to fix the above issue by synchronizing the ramblock from remote dirty bitmap and, when necessary, triggering the CPU throttle multiple times during a long iteration. This is a trade-off between synchronization overhead and CPU throttle impact. Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/f61f1b3653f2acf026901103e1c73d157d38b08f.1729146786.git.yong.huang@smartx.com [peterx: make prev_cnt global, and reset for each migration] Signed-off-by: Peter Xu --- migration/cpu-throttle.h | 14 ++++++++ migration/migration.h | 1 + migration/cpu-throttle.c | 70 +++++++++++++++++++++++++++++++++++++++- migration/migration.c | 14 ++++++-- migration/ram.c | 2 +- migration/trace-events | 1 + 6 files changed, 98 insertions(+), 4 deletions(-) diff --git a/migration/cpu-throttle.h b/migration/cpu-throttle.h index d65bdef6d0..420702b8d3 100644 --- a/migration/cpu-throttle.h +++ b/migration/cpu-throttle.h @@ -65,4 +65,18 @@ bool cpu_throttle_active(void); */ int cpu_throttle_get_percentage(void); +/** + * cpu_throttle_dirty_sync_timer_tick: + * + * Dirty sync timer hook. + */ +void cpu_throttle_dirty_sync_timer_tick(void *opaque); + +/** + * cpu_throttle_dirty_sync_timer: + * + * Start or stop the dirty sync timer. + */ +void cpu_throttle_dirty_sync_timer(bool enable); + #endif /* SYSEMU_CPU_THROTTLE_H */ diff --git a/migration/migration.h b/migration/migration.h index b9ce5aa4ff..7dc59c5e8d 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -551,4 +551,5 @@ int migration_rp_wait(MigrationState *s); */ void migration_rp_kick(MigrationState *s); +void migration_bitmap_sync_precopy(bool last_stage); #endif diff --git a/migration/cpu-throttle.c b/migration/cpu-throttle.c index fa47ee2e21..3df287d8d3 100644 --- a/migration/cpu-throttle.c +++ b/migration/cpu-throttle.c @@ -28,16 +28,23 @@ #include "qemu/main-loop.h" #include "sysemu/cpus.h" #include "cpu-throttle.h" +#include "migration.h" +#include "migration-stats.h" #include "trace.h" /* vcpu throttling controls */ -static QEMUTimer *throttle_timer; +static QEMUTimer *throttle_timer, *throttle_dirty_sync_timer; static unsigned int throttle_percentage; +static bool throttle_dirty_sync_timer_active; +static uint64_t throttle_dirty_sync_count_prev; #define CPU_THROTTLE_PCT_MIN 1 #define CPU_THROTTLE_PCT_MAX 99 #define CPU_THROTTLE_TIMESLICE_NS 10000000 +/* Making sure RAMBlock dirty bitmap is synchronized every five seconds */ +#define CPU_THROTTLE_DIRTY_SYNC_TIMESLICE_MS 5000 + static void cpu_throttle_thread(CPUState *cpu, run_on_cpu_data opaque) { double pct; @@ -112,6 +119,7 @@ void cpu_throttle_set(int new_throttle_pct) void cpu_throttle_stop(void) { qatomic_set(&throttle_percentage, 0); + cpu_throttle_dirty_sync_timer(false); } bool cpu_throttle_active(void) @@ -124,8 +132,68 @@ int cpu_throttle_get_percentage(void) return qatomic_read(&throttle_percentage); } +void cpu_throttle_dirty_sync_timer_tick(void *opaque) +{ + uint64_t sync_cnt = stat64_get(&mig_stats.dirty_sync_count); + + /* + * The first iteration copies all memory anyhow and has no + * effect on guest performance, therefore omit it to avoid + * paying extra for the sync penalty. + */ + if (sync_cnt <= 1) { + goto end; + } + + if (sync_cnt == throttle_dirty_sync_count_prev) { + trace_cpu_throttle_dirty_sync(); + WITH_RCU_READ_LOCK_GUARD() { + migration_bitmap_sync_precopy(false); + } + } + +end: + throttle_dirty_sync_count_prev = stat64_get(&mig_stats.dirty_sync_count); + + timer_mod(throttle_dirty_sync_timer, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + + CPU_THROTTLE_DIRTY_SYNC_TIMESLICE_MS); +} + +static bool cpu_throttle_dirty_sync_active(void) +{ + return qatomic_read(&throttle_dirty_sync_timer_active); +} + +void cpu_throttle_dirty_sync_timer(bool enable) +{ + assert(throttle_dirty_sync_timer); + + if (enable) { + if (!cpu_throttle_dirty_sync_active()) { + /* + * Always reset the dirty sync count cache, in case migration + * was cancelled once. + */ + throttle_dirty_sync_count_prev = 0; + timer_mod(throttle_dirty_sync_timer, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + + CPU_THROTTLE_DIRTY_SYNC_TIMESLICE_MS); + qatomic_set(&throttle_dirty_sync_timer_active, 1); + } + } else { + if (cpu_throttle_dirty_sync_active()) { + timer_del(throttle_dirty_sync_timer); + qatomic_set(&throttle_dirty_sync_timer_active, 0); + } + } +} + void cpu_throttle_init(void) { throttle_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, cpu_throttle_timer_tick, NULL); + throttle_dirty_sync_timer = + timer_new_ms(QEMU_CLOCK_VIRTUAL_RT, + cpu_throttle_dirty_sync_timer_tick, NULL); } diff --git a/migration/migration.c b/migration/migration.c index 05c8cd50b4..bcb735869b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3297,12 +3297,17 @@ static MigIterateState migration_iteration_run(MigrationState *s) static void migration_iteration_finish(MigrationState *s) { - /* If we enabled cpu throttling for auto-converge, turn it off. */ + bql_lock(); + + /* + * If we enabled cpu throttling for auto-converge, turn it off. + * Stopping CPU throttle should be serialized by BQL to avoid + * racing for the throttle_dirty_sync_timer. + */ if (migrate_auto_converge()) { cpu_throttle_stop(); } - bql_lock(); switch (s->state) { case MIGRATION_STATUS_COMPLETED: runstate_set(RUN_STATE_POSTMIGRATE); @@ -3520,6 +3525,11 @@ static void *migration_thread(void *opaque) qemu_savevm_send_colo_enable(s->to_dst_file); } + if (migrate_auto_converge()) { + /* Start RAMBlock dirty bitmap sync timer */ + cpu_throttle_dirty_sync_timer(true); + } + bql_lock(); ret = qemu_savevm_state_setup(s->to_dst_file, &local_err); bql_unlock(); diff --git a/migration/ram.c b/migration/ram.c index 9b5b350405..d284f63854 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1088,7 +1088,7 @@ static void migration_bitmap_sync(RAMState *rs, bool last_stage) } } -static void migration_bitmap_sync_precopy(bool last_stage) +void migration_bitmap_sync_precopy(bool last_stage) { Error *local_err = NULL; assert(ram_state); diff --git a/migration/trace-events b/migration/trace-events index 9a19599804..0638183056 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -381,3 +381,4 @@ migration_pagecache_insert(void) "Error allocating page" # cpu-throttle.c cpu_throttle_set(int new_throttle_pct) "set guest CPU throttled by %d%%" +cpu_throttle_dirty_sync(void) "" From patchwork Wed Oct 30 15:57:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09C39D5B86D for ; Wed, 30 Oct 2024 15:59:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5A-0003bh-PO; Wed, 30 Oct 2024 11:58: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 1t6B54-0003aS-Hz for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57: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 1t6B52-0007nM-Sc for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303876; 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=D04sswxuA64dl9ZML7ycu/fX/0EMcgaz7cJ3EQ22hfI=; b=T5eblZPkCxqLCgD/JZ28CKQhfeEFM+7N8WdxinQRRmLPLlwS9YhbxvBO2+Kv3U9YoN3MTC H8vWR17DzJahF3u1kumkow8wrm9Ul0huRq5QtPpB6sB7KonYD7f0XMydlS2mwYXptXNMGZ +sxnBZJsB1RIf9xWZQKHlof0oBTNX/Q= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-_JZ0IR-pO1O5gxBQvdI4Fw-1; Wed, 30 Oct 2024 11:57:53 -0400 X-MC-Unique: _JZ0IR-pO1O5gxBQvdI4Fw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6cbed928402so84811836d6.2 for ; Wed, 30 Oct 2024 08:57:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303872; x=1730908672; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D04sswxuA64dl9ZML7ycu/fX/0EMcgaz7cJ3EQ22hfI=; b=ASdAciRRy7zlE1bF5ahAaUeQUA8drNN6bU9neuWDkPI2vd/WBeN78w46lmKkZsN8pZ DeyizoNwllO31UoBeRg2GDg5r6cXS34+mA4us48Mkru4UOIIB2j1iMD8U7WNl0831Dak GXgCpc16ZpNgarorcTLh7qzpC0e7MifEmuMzMTBHNnVO4HemsXdHKERoRF//143snEyz 3RnlGLOYGwX5ZIr9joGGzv7RmEbxKrrpeSR1yMBM28idzYbtuQvtgbiWowu7kJWHn7gV 1VsOiP3Xhw13082BausA8gpYN5uFrfcrBJo8z9COwWIoKyFICmCGNRln4DhxgD1at+bX C4EQ== X-Gm-Message-State: AOJu0YyuHIQOolGov3uxHKlPMXY3vpd/QeHsrSvxahey+8UvPTZzW7Yx 22oPcbtFR5UH2Bb3szavMe9inphxqwLIWflBlpJZvgbiHG5bnVulcO+FkyBmR8keQqqboyZrtgC DzMzPieqDLu7FMsuU+7upUj1UOXOZUySP28K7QHO/AyCr6IrlsMLn/vvwWRN+Fg+MjMYNszpXRH GMZpHLI1OtaHUNOy/ZjBXXhTcSyuZOjCM6Ag== X-Received: by 2002:a05:6214:2f01:b0:6cc:4136:205 with SMTP id 6a1803df08f44-6d1856f3f3cmr326332626d6.26.1730303872641; Wed, 30 Oct 2024 08:57:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZyOG+p6mdeNoMIurYOPKldNYJffEmFXjA6H0JYnamYdreGP9Rd3uz+LSqS+FZ0V8YZefCOw== X-Received: by 2002:a05:6214:2f01:b0:6cc:4136:205 with SMTP id 6a1803df08f44-6d1856f3f3cmr326332186d6.26.1730303872168; Wed, 30 Oct 2024 08:57:52 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:51 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Hyman Huang , Peter Xu Subject: [PULL 09/18] tests/migration: Add case for periodic ramblock dirty sync Date: Wed, 30 Oct 2024 11:57:25 -0400 Message-ID: <20241030155734.2141398-10-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hyman Huang Signed-off-by: Hyman Huang Reviewed-by: Peter Xu Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/cb61504f1a1e9d5f2ca4dac12e518deb076ce9f3.1729146786.git.yong.huang@smartx.com Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 95e45b5029..e6a2803e71 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2791,6 +2791,8 @@ static void test_migrate_auto_converge(void) * so we need to decrease a bandwidth. */ const int64_t init_pct = 5, inc_pct = 25, max_pct = 95; + uint64_t prev_dirty_sync_cnt, dirty_sync_cnt; + int max_try_count, hit = 0; if (test_migrate_start(&from, &to, uri, &args)) { return; @@ -2827,6 +2829,36 @@ static void test_migrate_auto_converge(void) } while (true); /* The first percentage of throttling should be at least init_pct */ g_assert_cmpint(percentage, >=, init_pct); + + /* + * End the loop when the dirty sync count greater than 1. + */ + while ((dirty_sync_cnt = get_migration_pass(from)) < 2) { + usleep(1000 * 1000); + } + + prev_dirty_sync_cnt = dirty_sync_cnt; + + /* + * The RAMBlock dirty sync count must changes in 5 seconds, here we set + * the timeout to 10 seconds to ensure it changes. + * + * Note that migrate_ensure_non_converge set the max-bandwidth to 3MB/s, + * while the qtest mem is >= 100MB, one iteration takes at least 33s (100/3) + * to complete; this ensures that the RAMBlock dirty sync occurs. + */ + max_try_count = 10; + while (--max_try_count) { + dirty_sync_cnt = get_migration_pass(from); + if (dirty_sync_cnt != prev_dirty_sync_cnt) { + hit = 1; + break; + } + prev_dirty_sync_cnt = dirty_sync_cnt; + sleep(1); + } + g_assert_cmpint(hit, ==, 1); + /* Now, when we tested that throttling works, let it converge */ migrate_ensure_converge(from); From patchwork Wed Oct 30 15:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D2EFD5CCB9 for ; Wed, 30 Oct 2024 15:59:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5C-0003d1-4O; Wed, 30 Oct 2024 11:58: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 1t6B55-0003au-Js for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:59 -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 1t6B54-0007no-5l for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:57:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303877; 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=XauRfFIHmI+9xXD3oz2X/URcYPURxAnB3bljaFQ+418=; b=TQtHGDGT6QxVFgd+salpTg/31IdEy+EyofNRi4aV0EBml0jt5VqykzRKFfWGPnf7a7I3IT WB6haGXqczPT/l1jC9Y4ZcgeWB5EMNtJxDMpZaEsqSuY3SaSElxJAeUFkc/VjoOzCkrzOY xyhDE/UoPUZvhHpNHzN/9Q4nbt0o8lc= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-LWT9xeeNOA-Tep8P1pnefg-1; Wed, 30 Oct 2024 11:57:55 -0400 X-MC-Unique: LWT9xeeNOA-Tep8P1pnefg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6ce30559894so49776d6.3 for ; Wed, 30 Oct 2024 08:57:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303874; x=1730908674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XauRfFIHmI+9xXD3oz2X/URcYPURxAnB3bljaFQ+418=; b=vwTh95irK7aqNnzdlpZZL5WsU/3NEsCFbeAf+S5Cafekr6V9j8Hal665fYafm1ArRM vkDD48vRggSRvIC1FGHOeR0l1xta6LynIOtkpySBWsXA08PpIJnJTVdPDGLbyV0q9k6L 577vxqk1j2hdyaQ452LgVoZk8qtG3XJ1azzrn2szOsrT2VrU9J0U/rUSfDIsRlqp2aeI F9+1jdn1qUf25tV/cPbLIabS0USXJVHrE7yLxFVIa8miVJGbPTH6sG4Dmv0q3EWFovy7 +UwyYzMutPnJhousvjTQ6ZZmmgjAymCZDkcI0PDH/Mt7OqXCgy5+FFvsorI+4t9ipVXD xAYQ== X-Gm-Message-State: AOJu0YzCST+0wnxq/hESppppHpvNzE32LBKt2G+4+kR8cbr08lU6q1kJ VmULaDErQ0g8FFISeIee097GfNfTq5NUu2KP77zhOxKghy50BIxP62YXmF9WWd8eCch5Xy0mlLE 2/ga20hNg28Pox+wj7wyprhhaalP1wYieJ3zkeqmqDExzWTIQP48iN07oEpRKb6fsvwepg6HnEr ElIg9orSG0bTLyDnmE036PPi78kB1sZ9anHg== X-Received: by 2002:a05:6214:3a84:b0:6d3:447f:db4c with SMTP id 6a1803df08f44-6d3447fe633mr52796036d6.43.1730303874488; Wed, 30 Oct 2024 08:57:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnoqywHpvrLl8Pz1Pyfms3dap5PkftBtddYq6tMt2MCTXCkxDRzED3gPZ2LLhRk5HoccAnKQ== X-Received: by 2002:a05:6214:3a84:b0:6d3:447f:db4c with SMTP id 6a1803df08f44-6d3447fe633mr52795716d6.43.1730303874125; Wed, 30 Oct 2024 08:57:54 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:52 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Thomas Huth , Hyman Huang , Peter Xu Subject: [PULL 10/18] migration/dirtyrate: Silence warning about strcpy() on OpenBSD Date: Wed, 30 Oct 2024 11:57:26 -0400 Message-ID: <20241030155734.2141398-11-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Huth The linker on OpenBSD complains: ld: warning: dirtyrate.c:447 (../src/migration/dirtyrate.c:447)(...): warning: strcpy() is almost always misused, please use strlcpy() It's currently not a real problem in this case since both arrays have the same size (256 bytes). But just in case somebody changes the size of the source array in the future, let's better play safe and use g_strlcpy() here instead, with an additional check that the string has been copied as a whole. Signed-off-by: Thomas Huth Reviewed-by: Hyman Huang Link: https://lore.kernel.org/r/20241022063402.184213-1-thuth@redhat.com [peterx: Fix over-80 chars] Signed-off-by: Peter Xu --- migration/dirtyrate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index a74a6aeb56..f7e86686fc 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -437,6 +437,7 @@ static void get_ramblock_dirty_info(RAMBlock *block, struct DirtyRateConfig *config) { uint64_t sample_pages_per_gigabytes = config->sample_pages_per_gigabytes; + gsize len; /* Right shift 30 bits to calc ramblock size in GB */ info->sample_pages_count = (qemu_ram_get_used_length(block) * @@ -445,7 +446,9 @@ static void get_ramblock_dirty_info(RAMBlock *block, info->ramblock_pages = qemu_ram_get_used_length(block) >> qemu_target_page_bits(); info->ramblock_addr = qemu_ram_get_host_addr(block); - strcpy(info->idstr, qemu_ram_get_idstr(block)); + len = g_strlcpy(info->idstr, qemu_ram_get_idstr(block), + sizeof(info->idstr)); + g_assert(len < sizeof(info->idstr)); } static void free_ramblock_dirty_info(struct RamblockDirtyInfo *infos, int count) From patchwork Wed Oct 30 15:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0095D74950 for ; Wed, 30 Oct 2024 15:59:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5D-0003fR-7v; Wed, 30 Oct 2024 11:58:07 -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 1t6B56-0003b3-KA for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58: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 1t6B54-0007o3-US for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303878; 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=ZsscXx+KMHNJgp5Covv21rQwFJnGP8YdwoqwthrJBqE=; b=DwdyLrYrnTJ50FFgY18fJ49HKOTUNlV4vc4xMEBfFfReBN9wiBNmg+IqKTxjS90T+UJWIs X7irAI15w/A6A4mHXwcfZVTrTNP1eGKENFE90nkD+2hUx1c/rgWpA30YdFYRAUNItKUIKi oeAD59k+njg+KDvXGPNkoBscNIn1Shc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-P_v-HH6ROaCMcy_UNOxemA-1; Wed, 30 Oct 2024 11:57:57 -0400 X-MC-Unique: P_v-HH6ROaCMcy_UNOxemA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6cbec7fbf1cso71916d6.1 for ; Wed, 30 Oct 2024 08:57:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303876; x=1730908676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZsscXx+KMHNJgp5Covv21rQwFJnGP8YdwoqwthrJBqE=; b=Y4JCIMiE/ynkWou7y4gY/xo6C41syyhlMMS6hS1VZwqTD43NQfFHGrerKbi/tV/1Tm vQTgs3iD8i/dR8ISPjXAnPWHN8is5hiV8zNmBXfN4yRCDNemYgDt6PPaUfsjMn4cSbZd ANuU9qTFp6uV3mZqCbCo3TVIhClQevPv1IxLkVVE//hJXM2IxqTcuDGrd8MA847XNuso LIKVuaNWFGMYFHXRZ3ovyEKYBKh5QEK0U/7wlVsavAHjlVtDd1hP/wSMZd/PXc1I0aQh dvLzA4S5V9Twfth0g+HKBwU9nE2MMLyhL9zG0+zM4eBIi9ShLNPvLJ3kQgOcIvmCMvjh XoXQ== X-Gm-Message-State: AOJu0YxZDN8jPV7UYCP8KrLf1fcIzQHKI3S/tZEnBJPGrduqqeT7rD1S E1xoYAcRbIlt0P9RtccvSG0ct43p2r+EKEBZxygpHFdcdrmKa7zMEJc49vFr18OSEO6i4HUXjIS IPGnuqB4EeNHewW5DIouGPPsjexIXSLktaacErSEoIBET/MDpbNs+iS9hMidUr7rtwqN7sbUeK0 nVvsdwsf3070mrlvGv+Otf/evKlT4I37TLtw== X-Received: by 2002:a05:6214:5348:b0:6cb:d583:3765 with SMTP id 6a1803df08f44-6d345facebfmr52347476d6.1.1730303876292; Wed, 30 Oct 2024 08:57:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGV89Lpsp0exTp6uKtGZ47u1ViJp/BVjzdfYkAOc0jCBN2UveNjdDeX5ORPI2MOGxFUo+JNlA== X-Received: by 2002:a05:6214:5348:b0:6cb:d583:3765 with SMTP id 6a1803df08f44-6d345facebfmr52347116d6.1.1730303875899; Wed, 30 Oct 2024 08:57:55 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:54 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , Markus Armbruster Subject: [PULL 11/18] migration: Deprecate query-migrationthreads command Date: Wed, 30 Oct 2024 11:57:27 -0400 Message-ID: <20241030155734.2141398-12-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Per previous discussion [1,2], this patch deprecates query-migrationthreads command. To summarize, the major reason of the deprecation is due to no sensible way to consume the API properly: (1) The reported list of threads are incomplete (ignoring destination threads and non-multifd threads). (2) For CPU pinning, there's no way to properly pin the threads with the API if the threads will start running right away after migration threads can be queried, so the threads will always run on the default cores for a short window. (3) For VM debugging, one can use "-name $VM,debug-threads=on" instead, which will provide proper names for all migration threads. [1] https://lore.kernel.org/r/20240930195837.825728-1-peterx@redhat.com [2] https://lore.kernel.org/r/20241011153417.516715-1-peterx@redhat.com Reviewed-by: Fabiano Rosas Acked-by: Markus Armbruster Link: https://lore.kernel.org/r/20241022194501.1022443-1-peterx@redhat.com Signed-off-by: Peter Xu --- docs/about/deprecated.rst | 8 ++++++++ qapi/migration.json | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index ce38a3d0cf..100ba66fe1 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -147,6 +147,14 @@ options are removed in favor of using explicit ``blockdev-create`` and ``blockdev-add`` calls. See :doc:`/interop/live-block-operations` for details. +``query-migrationthreads`` (since 9.2) +'''''''''''''''''''''''''''''''''''''' + +To be removed with no replacement, as it reports only a limited set of +threads (for example, it only reports source side of multifd threads, +without reporting any destination threads, or non-multifd source threads). +For debugging purpose, please use ``-name $VM,debug-threads=on`` instead. + Incorrectly typed ``device_add`` arguments (since 6.2) '''''''''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/qapi/migration.json b/qapi/migration.json index 3af6aa1740..a605dc26db 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -2284,12 +2284,17 @@ # # Returns information of migration threads # +# Features: +# +# @deprecated: This command is deprecated with no replacement yet. +# # Returns: @MigrationThreadInfo # # Since: 7.2 ## { 'command': 'query-migrationthreads', - 'returns': ['MigrationThreadInfo'] } + 'returns': ['MigrationThreadInfo'], + 'features': ['deprecated'] } ## # @snapshot-save: From patchwork Wed Oct 30 15:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58F1CD5CCB9 for ; Wed, 30 Oct 2024 16:00:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5D-0003h6-B8; Wed, 30 Oct 2024 11:58:07 -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 1t6B5A-0003bp-5P for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58: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 1t6B58-0007od-Bl for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303881; 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=cLfiSEdO7zeQicFYxz5aA6Flw78+vUf5BF/rB2HZ8uE=; b=fxD32OF6DQMt8ac6XUR6qdc+H3iCMaUhO83QIlVqx6tzPo/LHVJ/LYTHZuL9weYG3Nkjcr KEv2ky9Q8/WFNULbv1fwVDs/3An7i2Mal20CgQV+SkNSnvcPcHtxtWkDsAHYjmzTB/Wjip 5eglqBMZqmxx6pifEACxrgVlvE8J7gs= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-9WnRrbLHPciuzWBsv2gFJg-1; Wed, 30 Oct 2024 11:58:00 -0400 X-MC-Unique: 9WnRrbLHPciuzWBsv2gFJg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7b163e0a5ecso1036095685a.1 for ; Wed, 30 Oct 2024 08:57:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303878; x=1730908678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cLfiSEdO7zeQicFYxz5aA6Flw78+vUf5BF/rB2HZ8uE=; b=iTzhXnMF/Dh0fEGj8iyoI6otKgLtBh0/jFF27Fm5g5q/9jo/o4XQUCyldWvOFmfL/P CcCtlR+x/zJ3ecqPvARhmZPz+LTBi/V0azzUZzGXr2RMvoorbUhvar0ZTdoX/Kd35dtZ 0Xp/nSo3HjxZs+KHG1GNH+cvMLvUWtzTiv4g62dNnbTT+PPogRlDG3bhk1esfqqAR7PC VTWx/TchtTQR9i8bWeD6chfYai97O2uH6OT/azo8++umCJ2A6nxxILtByjkOjGWJf4oY 2RYwUAZ8Qrowwk9Z8DpRJaNhUqkP3zguWXKBHu6z9SmClQ9AN6vouXVp9WwTtQcyZtrv 7bfA== X-Gm-Message-State: AOJu0YximiXYEysT/rpDKQdi3KYqRrZB+xmENA9ZUmi9j7LPWSkdPR7n C/HlztAVHmlt5yJ5xB6uDjrMNmVZ3uC5gRu+OpaT/HeVpbuzCEU++hLkiWqqWke3A+WAgMp04kX nrs/8SoDBX5v8NAJ3nYG7Jl8Nylxmzvs64Nfvdtgjhx9Be34DQisYvSHlo57QAKsgaB+h4vSgYz PuiWTOr04gPbyY0WbItEAUlDQUQ2+c7BkjfQ== X-Received: by 2002:a05:6214:3d8f:b0:6cc:41cf:a361 with SMTP id 6a1803df08f44-6d18584fee5mr265291426d6.42.1730303877940; Wed, 30 Oct 2024 08:57:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd0y6ew+0xHx0kyMUV4NyNX7osYVZH+5M6Tc3LWpbf1uzV0roF40RKB2HFvYeFSuVCOPAQGg== X-Received: by 2002:a05:6214:3d8f:b0:6cc:41cf:a361 with SMTP id 6a1803df08f44-6d18584fee5mr265291096d6.42.1730303877542; Wed, 30 Oct 2024 08:57:57 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:56 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 12/18] migration: Take migration object refcount earlier for threads Date: Wed, 30 Oct 2024 11:57:28 -0400 Message-ID: <20241030155734.2141398-13-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Both migration thread or background snapshot thread will take a refcount of the migration object at the entrace of the thread function. That makes sense, because it protects the object from being freed by the main thread in migration_shutdown() later, but it might still race with it if the thread is scheduled too late. Consider the case right after pthread_create() happened, VM shuts down with the object released, but right after that the migration thread finally got created, referencing MigrationState* in the opaque pointer which is already freed. The only 100% safe way to make sure it won't get freed is taking the refcount right before the thread is created, meanwhile when BQL is held. Reviewed-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20241024213056.1395400-2-peterx@redhat.com Signed-off-by: Peter Xu --- migration/migration.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index bcb735869b..de80d64dda 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3488,7 +3488,6 @@ static void *migration_thread(void *opaque) rcu_register_thread(); - object_ref(OBJECT(s)); update_iteration_initial_status(s); if (!multifd_send_setup()) { @@ -3626,7 +3625,6 @@ static void *bg_migration_thread(void *opaque) int ret; rcu_register_thread(); - object_ref(OBJECT(s)); migration_rate_set(RATE_LIMIT_DISABLED); @@ -3838,6 +3836,14 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) } } + /* + * Take a refcount to make sure the migration object won't get freed by + * the main thread already in migration_shutdown(). + * + * The refcount will be released at the end of the thread function. + */ + object_ref(OBJECT(s)); + if (migrate_background_snapshot()) { qemu_thread_create(&s->thread, MIGRATION_THREAD_SNAPSHOT, bg_migration_thread, s, QEMU_THREAD_JOINABLE); From patchwork Wed Oct 30 15:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A98B2D5B872 for ; Wed, 30 Oct 2024 15:59:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5C-0003f6-Mm; Wed, 30 Oct 2024 11:58:07 -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 1t6B5A-0003c0-9p for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58: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 1t6B58-0007oj-RS for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303882; 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=YXAngTXg1wboh7wqy0j68c2KKpEv3hBNCwOU5kZxwrs=; b=eRKhMrMmTuLGFqNvy8fj4LplkCPWlpcPatObWb86C4ue+6A79R/SByVY+A9px/+14w7UWg /6D243q6HwPxh3A1Dn71QG79pnt37wSkECWkAg4jj9UhhHdDkOcAUkrmotOSnq/OJolVzK eiuGplvuxklqsKUWDcb0bIgfMFrPQFs= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-B9z9GOrAPY-D3Hvh4ztJ2g-1; Wed, 30 Oct 2024 11:58:00 -0400 X-MC-Unique: B9z9GOrAPY-D3Hvh4ztJ2g-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6cbf76b01deso61996d6.2 for ; Wed, 30 Oct 2024 08:58:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303879; x=1730908679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YXAngTXg1wboh7wqy0j68c2KKpEv3hBNCwOU5kZxwrs=; b=Oi70MGY6oEH7cUSFfFlgEa13gbSxwoiZoP8Kym7HIMDjJqYRkieHcs+Kac10d63Ctr lowESmm9u+6pxBRvLukSlKcC3/ZoxlmCxPY+RdQbCj4T12G29PM9TmuMoiNaFkuhK2PW Z+lHpSXo4lBdo0mZIYFqWAfy/emPKM9D2QkL2WTCUKlLy37ZBPpetq2wEzG9byoHX+vs uo5UfkbqxMnLg/Az31VKlPZq9y/8emnU80egZZV9gaRSlyeiODRKqyVEc7MDNpbgLBXw LPBDFx4HA8YEKPsz1xsoQ9gq4WsLw4TJ0Ui0e0h+rBhPaW10hlb1u1GXF+JAd+4118ie TWqQ== X-Gm-Message-State: AOJu0YxDaUhWI6mooYnuZ1SWIdPz4dH9bPlhEY0kBYJ1wgyYZ+99lFqD ubtMVIbE4TGmx8SP3/wA04WsyctkZdu0mpxe98Fdlu2RrSIAsCPjZG7x2lnNcjVjxbBdsbQZuMF ThIkeUH6znYmUpR8i5zlB/EBxQEgeNAi1xxXtFwjNC7v48Vps6MCbsVMCNljfAUkOjnquoEMZqy E+1iEmCsWDyzG6m1J+BwUULDlLmWnSVkxIsw== X-Received: by 2002:a05:6214:2dc2:b0:6cc:51f:6c41 with SMTP id 6a1803df08f44-6d18584a22bmr292407506d6.36.1730303879707; Wed, 30 Oct 2024 08:57:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFszfrvspKeBen/IW8J4o0BUw9noNv84Qg6xtuGYieFC3ucmWm+WVfg3kzxJcOR9XWQ3OatZw== X-Received: by 2002:a05:6214:2dc2:b0:6cc:51f:6c41 with SMTP id 6a1803df08f44-6d18584a22bmr292407246d6.36.1730303879375; Wed, 30 Oct 2024 08:57:59 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:57:58 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 13/18] migration: Unexport dirty_bitmap_mig_init() Date: Wed, 30 Oct 2024 11:57:29 -0400 Message-ID: <20241030155734.2141398-14-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It's only used within migration/, so it shouldn't be exported. Reviewed-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20241024213056.1395400-3-peterx@redhat.com Signed-off-by: Peter Xu --- include/migration/misc.h | 3 --- migration/migration.h | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index bfadc5613b..df57be6b5e 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -108,7 +108,4 @@ bool migration_incoming_postcopy_advised(void); /* True if background snapshot is active */ bool migration_in_bg_snapshot(void); -/* migration/block-dirty-bitmap.c */ -void dirty_bitmap_mig_init(void); - #endif diff --git a/migration/migration.h b/migration/migration.h index 7dc59c5e8d..0956e9274b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -552,4 +552,8 @@ int migration_rp_wait(MigrationState *s); void migration_rp_kick(MigrationState *s); void migration_bitmap_sync_precopy(bool last_stage); + +/* migration/block-dirty-bitmap.c */ +void dirty_bitmap_mig_init(void); + #endif From patchwork Wed Oct 30 15:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69AB2D5B86D for ; Wed, 30 Oct 2024 15:59:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5G-0003lv-6Z; Wed, 30 Oct 2024 11:58:10 -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 1t6B5E-0003jr-C8 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58: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 1t6B5D-0007pN-0U for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303885; 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=yT8lUIBKet6fbgptE6xA8GhBp1fdHflDGVquMTNAch4=; b=QX/4hs9lLefTS7kMTc5H2NE790Wb+ARSan6VeGGRPD5aKmNqGfBM67jGlUxwXXaXP6MF5z HUgOLzSZQTXa86fj2Zc+M9ZeC7fukwiA6Mr1TSobGiAUgmZlGnoq2qACNy92buE/UN+Axi vep+4ZXn/pfFyY3StiICAEsr2lqVGl0= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-7ByceYOuNhSLx-DjwpRpBw-1; Wed, 30 Oct 2024 11:58:04 -0400 X-MC-Unique: 7ByceYOuNhSLx-DjwpRpBw-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3e601bc6ddaso6605053b6e.3 for ; Wed, 30 Oct 2024 08:58:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303883; x=1730908683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yT8lUIBKet6fbgptE6xA8GhBp1fdHflDGVquMTNAch4=; b=LFHUtDx0rnIgLvY603/TlRIzHnXMeSfdX8FueywA8jejsHw0u5J8M8RKVNH43tQ+f7 LpctCX2Z7V3s5WbZtzQEcgBsjo5oXBMLiBagQv/COJE12vfzbhdGgYzQD7JxPOws29zu 5zhNlDTCrzlPkTRRTjrI199t/m6e/7zq83mc0GhtPkqkkVmiN988tgQ0Lp3WjYCXyGaE /IdgpsoIUC6rtiB0i+tE3jLJoApcjIVY/SzM/KJRkTeTcRNCjMcSeC64+mPGHlMoSZeN rl/tBXr25r4Fe7uHVX4EPS8MZmicV7G4GuoqXsMP9ukRUAhvMTjLalWKVjYGYmYai9Dv pEqw== X-Gm-Message-State: AOJu0Ywg4k0ltnkdpTWjcL5jCtFGoaFMylwLNxT0JGTkAgqfnG0ndvY0 8M4uQsWRgmkT68pKPRPaiNFN4HsKEyDn7iNOk6562RXWLpU5cchP5BttH19I61GiHYXRTPuxGhK SyQtKb/hcZx5J3oUDYFhz85W6oXhtWt918Prl0OgWuytzVT+4U9VGsckWELRdSO4H3zLeR2kBzf H+sH+3X8VAnYgWGoO2Ef9iVy0OI/sI1XO2nQ== X-Received: by 2002:a05:6808:1812:b0:3e4:d683:c24d with SMTP id 5614622812f47-3e6384cb1aamr13902976b6e.43.1730303881535; Wed, 30 Oct 2024 08:58:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERI0OV8OSpAGe4Y7v6MLFTthvZUkoiUcrFyAkVum4xQPHelymS+o6v8fX6BTYTC+h7wsjXyw== X-Received: by 2002:a05:6808:1812:b0:3e4:d683:c24d with SMTP id 5614622812f47-3e6384cb1aamr13902945b6e.43.1730303881108; Wed, 30 Oct 2024 08:58:01 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:58:00 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 14/18] migration: Unexport ram_mig_init() Date: Wed, 30 Oct 2024 11:57:30 -0400 Message-ID: <20241030155734.2141398-15-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It's only used within migration/. Reviewed-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20241024213056.1395400-4-peterx@redhat.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 - migration/ram.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index df57be6b5e..e8490e3af5 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -39,7 +39,6 @@ void precopy_add_notifier(NotifierWithReturn *n); void precopy_remove_notifier(NotifierWithReturn *n); int precopy_notify(PrecopyNotifyReason reason, Error **errp); -void ram_mig_init(void); void qemu_guest_free_page_hint(void *addr, size_t len); bool migrate_ram_is_ignored(RAMBlock *block); diff --git a/migration/ram.h b/migration/ram.h index bc0318b834..0d1981f888 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -44,6 +44,7 @@ extern XBZRLECacheStats xbzrle_counters; INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else +void ram_mig_init(void); int xbzrle_cache_resize(uint64_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); From patchwork Wed Oct 30 15:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E7E7D6B6A0 for ; Wed, 30 Oct 2024 16:01:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5L-0003pO-7T; Wed, 30 Oct 2024 11:58:15 -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 1t6B5H-0003o4-V5 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:12 -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 1t6B5F-0007q3-5R for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303888; 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=E4oURxNBXBkPRiq9WGmdIdu1uQxGl0jyPp2LNYV0ZBA=; b=MGFpXA/ppNqFK/Ak0BJXOCEB9BdfN7I4UrAkmNV7LpPwjiqgyNLrs0bAHODMpb3SYf/ivq Yt7MfQ4dMtj9Al95CFBDlaieVmhFlQ9bS+OdWuzxSrROmtnjs99vOkrm2LXka2AOCywloJ pd/SIU2uB9IGNal1mMyzYpFH5apeXNw= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-z0MOC_x0PCuQ8WrnbrbbtQ-1; Wed, 30 Oct 2024 11:58:06 -0400 X-MC-Unique: z0MOC_x0PCuQ8WrnbrbbtQ-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cbe4cb4252so63056d6.2 for ; Wed, 30 Oct 2024 08:58:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303885; x=1730908685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4oURxNBXBkPRiq9WGmdIdu1uQxGl0jyPp2LNYV0ZBA=; b=Zpwd2+waQ4k4xwn2SgqC12jcOYrsEyfYgVsHUQkEls8htcJdZm4pLiPMqB4ngzu3NR L6VDjO7TWMCytXuzpayj7hJZWfUmZtw1edUh+JcStk1Qpsxr/1iqDvkBWU7EgdzhsBDK 8J5MXAGHXa+LqG9GcG6T889V8p2KHMxrByw2xw847/HTYoNOFnT5N5oekISQLLZqVHMQ 5van2Pjymoq9QJ2asIZsMWR13Wo3+Lremrsz+XmiGer2weEM3aM99mTMTuwizdEzP44D SPNTwl7m9FpjWt1x1SHKjbyNHtAtjQbu+TGlPGXo7mv5/fYzll729qZCIZeLqduB6r0c TSEQ== X-Gm-Message-State: AOJu0YxVihVX/Bn1qLibe1mekBI2jsdLbGGpLHXgUXMpBraEybmh8rbV 4GBBVtioXYtcINdH9YoEQ1RpxO3x5S+yg7nl4oMJMopu7ExmLYvKqz2xn0qKkOEjpYopcWTTEtC PyUqO3YzKHDESLsYyAg6AH+h6cBivoJlfxLtaqVQyhHFv0+Cc0NhduDhCVNHZjaRTxR2uDsyCk/ 2Bud92F5AyTfePVg1udciRsoL9ku42hnbzSw== X-Received: by 2002:a05:6214:4305:b0:6cb:ff04:655f with SMTP id 6a1803df08f44-6d1856eea23mr190399926d6.22.1730303884224; Wed, 30 Oct 2024 08:58:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGDI1RbKNPifftg1STXFl8wa3OuriAQLyEGLq+Q7HiiTe19QARdxgOPAhrUgbnviWCNKwR2w== X-Received: by 2002:a05:6214:4305:b0:6cb:ff04:655f with SMTP id 6a1803df08f44-6d1856eea23mr190399036d6.22.1730303882365; Wed, 30 Oct 2024 08:58:02 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:58:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 15/18] migration: Drop migration_is_setup_or_active() Date: Wed, 30 Oct 2024 11:57:31 -0400 Message-ID: <20241030155734.2141398-16-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This helper is mostly the same as migration_is_running(), except that one has COLO reported as true, the other has CANCELLING reported as true. Per my past years experience on the state changes, none of them should matter. To make it slightly safer, report both COLO || CANCELLING to be true in migration_is_running(), then drop the other one. We kept the 1st only because the name is simpler, and clear enough. Reviewed-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20241024213056.1395400-5-peterx@redhat.com Signed-off-by: Peter Xu --- include/migration/misc.h | 4 ++-- hw/vfio/common.c | 2 +- migration/migration.c | 35 +++-------------------------------- migration/ram.c | 5 ++--- net/vhost-vdpa.c | 3 +-- 5 files changed, 9 insertions(+), 40 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e8490e3af5..86ef160f19 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -52,11 +52,12 @@ void dump_vmstate_json_to_file(FILE *out_fp); /* migration/migration.c */ void migration_object_init(void); void migration_shutdown(void); + bool migration_is_idle(void); bool migration_is_active(void); bool migration_is_device(void); +bool migration_is_running(void); bool migration_thread_is_self(void); -bool migration_is_setup_or_active(void); typedef enum MigrationEventType { MIG_EVENT_PRECOPY_SETUP, @@ -95,7 +96,6 @@ void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode); void migration_remove_notifier(NotifierWithReturn *notify); -bool migration_is_running(void); void migration_file_set_error(int ret, Error *err); /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 36d0cf6585..dcef44fe55 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -149,7 +149,7 @@ bool vfio_viommu_preset(VFIODevice *vbasedev) static void vfio_set_migration_error(int ret) { - if (migration_is_setup_or_active()) { + if (migration_is_running()) { migration_file_set_error(ret, NULL); } } diff --git a/migration/migration.c b/migration/migration.c index de80d64dda..cab65ba8db 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1113,33 +1113,6 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value) migrate_send_rp_message(mis, MIG_RP_MSG_RESUME_ACK, sizeof(buf), &buf); } -/* - * Return true if we're already in the middle of a migration - * (i.e. any of the active or setup states) - */ -bool migration_is_setup_or_active(void) -{ - MigrationState *s = current_migration; - - switch (s->state) { - case MIGRATION_STATUS_ACTIVE: - case MIGRATION_STATUS_POSTCOPY_ACTIVE: - case MIGRATION_STATUS_POSTCOPY_PAUSED: - case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: - case MIGRATION_STATUS_POSTCOPY_RECOVER: - case MIGRATION_STATUS_SETUP: - case MIGRATION_STATUS_PRE_SWITCHOVER: - case MIGRATION_STATUS_DEVICE: - case MIGRATION_STATUS_WAIT_UNPLUG: - case MIGRATION_STATUS_COLO: - return true; - - default: - return false; - - } -} - bool migration_is_running(void) { MigrationState *s = current_migration; @@ -1155,11 +1128,10 @@ bool migration_is_running(void) case MIGRATION_STATUS_DEVICE: case MIGRATION_STATUS_WAIT_UNPLUG: case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_COLO: return true; - default: return false; - } } @@ -1658,8 +1630,7 @@ bool migration_incoming_postcopy_advised(void) bool migration_in_bg_snapshot(void) { - return migrate_background_snapshot() && - migration_is_setup_or_active(); + return migrate_background_snapshot() && migration_is_running(); } bool migration_is_idle(void) @@ -2332,7 +2303,7 @@ static void *source_return_path_thread(void *opaque) trace_source_return_path_thread_entry(); rcu_register_thread(); - while (migration_is_setup_or_active()) { + while (migration_is_running()) { trace_source_return_path_thread_loop_top(); header_type = qemu_get_be16(rp); diff --git a/migration/ram.c b/migration/ram.c index d284f63854..5646a0b882 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2860,7 +2860,7 @@ void qemu_guest_free_page_hint(void *addr, size_t len) size_t used_len, start, npages; /* This function is currently expected to be used during live migration */ - if (!migration_is_setup_or_active()) { + if (!migration_is_running()) { return; } @@ -3208,8 +3208,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } out: - if (ret >= 0 - && migration_is_setup_or_active()) { + if (ret >= 0 && migration_is_running()) { if (migrate_multifd() && migrate_multifd_flush_after_each_section() && !migrate_mapped_ram()) { ret = multifd_ram_flush_and_sync(); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 46b02c50be..231b45246c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -375,8 +375,7 @@ static int vhost_vdpa_net_data_start(NetClientState *nc) assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); - if (s->always_svq || - migration_is_setup_or_active()) { + if (s->always_svq || migration_is_running()) { v->shadow_vqs_enabled = true; } else { v->shadow_vqs_enabled = false; From patchwork Wed Oct 30 15:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB74CD5B872 for ; Wed, 30 Oct 2024 15:59:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5K-0003og-3b; Wed, 30 Oct 2024 11:58:14 -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 1t6B5F-0003lq-Nx for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58: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 1t6B5D-0007ph-T9 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303887; 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=eEuFCgBxTvksT6iByDhahXGFDYrMUUEVp3vLKzxjgS8=; b=AYQ/0NQjAawfucEv2IkNGmAqIOHEU4j4H9uyCZps5zlSOLNhRcf3rYPDQWqa7F+p2RShC8 vhypOFLodq7Y0EzVqfrh7eXs6lF5uvVQca4EpBpHL8HB+DnL/Hbd3UjajmRNc90LPz+BQh mp1e8Bk2sqnHLBK6pRU3k54HqVrf5Cw= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-FgobQgnBPX2yDodQSkw68w-1; Wed, 30 Oct 2024 11:58:06 -0400 X-MC-Unique: FgobQgnBPX2yDodQSkw68w-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6cdeeb785c8so84836d6.2 for ; Wed, 30 Oct 2024 08:58:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303885; x=1730908685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eEuFCgBxTvksT6iByDhahXGFDYrMUUEVp3vLKzxjgS8=; b=j1UpQ1bKgya8/FVAKhTefMjChfZTYJfdqMyfcN5ZZGDVPAKdNjdkjNts5uvwokubWg MFvcom54LRdRtcQGNX0awf5TvfIKzpiWC4/yPNW76D5B9iNKtYdD/UDTaov09JPdJeuu Wvt49w0FiB/weoWLEuP6jfkU4I05lJCHL2D8A8tp8V7FbKqNj0bW3AwqExLKdN4hRiqQ SGzilHs9H2hG6qVqqf+PIA/sjkgfk+n8+3B5Y605XW65BXQ+5dG71dBwc4RZfzEKyEYi 4rdt3fQTrh9/lKeJaQ430tmuG4weCZcRiwCt5lmTrCi9WZcuFCWU5loEP54VE4ry3dx0 gNRQ== X-Gm-Message-State: AOJu0Yxo9UGmNbBZhHiwYXtHIX9MsWmaVF3YMYlDoNY/clRYJIcnXcA/ cUtA70W/IQ6L+ccj0lB4PMj2kfMjEeiPEoxFJ61T+0qL1NHFz4dth6Kz/8fFrT205BsXClgfsSu O/KRxhwypelI8xK8vJmMWVUCUIJDJpBaRjGeoQIGwVip14+ZdWQAPum8QeRoU0kBctJjpf3e3K+ INJZuPnuUbif+Fxuz4na8fr4X6+B228d1ecQ== X-Received: by 2002:a05:6214:5411:b0:6cb:ee08:d4c1 with SMTP id 6a1803df08f44-6d1856c4a8cmr271025556d6.13.1730303885064; Wed, 30 Oct 2024 08:58:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk5gSrGBUIiTsDaJSjzfnOaaIwNnmO/TG15vPt/ryAgxB6jM3CKl97CDg/ODol3O+GWP2l2A== X-Received: by 2002:a05:6214:5411:b0:6cb:ee08:d4c1 with SMTP id 6a1803df08f44-6d1856c4a8cmr271025216d6.13.1730303884570; Wed, 30 Oct 2024 08:58:04 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:58:03 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 16/18] migration: Drop migration_is_idle() Date: Wed, 30 Oct 2024 11:57:32 -0400 Message-ID: <20241030155734.2141398-17-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now with the current migration_is_running(), it will report exactly the opposite of what will be reported by migration_is_idle(). Drop migration_is_idle(), instead use "!migration_is_running()" which should be identical on functionality. In reality, most of the idle check is inverted, so it's even easier to write with "migrate_is_running()" check. Reviewed-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20241024213056.1395400-6-peterx@redhat.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 - hw/virtio/virtio-mem.c | 2 +- migration/migration.c | 21 +-------------------- migration/ram.c | 2 +- system/qdev-monitor.c | 4 ++-- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 86ef160f19..804eb23c06 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -53,7 +53,6 @@ void dump_vmstate_json_to_file(FILE *out_fp); void migration_object_init(void); void migration_shutdown(void); -bool migration_is_idle(void); bool migration_is_active(void); bool migration_is_device(void); bool migration_is_running(void); diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index ae1e81d7ba..80ada89551 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -188,7 +188,7 @@ static bool virtio_mem_is_busy(void) * after plugging them) until we're running on the destination (as we didn't * migrate these blocks when they were unplugged). */ - return migration_in_incoming_postcopy() || !migration_is_idle(); + return migration_in_incoming_postcopy() || migration_is_running(); } typedef int (*virtio_mem_range_cb)(VirtIOMEM *vmem, void *arg, diff --git a/migration/migration.c b/migration/migration.c index cab65ba8db..04d7e67897 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1633,25 +1633,6 @@ bool migration_in_bg_snapshot(void) return migrate_background_snapshot() && migration_is_running(); } -bool migration_is_idle(void) -{ - MigrationState *s = current_migration; - - if (!s) { - return true; - } - - switch (s->state) { - case MIGRATION_STATUS_NONE: - case MIGRATION_STATUS_CANCELLED: - case MIGRATION_STATUS_COMPLETED: - case MIGRATION_STATUS_FAILED: - return true; - default: - return false; - } -} - bool migration_is_active(void) { MigrationState *s = current_migration; @@ -1730,7 +1711,7 @@ static bool is_busy(Error **reasonp, Error **errp) ERRP_GUARD(); /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too. */ - if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) { + if (runstate_check(RUN_STATE_SAVE_VM) || migration_is_running()) { error_propagate_prepend(errp, *reasonp, "disallowing migration blocker " "(migration/snapshot in progress) for: "); diff --git a/migration/ram.c b/migration/ram.c index 5646a0b882..504b48d584 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4498,7 +4498,7 @@ static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host, return; } - if (!migration_is_idle()) { + if (migration_is_running()) { /* * Precopy code on the source cannot deal with the size of RAM blocks * changing at random points in time - especially after sending the diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 44994ea0e1..320c47b72d 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -679,7 +679,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, return NULL; } - if (!migration_is_idle()) { + if (migration_is_running()) { error_setg(errp, "device_add not allowed while migrating"); return NULL; } @@ -928,7 +928,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) return; } - if (!migration_is_idle() && !dev->allow_unplug_during_migration) { + if (migration_is_running() && !dev->allow_unplug_during_migration) { error_setg(errp, "device_del not allowed while migrating"); return; } From patchwork Wed Oct 30 15:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FAE6D6B6A1 for ; Wed, 30 Oct 2024 16:01:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5L-0003p4-25; Wed, 30 Oct 2024 11:58:15 -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 1t6B5H-0003o5-VQ for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:12 -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 1t6B5G-0007qH-2G for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303889; 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=2azfgrHGWZXFInBw3IGghM+a5xX+aBe1mBdMjVZb6pQ=; b=gJvrNjm01XYdJigX2ubTV42suZms3233CZUgUTDRaiBdk6wckVjRvBCOgdIRaRpYgNEaCs drQaZSGBBNElb2ASVideOtJA2LOUiz41xTqKNPhyOGEsCgIf+EPusMoiRokDJy5V7NT5bF EXI8wug1SoYyXkZT7H2rhKKeI8xLvWo= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-15iv24NzPUGKwcuEuzrCKA-1; Wed, 30 Oct 2024 11:58:08 -0400 X-MC-Unique: 15iv24NzPUGKwcuEuzrCKA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cdeed5a061so97961766d6.3 for ; Wed, 30 Oct 2024 08:58:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303887; x=1730908687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2azfgrHGWZXFInBw3IGghM+a5xX+aBe1mBdMjVZb6pQ=; b=mOBFsBLq9txngJoFkcQltJmMBKZ8yXBHwgBKUqauCOhcEHcsrQYr+RdgrKSd6EPVJi XbMN1VX5tTk98RjPRllso0ATCrhiH4ECfkvVHxngR2lkJEIgIQ5a3a9UX+Hc8Bx5BYe9 bHDPsOt2Z/RoBWixsHqXPueMLKFJ1ndnNl6geJTZcsodiSaySUJ86AwgBms7MUW2KLVH riW1U+Zt2F6FxAeIDX0BqGFlKo57GuJeyr9TLj7xGOUsiNTLKE9b+ZT9eF32L1Elfn1d d0LmbMneQteeHTtpnhjrKE1/B1Knz2bnbKLmItdgyKxwnd40JlKzUofghtKSqnmhGuxT OsiQ== X-Gm-Message-State: AOJu0Yw4lB136y2erWrzg60Oa+XEQJuP/P/K8n6Cuh2TQtON5KHEdXYk 9gUygw5OvjEGyIbJQoY85MJfYVC91rs9FwrHpnbPKh6DTtqCVUqih+0Dh5KDF6NNk2fIJ1Wa3aE WeNHPaR6iTCdY2tI/DJc06FACqYGLTnUMiH0gR8N3tuRplenBGeSjyHlKNUFPhEtoWpPQdrOv46 f2jNlbzNnh13P2XF4yBv1VZEjqtqHT/b9i/g== X-Received: by 2002:a05:6214:4411:b0:6ce:26d0:c7af with SMTP id 6a1803df08f44-6d18571761emr180022706d6.31.1730303887212; Wed, 30 Oct 2024 08:58:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW2MNWZEqv4BU6M3I56hGMzOsfrW22HsHDYq01ihZkDo8Hu20mkIUmZu+0fbvY83duhvDyTw== X-Received: by 2002:a05:6214:4411:b0:6ce:26d0:c7af with SMTP id 6a1803df08f44-6d18571761emr180022456d6.31.1730303886841; Wed, 30 Oct 2024 08:58:06 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:58:05 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , "Maciej S. Szmigiero" , Peter Xu Subject: [PULL 17/18] migration/ram: Add load start trace event Date: Wed, 30 Oct 2024 11:57:33 -0400 Message-ID: <20241030155734.2141398-18-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Maciej S. Szmigiero" There's a RAM load complete trace event but there wasn't its start equivalent. Signed-off-by: Maciej S. Szmigiero Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/94ddfa7ecb83a78f73b82867dd30c8767592d257.1730203967.git.maciej.szmigiero@oracle.com Signed-off-by: Peter Xu --- migration/ram.c | 1 + migration/trace-events | 1 + 2 files changed, 2 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 504b48d584..12031df4e5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4294,6 +4294,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) * it will be necessary to reduce the granularity of this * critical section. */ + trace_ram_load_start(); WITH_RCU_READ_LOCK_GUARD() { if (postcopy_running) { /* diff --git a/migration/trace-events b/migration/trace-events index 0638183056..bb0e0cc6dc 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -115,6 +115,7 @@ colo_flush_ram_cache_end(void) "" save_xbzrle_page_skipping(void) "" save_xbzrle_page_overflow(void) "" ram_save_iterate_big_wait(uint64_t milliconds, int iterations) "big wait: %" PRIu64 " milliseconds, %d iterations" +ram_load_start(void) "" ram_load_complete(int ret, uint64_t seq_iter) "exit_code %d seq iteration %" PRIu64 ram_write_tracking_ramblock_start(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu" ram_write_tracking_ramblock_stop(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu" From patchwork Wed Oct 30 15:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13856799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 488C2D5B86D for ; Wed, 30 Oct 2024 15:59:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5N-0003qC-6N; Wed, 30 Oct 2024 11:58:17 -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 1t6B5L-0003pB-3G for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:15 -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 1t6B5J-0007qh-EV for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303891; 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=C9NKSka6dUxxXzhi8guhu9YpXYcj6P64i1DB2FeeVAk=; b=Ztjq21nZdthoAb5Ry4LyXwweEVtXti1HqvqgXLovS4riJ/KORtYsTPVsUc0wVu/XgD+WYv t5i3UiCIAu03kZANTcUifHySOar720prosZOytNTv4moax/ZV8KFjZLWV7Zxqv+G0KWqTs vf8YDCQDlDFXNRkw8qpjqKek71bu8mI= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-jo27UzoDMvSxr320icYp_w-1; Wed, 30 Oct 2024 11:58:10 -0400 X-MC-Unique: jo27UzoDMvSxr320icYp_w-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cbf039dccfso289076d6.0 for ; Wed, 30 Oct 2024 08:58:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303889; x=1730908689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C9NKSka6dUxxXzhi8guhu9YpXYcj6P64i1DB2FeeVAk=; b=ipPeO5PvcSbKVB89Dcf2CiWDpgi26uTskx+UQ2eKGWE43h+lgAD/5DLclhJyIfQHtB +jBdTd+aX3wVjHoGchH3isR5ICu9XPcrcE9Ui58j3a8TAKKcM2ow9/fL93iKngOrLGtW ijwYm1uroDTqp0Y0L41hUkmjkoyxklGOYRt1kyAWtht/cftKqC9enkpVWHtw9n46iuPs a1A3PDRwpfv4A1TKDvaWSMvazSazeEQz1p/UsqWigsftQXyDfztZDhLy6/uPdj7m7HRk VJU+BCaGnv/IdHN4GI7a6VWbkDGeUn1WX0FBIlfZ9pgtrNXKG9kQehgBQhakP/+nzqqQ aBsw== X-Gm-Message-State: AOJu0YzwsfKb3sdl99SMeHEnZIottij0jFkZRvH0oDm6ayPlkFJXnkXY GqeAR/uTpDO6pk5B8EKkwhdU5Wq9ImNGZUmpSb1sRfB0RYQOB/mfCs0eeUxRo+jgEe2Ok86E3D+ lgvhS5U0sdFECD9P8twJK2SxYTo4j5jiRqk57LJnhJEW7u7oMWHp+3K5wn5kivpyRhSIXpSR8g7 e/GlBzeOAhOyGArBRIzCEKDh0jfWeALy/6fA== X-Received: by 2002:a05:6214:2d48:b0:6cc:42d:bb6 with SMTP id 6a1803df08f44-6d1856bb1bdmr229407766d6.16.1730303889090; Wed, 30 Oct 2024 08:58:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPcJaRcuMSCmloCCup7Rd8Vz8bxa6WrauP/xuwP0iAMbkbEeTcOOj5HIHfocZotB4FLvJ9Cw== X-Received: by 2002:a05:6214:2d48:b0:6cc:42d:bb6 with SMTP id 6a1803df08f44-6d1856bb1bdmr229407456d6.16.1730303888713; Wed, 30 Oct 2024 08:58:08 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:58:07 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , "Maciej S. Szmigiero" , Peter Xu Subject: [PULL 18/18] migration/multifd: Zero p->flags before starting filling a packet Date: Wed, 30 Oct 2024 11:57:34 -0400 Message-ID: <20241030155734.2141398-19-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: "Maciej S. Szmigiero" This way there aren't stale flags there. p->flags can't contain SYNC to be sent at the next RAM packet since syncs are now handled separately in multifd_send_thread. Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Signed-off-by: Maciej S. Szmigiero Link: https://lore.kernel.org/r/1c96b6cdb797e6f035eb1a4ad9bfc24f4c7f5df8.1730203967.git.maciej.szmigiero@oracle.com Signed-off-by: Peter Xu --- migration/multifd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/multifd.c b/migration/multifd.c index 697fe86fdf..4374e14a96 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -600,6 +600,7 @@ static void *multifd_send_thread(void *opaque) * qatomic_store_release() in multifd_send(). */ if (qatomic_load_acquire(&p->pending_job)) { + p->flags = 0; p->iovs_num = 0; assert(!multifd_payload_empty(p->data)); @@ -651,7 +652,6 @@ static void *multifd_send_thread(void *opaque) } /* p->next_packet_size will always be zero for a SYNC packet */ stat64_add(&mig_stats.multifd_bytes, p->packet_len); - p->flags = 0; } qatomic_set(&p->pending_sync, false);