From patchwork Mon Mar 11 21:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589364 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 A5F0AC54E58 for ; Mon, 11 Mar 2024 22:03:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngG-0000AG-0R; Mon, 11 Mar 2024 17:59:36 -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 1rjngE-00009q-Kn for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:34 -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 1rjngB-0003xS-UX for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194371; 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=jw41KY+8uC9noF71Dt+JCbXCA+1c3J79mVTzi6ld/Go=; b=CJyPON0hZCSgAmRV7F8B2Andq4uIizRkRY83HEa96TUOJlztCKO1eb9QUSXzJrtvHZnYq+ fZocGElDoIMyMit12Xvu2iB3oGzU9QnNipNaPSpvgbuzB/9PVzjkO59/KBM+shCi+r9T4d 8lS6f0yC0d2hOWmUL+xbfB9ctKq0QFo= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-228-XnCpQiNFNgeJGX9n1SoPJg-1; Mon, 11 Mar 2024 17:59:30 -0400 X-MC-Unique: XnCpQiNFNgeJGX9n1SoPJg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-42f30752eb4so14718431cf.1 for ; Mon, 11 Mar 2024 14:59:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194369; x=1710799169; 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=jw41KY+8uC9noF71Dt+JCbXCA+1c3J79mVTzi6ld/Go=; b=ZlkbBvQvBJp7rjP8fJhe5Y0i5Pg9LMpbJv8YEus3363XgoCQDjq7AIZBWnyNAubaDc jhvmswv7RgMnT4346NdV5L/nwnZqj5Obal6uj5np8pIExq9He7xoYDIjwFJxKXKpfObp EC2BHZgAoYuHMiueBRlZOIqr+1tv62EEfZVWEI+akoggsBF9awOA4+VZWaZR4HKSbA2f bFHt84jIWgw+fqjTv7MbfHvu5FUHcLTd/SqSey2VpspWqSg/yhYbP0mDf8s/2IbesW3U Nj8Dp1b744hTlpUAfWjG1JU1fXQfW8jq/xVGgZDiLajIM/4AHBTwI8StVwRX5GDZiGYo FPwQ== X-Gm-Message-State: AOJu0YyS7E6cDVunPEEVj+53EEeAwSF0kHPNW5zMAkyNFpk3OtFv8lpu npYsBgvpGocV6oChfc2gruD44ugbuvw0ckER51n1tq0pdwQwGGLJsinpgk/Y0wtt0CgWVaj7J24 WqVbCxzIAS2xP/ofSgUI682/yThvRdcoOxDqZeKvklrSzmNdMkfh8BO7Ji+q1XHUOKX7JMBhqUe i72lPohgYrAK1dowqh5epvBJs79dQ/+UwwUQ== X-Received: by 2002:a05:622a:1aa6:b0:42e:f7aa:834f with SMTP id s38-20020a05622a1aa600b0042ef7aa834fmr9939863qtc.0.1710194369278; Mon, 11 Mar 2024 14:59:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFck49NC9NEODTXKIL/BjC6AljEr9ux2q/N4yBgMcaansN8+EXXhmxyU28U6E4f87DDuvogeQ== X-Received: by 2002:a05:622a:1aa6:b0:42e:f7aa:834f with SMTP id s38-20020a05622a1aa600b0042ef7aa834fmr9939842qtc.0.1710194368788; Mon, 11 Mar 2024 14:59:28 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:28 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Avihai Horon Subject: [PULL 01/34] migration: Don't serialize devices in qemu_savevm_state_iterate() Date: Mon, 11 Mar 2024 17:58:52 -0400 Message-ID: <20240311215925.40618-2-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Avihai Horon Commit 90697be8896c ("live migration: Serialize vmstate saving in stage 2") introduced device serialization in qemu_savevm_state_iterate(). The rationale behind it was to first complete migration of slower changing block devices and only then migrate the RAM, to avoid sending fast changing RAM pages over and over. This commit was added a long time ago, and while it was useful back then, it is not the case anymore: 1. Block migration is deprecated, see commit 66db46ca83b8 ("migration: Deprecate block migration"). 2. Today there are other iterative devices besides RAM and block, such as VFIO, which are registered for migration after RAM. With current serialization behavior, a fast changing device can block other devices from sending their data, which may prevent migration from converging in some cases. The issue described in item 2 was observed in several VFIO migration scenarios with switchover-ack capability enabled, where some workload on the VM prevented RAM from ever reaching a hard zero, thus blocking VFIO initial pre-copy data from being sent. Hence, destination could not ack switchover and migration could not converge. Fix that by not serializing iterative devices in qemu_savevm_state_iterate(). Note that this still doesn't fully prevent device starvation. As correctly pointed out by Peter [1], a fast changing device might constantly consume all allocated bandwidth and block the following devices. However, this scenario is more likely to happen only if max-bandwidth is low. [1] https://lore.kernel.org/qemu-devel/Zd6iw9dBhW6wKNxx@x1n/ Signed-off-by: Avihai Horon Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240304105339.20713-2-avihaih@nvidia.com Signed-off-by: Peter Xu --- migration/savevm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index dc1fb9c0d3..e84b26e1c8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1390,7 +1390,8 @@ int qemu_savevm_state_resume_prepare(MigrationState *s) int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy) { SaveStateEntry *se; - int ret = 1; + bool all_finished = true; + int ret; trace_savevm_state_iterate(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { @@ -1431,16 +1432,12 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy) "%d(%s): %d", se->section_id, se->idstr, ret); qemu_file_set_error(f, ret); - } - if (ret <= 0) { - /* Do not proceed to the next vmstate before this one reported - completion of the current stage. This serializes the migration - and reduces the probability that a faster changing state is - synchronized over and over again. */ - break; + return ret; + } else if (!ret) { + all_finished = false; } } - return ret; + return all_finished; } static bool should_send_vmdesc(void) From patchwork Mon Mar 11 21:58:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589355 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 1A9B8C54E5D for ; Mon, 11 Mar 2024 22: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 1rjngH-0000B9-MW; Mon, 11 Mar 2024 17:59:37 -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 1rjngG-0000AM-2N for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:36 -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 1rjngE-0003xg-2j for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194373; 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=4TJ0h7ZMVfo2zcsyyzL/oW195rR/axwQDT3wJxhwttk=; b=AUc0+x7yMvGEKO70CkvmsfwWCr+bkG28rOor6l8icirOvMjlWBUKkO8kztNOmPOkBrc8XP QFCdmNylz46C7uH/qHrcuThweMTaZk0KzcDZavKVurZIBWyDOFXPS/cKeUqcs/UOaU9sky TQJy35aQi7w93RQcS9rti/35p50owCg= 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-471-wCeX326cOMurQZvGDF7Z_Q-1; Mon, 11 Mar 2024 17:59:31 -0400 X-MC-Unique: wCeX326cOMurQZvGDF7Z_Q-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690becce69eso10936526d6.1 for ; Mon, 11 Mar 2024 14:59:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194371; x=1710799171; 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=4TJ0h7ZMVfo2zcsyyzL/oW195rR/axwQDT3wJxhwttk=; b=NhBlXXT9h/aUejgCM8ZIlwNO6Y9uzC24ZG7QFFaB6LuSnrfm5RYo1/RqTRuJhHHZlQ df1kWZBj4eQe+8reLU4Q47aoWLNhH8zv2obDl+x7r6FowgmFsX+9PqaQjOWjnPAQB2vX NCkRKX72wec2A4iB3tr+WpAlskTc1uWdhPqqlI83Nl+9p7VpzKOGGSSv6F0O25IZLv2b DTw890IUiwxWRO3Lo/5txHFf31zRPEgv5AQHjs864Siz0oAB/RnRIsq66JR8KKAz7BBO fURK7e3RiK6Ya5Uzw76v5Lt6Oz9pqGHZI4Rgg3gXslK/LsOt1sDNERU3LHi9eykDxw5M TB/A== X-Gm-Message-State: AOJu0YxejqTMXD8UvFdo4rH9O7HFnBw/asb8YBUy8StKnD98eKHFMmo6 +n8UEon71ZaAJLT9cZkPOTqlcWXLOIH5aQuu9PI0MDc78UjzbfxgxWs6nhjLHiWdDV3PFXWuLyS 83C/F1YG07nDTrKbIEbmrch/XXRuZqhfrH5NvQ2M2E7cPZBh58OJafI9O7tRFuHBBUD4GIZ6CyK 7pnimzJmRwbwVG9y43Pm1SupA+EHBqdD+Cjg== X-Received: by 2002:a0c:fc10:0:b0:690:b5a9:84f1 with SMTP id z16-20020a0cfc10000000b00690b5a984f1mr7585190qvo.1.1710194370740; Mon, 11 Mar 2024 14:59:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGZ9XVkV0tZBQ1ickch4q5CoKHbNhHKlJ9Blyvyu7wlZIm52bMY6pK7Qr6N9S0JMG1cp2zKw== X-Received: by 2002:a0c:fc10:0:b0:690:b5a9:84f1 with SMTP id z16-20020a0cfc10000000b00690b5a984f1mr7585166qvo.1.1710194370305; Mon, 11 Mar 2024 14:59:30 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:29 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Avihai Horon Subject: [PULL 02/34] vfio/migration: Refactor vfio_save_state() return value Date: Mon, 11 Mar 2024 17:58:53 -0400 Message-ID: <20240311215925.40618-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Avihai Horon Currently, vfio_save_state() returns 1 regardless of whether there is more data to send or not. This was done to prevent a fast changing VFIO device from potentially blocking other devices from sending their data, as qemu_savevm_state_iterate() serialized devices. Now that qemu_savevm_state_iterate() no longer serializes devices, there is no need for that. Refactor vfio_save_state() to return 0 if more data is available and 1 if no more data is available. Signed-off-by: Avihai Horon Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240304105339.20713-3-avihaih@nvidia.com Signed-off-by: Peter Xu --- hw/vfio/migration.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 50140eda87..0af783a589 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -529,11 +529,7 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) trace_vfio_save_iterate(vbasedev->name, migration->precopy_init_size, migration->precopy_dirty_size); - /* - * A VFIO device's pre-copy dirty_bytes is not guaranteed to reach zero. - * Return 1 so following handlers will not be potentially blocked. - */ - return 1; + return !migration->precopy_init_size && !migration->precopy_dirty_size; } static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) From patchwork Mon Mar 11 21:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589377 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 4733AC5475B for ; Mon, 11 Mar 2024 22:07:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngI-0000Bn-Tt; Mon, 11 Mar 2024 17:59:38 -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 1rjngG-0000Ah-Td for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:36 -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 1rjngF-0003xu-BB for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194374; 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=uwyy8rtdLNCpslvbHPqDS/nmA49F1iWnhudQzO3o784=; b=gA+usf2zp6Ce6nXSuSqmlsCV7c0ZTcmk/XHA7EzxPEDivskidnKEA3akfs29m1oV5ooTfW hRAL/yWHnRA84WdltaqphrI4bupzP8sfT8dLxtfPrdUX+koh//gCQP/bUs+C8SXGfBDXP6 bo+w4tDPWRaYDY21SxMedcpmvcRMMQ4= 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-508-Ucrsj4nwMPSON_aTYjAsXg-1; Mon, 11 Mar 2024 17:59:32 -0400 X-MC-Unique: Ucrsj4nwMPSON_aTYjAsXg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6818b8cb840so15026386d6.1 for ; Mon, 11 Mar 2024 14:59:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194372; x=1710799172; 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=uwyy8rtdLNCpslvbHPqDS/nmA49F1iWnhudQzO3o784=; b=LqYqxJCkXdJOaE95wcOEq/DNGAGlPPHDIoL7yr/K0xQ8M9Hl621VNyihkuccCSAakG oz5N3jMm618kxtmJk24jDmHrOTsNOS++TpBObj7M2PsZGty3UR9O/EZoivkXwpbZElC9 BgyGMU2WU62fIbKmBd8Sy4M6JNPj3wRBE4LzOvRcqSBKpYLEVV95vsrilkJan8h8GFnF vdFbcJGxwqmal0MPZsXj1ghUoExRMwVscxg4Ql9gnCHNcaoTVwPXqPycaEJB7auE/USD 1BqHd5x2i4XTXOe9bqp/xpDRJIzAs/Ut+CytIugPYJJgrZmXwtZ/iPSH/uIycePUSc6T +ggQ== X-Gm-Message-State: AOJu0YyaqEjBMnBWl+vVBGFMMSreG9zwP++BpGFlawVQjjWdD47HUsL+ AAyetOVUhZozgq1P5pTlWVORYyoc41qe+o5Egd3EydYIzDC2khEu6jXukPN3JnHaeVC52Q+IQOh 6wQJsbQseIFOm6Rs8+eiaROUuRFuZF7W6IWizsYRFOW6ol7SaV+8xbMq8huLJmyX6vrNp6c5Yaq vvKlHn48sABbGxRRzo80f02+Z1dnlFR/inUg== X-Received: by 2002:a05:6214:b6a:b0:690:ca31:f070 with SMTP id ey10-20020a0562140b6a00b00690ca31f070mr5305036qvb.2.1710194372131; Mon, 11 Mar 2024 14:59:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPtYvRgKglwS5jyZdSISMmu08wk8u4NUN8bEuMHipzZ9gx06K2n7D4LOqq8FHuw65pqRpjDg== X-Received: by 2002:a05:6214:b6a:b0:690:ca31:f070 with SMTP id ey10-20020a0562140b6a00b00690ca31f070mr5305017qvb.2.1710194371727; Mon, 11 Mar 2024 14:59:31 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:31 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Avihai Horon Subject: [PULL 03/34] vfio/migration: Add a note about migration rate limiting Date: Mon, 11 Mar 2024 17:58:54 -0400 Message-ID: <20240311215925.40618-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Avihai Horon VFIO migration buffer size is currently limited to 1MB. Therefore, there is no need to check if migration rate exceeded, as in the worst case it will exceed by only 1MB. However, if the buffer size is later changed to a bigger value, vfio_save_iterate() should enforce migration rate (similar to migration RAM code). Add a note about this in vfio_save_iterate() to serve as a reminder. Suggested-by: Peter Xu Signed-off-by: Avihai Horon Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240304105339.20713-4-avihaih@nvidia.com Signed-off-by: Peter Xu --- hw/vfio/migration.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 0af783a589..f82dcabc49 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -505,6 +505,12 @@ static bool vfio_is_active_iterate(void *opaque) return vfio_device_state_is_precopy(vbasedev); } +/* + * Note about migration rate limiting: VFIO migration buffer size is currently + * limited to 1MB, so there is no need to check if migration rate exceeded (as + * in the worst case it will exceed by 1MB). However, if the buffer size is + * later changed to a bigger value, migration rate should be enforced here. + */ static int vfio_save_iterate(QEMUFile *f, void *opaque) { VFIODevice *vbasedev = opaque; From patchwork Mon Mar 11 21:58:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589359 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 A3B7FC5475B for ; Mon, 11 Mar 2024 22:01:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngJ-0000Bq-4L; Mon, 11 Mar 2024 17:59:39 -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 1rjngH-0000BA-Lj for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:37 -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 1rjngF-0003y8-Tg for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194375; 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=fgD8Hj1BkAhj8rZZ5gxcPG2OyHSFcGpD603UIiwTf/s=; b=ZZEIiedu6TLxiG76RPImfWhwuWVKtzVMmUBWkecjHNHZ3oqKZML49JmyBa1URhvkU5G1eg ktzGYl6agBvyGrGcjN19RboSqWxkSbZPSJgyOy+YTGtcrVFa+zUt0iVc7aFkgJnNs470rO 2NDqaJkLTdCneM+vpz+Xno0xUKq8Ek8= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-10zwMXv3Piy4pF5EbOqIFQ-1; Mon, 11 Mar 2024 17:59:34 -0400 X-MC-Unique: 10zwMXv3Piy4pF5EbOqIFQ-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-7dadf2f724aso283616241.1 for ; Mon, 11 Mar 2024 14:59:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194373; x=1710799173; 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=fgD8Hj1BkAhj8rZZ5gxcPG2OyHSFcGpD603UIiwTf/s=; b=MEpnCZxh0zj8ouIscwrBZSjbsYaU7ewojB/Hn1gP/sF92IaOgn6YC9Z/BnZXUt4R69 scKZUR05B2f+GQzkwo5kUf41AKyp5aUYWX2IafaQUSieKiNus9AcPIykAoKsuOhiVdym BaSGQKyMkwe6O7xU1cFWVDE21D4+4CPdxl5s61T2R8sDYa77h2O3d4c0cSiTPymN++V6 WH/FO8F1h3spdp2knANLdCPPaETgpvRARWS24KDNCxv5o8AMl9B0WRcYryNBlrecQnfh pSZT7ck8GPTI6iIuu53USJofBhFvGdQcEbM1lIrDLrKA6zZRiSEHmwfVV4k+44kBk2Hh TDMg== X-Gm-Message-State: AOJu0YxuE9L0cpWF1c9M0iBwB/4piP8lLOcJvnpQM+/5Y253BVRKaZU6 gFwrp4og/3NVNvHf7WtPdAGN+4UWpGY5E0Z58+1NlMggxvqlWEjUQvLskEXs9nR/m5eFsgrRfXR Kte2xUqj2QJ9nRc3Ruo99N+tOp3kDuvNZCpOxtxQBfj0OD2Ggd0boZDYDQ0EJNwVu80I5kwnjdK KccrdRmGGB52zLpf9SeQnbpJhuQ8Qu8lgKtA== X-Received: by 2002:a05:6102:4187:b0:472:e88d:6839 with SMTP id cd7-20020a056102418700b00472e88d6839mr4628840vsb.3.1710194373568; Mon, 11 Mar 2024 14:59:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbnSImJ380TOrwkmT2l3GIUpyxYn/MMIhuun7lyslKJ+TgvEM6Sn10ZLMcXrpE7YCWdCiK7g== X-Received: by 2002:a05:6102:4187:b0:472:e88d:6839 with SMTP id cd7-20020a056102418700b00472e88d6839mr4628823vsb.3.1710194373097; Mon, 11 Mar 2024 14:59:33 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:32 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Maksim Davydov Subject: [PULL 04/34] migration/ram: add additional check Date: Mon, 11 Mar 2024 17:58:55 -0400 Message-ID: <20240311215925.40618-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Maksim Davydov If a migration stream is broken, the address and flag reading can return zero. Thus, an irrelevant flag error will be returned instead of EIO. It can be fixed by additional check after the reading. Signed-off-by: Maksim Davydov Link: https://lore.kernel.org/r/20240304144203.158477-1-davydov-max@yandex-team.ru Signed-off-by: Peter Xu --- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 003c28e133..2cd936d9ce 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4214,6 +4214,12 @@ static int ram_load_precopy(QEMUFile *f) i++; addr = qemu_get_be64(f); + ret = qemu_file_get_error(f); + if (ret) { + error_report("Getting RAM address failed"); + break; + } + flags = addr & ~TARGET_PAGE_MASK; addr &= TARGET_PAGE_MASK; From patchwork Mon Mar 11 21:58:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589382 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 3FDBBC54E5D for ; Mon, 11 Mar 2024 22:10:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngK-0000CE-9O; Mon, 11 Mar 2024 17:59:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngJ-0000Br-8q for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:39 -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 1rjngH-0003yV-Jv for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194376; 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=+T3rLu53eP93SiwWxcECCKMxAP2DCTkljq+aiGvFxI4=; b=eG4DsXcTzLsvxqRRjuq6qNahxiUlKXP4LwpQOEf4uAVUtlmw9kMeRIyV0lQTF8wvdTZlqu T6WxPo0fx2Hm64J+6Tnn3qKGmuVTaVazlTsY0LppQeysxLYGQVOibgytNlOwa72m7nRQGj mp6FPdzLVPnptU3Eo7sXs27lzrLGPUQ= 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-651-N8TqUTR0PBqkrixC9m3SUw-1; Mon, 11 Mar 2024 17:59:35 -0400 X-MC-Unique: N8TqUTR0PBqkrixC9m3SUw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6818b8cb840so15026526d6.1 for ; Mon, 11 Mar 2024 14:59:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194375; x=1710799175; 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=+T3rLu53eP93SiwWxcECCKMxAP2DCTkljq+aiGvFxI4=; b=A5qlU0MLO1ZTuXzwFve0nY5vnvtW1dcSPWS6PKW7LGUq6eHGfvAPNRrDDsqpdCvyQ5 H/5NorgPJiffJ0+OiAmfCeKrY62zgyGBMsxy8jf+x+VeMFQyhaDakIWUoLdvR1Vplx5t gRifCvntyX1tAulbq0Ud+4V4giRJAGYkoJc1blIfs3LGkmfZ12oGA5Swk3FI65GRdqCU 9FSuSTi8iC+lg9H9U/rptaINEa3CYgXvFj8c9PKyM5ksiJ0iB63iS0I+U4ojQgARW1O1 FJ84G3YB/aN/zBLB3MywM+c0GJrD/PI4xh/9W6MJ2k42YCcnaSM/Nhk/2q9z1YJc3jhy BqJQ== X-Gm-Message-State: AOJu0YyuymR+a5Lnxindr2iDk4vHuKSdbqUQdDwBub7+Vd/VPN9ZIsw+ gnznnPAeECWsjA0SS7mhqfC9eHI+LEy2HmJO/Or3ZMxDNaQNKgBP1jKNF0eNcuSz0GIi2Ej70kc lLUR+sBD3R4oZZAJ78ej2eImwVbY+cGc3NYun1raX9DUhiTzOcIPybDnpf8SqYQ6JrcsEj+C2dS g3yF7Wfqjn21knYKrP+r0M1dTJprY9PaS0uQ== X-Received: by 2002:a05:6214:4c11:b0:690:de72:316f with SMTP id qh17-20020a0562144c1100b00690de72316fmr1714533qvb.1.1710194374883; Mon, 11 Mar 2024 14:59:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFledxb02XIcVimWBw7Swd7/bBA4koJR+YAws4GER3eGEKY5lu/AlbFGVIb99KYWEIsDlC6Aw== X-Received: by 2002:a05:6214:4c11:b0:690:de72:316f with SMTP id qh17-20020a0562144c1100b00690de72316fmr1714509qvb.1.1710194374437; Mon, 11 Mar 2024 14:59:34 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:33 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Subject: [PULL 05/34] migration: Report error when shutdown fails Date: Mon, 11 Mar 2024 17:58:56 -0400 Message-ID: <20240311215925.40618-6-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cédric Le Goater This will help detect issues regarding I/O channels usage. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Xu Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240304122844.1888308-7-clg@redhat.com Signed-off-by: Peter Xu --- migration/qemu-file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index b10c882629..a10882d47f 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -63,6 +63,8 @@ struct QEMUFile { */ int qemu_file_shutdown(QEMUFile *f) { + Error *err = NULL; + /* * We must set qemufile error before the real shutdown(), otherwise * there can be a race window where we thought IO all went though @@ -91,7 +93,8 @@ int qemu_file_shutdown(QEMUFile *f) return -ENOSYS; } - if (qio_channel_shutdown(f->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL) < 0) { + if (qio_channel_shutdown(f->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, &err) < 0) { + error_report_err(err); return -EIO; } From patchwork Mon Mar 11 21:58:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589376 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 DBABCC54E58 for ; Mon, 11 Mar 2024 22:05:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngO-0000GG-19; Mon, 11 Mar 2024 17:59:44 -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 1rjngM-0000FF-JU for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:42 -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 1rjngL-0003yn-0U for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194379; 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=fy9ven1kWN6KIHr7K9n1SATScv4YMRbuKCUFVtbSpwk=; b=UDRLLCI7nhQait1osffc1rclHkoSO7MZKtydZ4+APIukodC2t6y4KCjateQr/RvwE96knN E/O6UrFIWQcYK++PXW4Qi+iYJ7VMx+m4u7yuBCER7h9u2xDNQSTBCYDGj/FkNvWGvHtriV NVbVkCdJuvzDSkMRVBOAhi7xoThEkKw= 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-227-GXyH86IANMe3JBxfUUEzmA-1; Mon, 11 Mar 2024 17:59:36 -0400 X-MC-Unique: GXyH86IANMe3JBxfUUEzmA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690d3f5af86so4505126d6.0 for ; Mon, 11 Mar 2024 14:59:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194376; x=1710799176; 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=fy9ven1kWN6KIHr7K9n1SATScv4YMRbuKCUFVtbSpwk=; b=kDkdi9MsX6Lvyx0yqAkMLU60RldBKVEdzHoRIIKIupmPgh5yiQjccGeIqay+6Ihbv/ O9hQGA0IYGa3Rd6kCzmdco0ivReC7lK+eKfuuGUMWoWZsbDcSrhPhEl1qyzIVYFA0MQZ p13E7cfxVYdGPFLyn/UbcYALvAx4ygnK0jsp1nuE2aePI37ul3D+RE7QWuNwwSoRAi0s nLWCn6BxVksdydZDslHbSuZB4VX8toUfXa3S7/3qGrntH141G2nFtvwEG1wp6p+uu8/Q VGVwh53pk5PKj4WAlbcG5a1SiW2ltWT8jwqFm6iGsJTzj8hBp2ixdDopmOwHznZ2TiMz 5cuw== X-Gm-Message-State: AOJu0YwlJUBGNxDdS1qYYZ71C8HwUT+Ct/HEEsmYTM86uKfmINdOaOuJ 0AIGUEc1QJ/ol7mUqECiltBJ4ctfgJxPR1eabDYuHaamxRkOnkCv2E/tvR/cDfPFaI3Gbk/pmPQ jxF4Ra5xuYENYkro7Acd8/vRZQin6NWVgUg35XQrYZXR7iqUjeZbZyBReNuTgna56Tp8Gnxe9ad 7mRjQoGupj/dnjtEl1GmykzeHbwoiRRfbTlw== X-Received: by 2002:a0c:e141:0:b0:690:a71a:d381 with SMTP id c1-20020a0ce141000000b00690a71ad381mr7862214qvl.6.1710194376148; Mon, 11 Mar 2024 14:59:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJtZGA5BfIepUNIgay/2QytymBVXHAVshBpDfYFXh4F3Q1HqzsO/DJv6DO8nosaVPXVmuDdA== X-Received: by 2002:a0c:e141:0:b0:690:a71a:d381 with SMTP id c1-20020a0ce141000000b00690a71ad381mr7862192qvl.6.1710194375797; Mon, 11 Mar 2024 14:59:35 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:35 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 06/34] migration: Remove SaveStateHandler and LoadStateHandler typedefs Date: Mon, 11 Mar 2024 17:58:57 -0400 Message-ID: <20240311215925.40618-7-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cédric Le Goater They are only used once. Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240304122844.1888308-8-clg@redhat.com Signed-off-by: Peter Xu --- include/migration/register.h | 4 ++-- include/qemu/typedefs.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index 9ab1f79512..2e6a7d766e 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -18,7 +18,7 @@ typedef struct SaveVMHandlers { /* This runs inside the BQL. */ - SaveStateHandler *save_state; + void (*save_state)(QEMUFile *f, void *opaque); /* * save_prepare is called early, even before migration starts, and can be @@ -71,7 +71,7 @@ typedef struct SaveVMHandlers { /* This calculate the exact remaining data to transfer */ void (*state_pending_exact)(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy); - LoadStateHandler *load_state; + int (*load_state)(QEMUFile *f, void *opaque, int version_id); int (*load_setup)(QEMUFile *f, void *opaque); int (*load_cleanup)(void *opaque); /* Called when postcopy migration wants to resume from failure */ diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index a028dba4d0..50c277cf0b 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -151,8 +151,6 @@ typedef struct IRQState *qemu_irq; /* * Function types */ -typedef void SaveStateHandler(QEMUFile *f, void *opaque); -typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); typedef void (*qemu_irq_handler)(void *opaque, int n, int level); #endif /* QEMU_TYPEDEFS_H */ From patchwork Mon Mar 11 21:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589379 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 358A8C5475B for ; Mon, 11 Mar 2024 22:08:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngO-0000HS-NE; Mon, 11 Mar 2024 17:59:44 -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 1rjngN-0000Ff-Cm for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:43 -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 1rjngL-0003ys-0Q for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194380; 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=FTOPAhre4/h24RN4Ps85iFFxvGXIdSpDYg+k8LNyGXk=; b=U+5vpQoKq48hJjvd5FGscmUda9+68N7eNuu9ukIF+nKe6W+Q42L3bF3oSRSqDVZ1ZeeCfx uL0bWJx3hYmyHU5ZTuCuqkyMFvSzgT4FE7QUN3XWNGCnZhKldggww0kNNML7B0HAFNOXRE haP/8sdofKDM64d1QhrIEvYmjnpBQy8= 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-529-xPre58MTM_OvzebphgXQwQ-1; Mon, 11 Mar 2024 17:59:38 -0400 X-MC-Unique: xPre58MTM_OvzebphgXQwQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6818b8cb840so15026776d6.1 for ; Mon, 11 Mar 2024 14:59:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194377; x=1710799177; 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=FTOPAhre4/h24RN4Ps85iFFxvGXIdSpDYg+k8LNyGXk=; b=UrrLcWbCTWJcQ0lJwxkS/xK7lYZureGvOHmlnaba7d4oyZ2MgoUaovHx3/tylDnkvb E/uU+qpYc4xoN9+61hW/63sQr5iFx1nPdjm0xHTX7F3pn2xD8YuUupu2ZVxAQnvVRb5X nQjpkPlYegFErJyceoiabIblXpKcS/AI8mvLoOAJ+Y6cLSvnQ8ZKCCKd3tEWNs5WiPIL yyI+iB0NBlFvC4bWyBt7tY8tyP0tZTzv/3WTq6OkdSldK2QgQCp9ndS7A6AfUEnyhEpE 8x14vqes9RGfshEj5tAf0Apu5ZsUZUSvNSjPxQBMr4cttJhRiHtJa8pyCc//R4B4Z+TQ 6Nlw== X-Gm-Message-State: AOJu0YyjK1dBf/fr+v5g/7fNkDA67LH7SBBWYFrx/MDEAfVW2FpHDXEL pjQJBMu+j+HtsxsIMYWVCMIhtii7AyJwWl5xn8xUNvMQDbKvgMCcfm8JeV3BesBu/+ievNtpxZA jjuMJZyqu/6Cwm0Y3SYRm870bBD+QaxA7kBMg8oPZK881kgLiO3aNwOoP0ljjbQqCpHuXFmoDo2 7GYioPeQ8QQYxbZRVr3zIyHvBjL+ZBq48zvQ== X-Received: by 2002:a05:6214:4c11:b0:690:de72:316f with SMTP id qh17-20020a0562144c1100b00690de72316fmr1714606qvb.1.1710194377360; Mon, 11 Mar 2024 14:59:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNtB+2W+/wSVwhrhyjB3itKHPIe5bq0bZXHHJoYBcnKpKOrnoRH9xtHqEjdLSrC2mbDmJcTA== X-Received: by 2002:a05:6214:4c11:b0:690:de72:316f with SMTP id qh17-20020a0562144c1100b00690de72316fmr1714580qvb.1.1710194376873; Mon, 11 Mar 2024 14:59:36 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:36 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 07/34] migration: Add documentation for SaveVMHandlers Date: Mon, 11 Mar 2024 17:58:58 -0400 Message-ID: <20240311215925.40618-8-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cédric Le Goater The SaveVMHandlers structure is still in use for complex subsystems and devices. Document the handlers since we are going to modify a few later. Reviewed-by: Peter Xu Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240304122844.1888308-9-clg@redhat.com Signed-off-by: Peter Xu --- include/migration/register.h | 263 +++++++++++++++++++++++++++++++---- 1 file changed, 237 insertions(+), 26 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index 2e6a7d766e..d7b70a8be6 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -16,30 +16,130 @@ #include "hw/vmstate-if.h" +/** + * struct SaveVMHandlers: handler structure to finely control + * migration of complex subsystems and devices, such as RAM, block and + * VFIO. + */ typedef struct SaveVMHandlers { - /* This runs inside the BQL. */ + + /* The following handlers run inside the BQL. */ + + /** + * @save_state + * + * Saves state section on the source using the latest state format + * version. + * + * Legacy method. Should be deprecated when all users are ported + * to VMStateDescription. + * + * @f: QEMUFile where to send the data + * @opaque: data pointer passed to register_savevm_live() + */ void (*save_state)(QEMUFile *f, void *opaque); - /* - * save_prepare is called early, even before migration starts, and can be - * used to perform early checks. + /** + * @save_prepare + * + * Called early, even before migration starts, and can be used to + * perform early checks. + * + * @opaque: data pointer passed to register_savevm_live() + * @errp: pointer to Error*, to store an error if it happens. + * + * Returns zero to indicate success and negative for error */ int (*save_prepare)(void *opaque, Error **errp); + + /** + * @save_setup + * + * Initializes the data structures on the source and transmits + * first section containing information on the device + * + * @f: QEMUFile where to send the data + * @opaque: data pointer passed to register_savevm_live() + * + * Returns zero to indicate success and negative for error + */ int (*save_setup)(QEMUFile *f, void *opaque); + + /** + * @save_cleanup + * + * Uninitializes the data structures on the source + * + * @opaque: data pointer passed to register_savevm_live() + */ void (*save_cleanup)(void *opaque); + + /** + * @save_live_complete_postcopy + * + * Called at the end of postcopy for all postcopyable devices. + * + * @f: QEMUFile where to send the data + * @opaque: data pointer passed to register_savevm_live() + * + * Returns zero to indicate success and negative for error + */ int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); + + /** + * @save_live_complete_precopy + * + * Transmits the last section for the device containing any + * remaining data at the end of a precopy phase. When postcopy is + * enabled, devices that support postcopy will skip this step, + * where the final data will be flushed at the end of postcopy via + * @save_live_complete_postcopy instead. + * + * @f: QEMUFile where to send the data + * @opaque: data pointer passed to register_savevm_live() + * + * Returns zero to indicate success and negative for error + */ int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); /* This runs both outside and inside the BQL. */ + + /** + * @is_active + * + * Will skip a state section if not active + * + * @opaque: data pointer passed to register_savevm_live() + * + * Returns true if state section is active else false + */ bool (*is_active)(void *opaque); + + /** + * @has_postcopy + * + * Checks if a device supports postcopy + * + * @opaque: data pointer passed to register_savevm_live() + * + * Returns true for postcopy support else false + */ bool (*has_postcopy)(void *opaque); - /* is_active_iterate - * If it is not NULL then qemu_savevm_state_iterate will skip iteration if - * it returns false. For example, it is needed for only-postcopy-states, - * which needs to be handled by qemu_savevm_state_setup and - * qemu_savevm_state_pending, but do not need iterations until not in - * postcopy stage. + /** + * @is_active_iterate + * + * As #SaveVMHandlers.is_active(), will skip an inactive state + * section in qemu_savevm_state_iterate. + * + * For example, it is needed for only-postcopy-states, which needs + * to be handled by qemu_savevm_state_setup() and + * qemu_savevm_state_pending(), but do not need iterations until + * not in postcopy stage. + * + * @opaque: data pointer passed to register_savevm_live() + * + * Returns true if state section is active else false */ bool (*is_active_iterate)(void *opaque); @@ -48,44 +148,155 @@ typedef struct SaveVMHandlers { * use data that is local to the migration thread or protected * by other locks. */ + + /** + * @save_live_iterate + * + * Should send a chunk of data until the point that stream + * bandwidth limits tell it to stop. Each call generates one + * section. + * + * @f: QEMUFile where to send the data + * @opaque: data pointer passed to register_savevm_live() + * + * Returns 0 to indicate that there is still more data to send, + * 1 that there is no more data to send and + * negative to indicate an error. + */ int (*save_live_iterate)(QEMUFile *f, void *opaque); /* This runs outside the BQL! */ - /* Note for save_live_pending: - * must_precopy: - * - must be migrated in precopy or in stopped state - * - i.e. must be migrated before target start - * - * can_postcopy: - * - can migrate in postcopy or in stopped state - * - i.e. can migrate after target start - * - some can also be migrated during precopy (RAM) - * - some must be migrated after source stops (block-dirty-bitmap) - * - * Sum of can_postcopy and must_postcopy is the whole amount of + + /** + * @state_pending_estimate + * + * This estimates the remaining data to transfer + * + * Sum of @can_postcopy and @must_postcopy is the whole amount of * pending data. + * + * @opaque: data pointer passed to register_savevm_live() + * @must_precopy: amount of data that must be migrated in precopy + * or in stopped state, i.e. that must be migrated + * before target start. + * @can_postcopy: amount of data that can be migrated in postcopy + * or in stopped state, i.e. after target start. + * Some can also be migrated during precopy (RAM). + * Some must be migrated after source stops + * (block-dirty-bitmap) */ - /* This estimates the remaining data to transfer */ void (*state_pending_estimate)(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy); - /* This calculate the exact remaining data to transfer */ + + /** + * @state_pending_exact + * + * This calculates the exact remaining data to transfer + * + * Sum of @can_postcopy and @must_postcopy is the whole amount of + * pending data. + * + * @opaque: data pointer passed to register_savevm_live() + * @must_precopy: amount of data that must be migrated in precopy + * or in stopped state, i.e. that must be migrated + * before target start. + * @can_postcopy: amount of data that can be migrated in postcopy + * or in stopped state, i.e. after target start. + * Some can also be migrated during precopy (RAM). + * Some must be migrated after source stops + * (block-dirty-bitmap) + */ void (*state_pending_exact)(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy); + + /** + * @load_state + * + * Load sections generated by any of the save functions that + * generate sections. + * + * Legacy method. Should be deprecated when all users are ported + * to VMStateDescription. + * + * @f: QEMUFile where to receive the data + * @opaque: data pointer passed to register_savevm_live() + * @version_id: the maximum version_id supported + * + * Returns zero to indicate success and negative for error + */ int (*load_state)(QEMUFile *f, void *opaque, int version_id); + + /** + * @load_setup + * + * Initializes the data structures on the destination. + * + * @f: QEMUFile where to receive the data + * @opaque: data pointer passed to register_savevm_live() + * + * Returns zero to indicate success and negative for error + */ int (*load_setup)(QEMUFile *f, void *opaque); + + /** + * @load_cleanup + * + * Uninitializes the data structures on the destination. + * + * @opaque: data pointer passed to register_savevm_live() + * + * Returns zero to indicate success and negative for error + */ int (*load_cleanup)(void *opaque); - /* Called when postcopy migration wants to resume from failure */ + + /** + * @resume_prepare + * + * Called when postcopy migration wants to resume from failure + * + * @s: Current migration state + * @opaque: data pointer passed to register_savevm_live() + * + * Returns zero to indicate success and negative for error + */ int (*resume_prepare)(MigrationState *s, void *opaque); - /* Checks if switchover ack should be used. Called only in dest */ + + /** + * @switchover_ack_needed + * + * Checks if switchover ack should be used. Called only on + * destination. + * + * @opaque: data pointer passed to register_savevm_live() + * + * Returns true if switchover ack should be used and false + * otherwise + */ bool (*switchover_ack_needed)(void *opaque); } SaveVMHandlers; +/** + * register_savevm_live: Register a set of custom migration handlers + * + * @idstr: state section identifier + * @instance_id: instance id + * @version_id: version id supported + * @ops: SaveVMHandlers structure + * @opaque: data pointer passed to SaveVMHandlers handlers + */ int register_savevm_live(const char *idstr, uint32_t instance_id, int version_id, const SaveVMHandlers *ops, void *opaque); +/** + * unregister_savevm: Unregister custom migration handlers + * + * @obj: object associated with state section + * @idstr: state section identifier + * @opaque: data pointer passed to register_savevm_live() + */ void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque); #endif From patchwork Mon Mar 11 21:58:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589357 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 5D73DC54E58 for ; Mon, 11 Mar 2024 22:00:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngQ-0000IW-Us; Mon, 11 Mar 2024 17:59: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 1rjngN-0000GJ-UI for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:43 -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 1rjngL-0003z0-Pc for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194381; 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=qc0i8BnW6Y7BuHtVVuKYvIGbeCP0Ayl8x1jn5Sm+WgI=; b=GkCnBHnj4lkH300jLClTKDkSWnxOTKzr0JH7TRYYVkcH4AbL30Y2i57vqR3kpeKo5rdgT0 gRgRKCb/MQ0RLH5zwXk+imRRnomdDjCtM3wK4gptK/hMpKE6dTkFTXk5e4YDChuRqYK82Z EtNqxfWj6+YQzGG7FmrmLNPjv95UyHM= 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-147-h9wBVvsBOn-BbcloWah00Q-1; Mon, 11 Mar 2024 17:59:39 -0400 X-MC-Unique: h9wBVvsBOn-BbcloWah00Q-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6818b8cb840so15026886d6.1 for ; Mon, 11 Mar 2024 14:59:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194379; x=1710799179; 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=qc0i8BnW6Y7BuHtVVuKYvIGbeCP0Ayl8x1jn5Sm+WgI=; b=OavWQh9fO3HKYiejE6iDsNy71tvxasmFOz0yvXopX3ra/wpGyb74eRCBLDuGlP5jSF z/lFBg8f0llA+yUP58g2tAgbPSr7B5ARWz0UW3h7qlKUHveJT6BjC/+x6b1QrCOS7JNT ImSzXkHIfxIW38AykLnAk7prlHgPzfghtb6p7tiqJncY6e8eAcdG9pGurNRSySoc8ojs GMJnv/oeEc/9AjWPRxlSEpkNjZymBIVazcjohAhU87tiAbPMurcFIOY4EaP7MwiVwP5O vrLsbluyPDgi3FvCYoDo4M97i1ZJwC5fwzZ6iMYlRSyQKZsjID/+tuZhR4B62EIAO3r/ vvZw== X-Gm-Message-State: AOJu0YxO2eU6514lQqtePbO15slaXoIElbsGLYo0OrC+rIWYawpHZLOE PUet13YBQdk6PqzBFcJiIbhbIjbDzInS6bVeiwXT/9imr7XEmgrG4UX8KpJr/11/+Tu2wbQVxCc AYFH9f6DugtTrt/qZdhWfo7ac/pvA8BuEekETAKjdb87VwCaFY6OBIr+Rz6aQZNxIE0AA5WYQup 5I8Odi/HDUZVe/0IQUmfrkMQEBTiaKgdiGOA== X-Received: by 2002:a05:6214:b6a:b0:690:ca31:f070 with SMTP id ey10-20020a0562140b6a00b00690ca31f070mr5305224qvb.2.1710194379066; Mon, 11 Mar 2024 14:59:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOcDHtuVt2rJwLQXQNhTd4XDalzwWJL/qsute3enz3Sd6W1EkaaNsnBWPX7ewIFEZyhdeKEw== X-Received: by 2002:a05:6214:b6a:b0:690:ca31:f070 with SMTP id ey10-20020a0562140b6a00b00690ca31f070mr5305201qvb.2.1710194378502; Mon, 11 Mar 2024 14:59:38 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:37 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 08/34] migration: Do not call PRECOPY_NOTIFY_SETUP notifiers in case of error Date: Mon, 11 Mar 2024 17:58:59 -0400 Message-ID: <20240311215925.40618-9-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cédric Le Goater When commit bd2270608fa0 ("migration/ram.c: add a notifier chain for precopy") added PRECOPY_NOTIFY_SETUP notifiers at the end of qemu_savevm_state_setup(), it didn't take into account a possible error in the loop calling vmstate_save() or .save_setup() handlers. Check ret value before calling the notifiers. Reviewed-by: Peter Xu Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240304122844.1888308-10-clg@redhat.com Signed-off-by: Peter Xu --- migration/savevm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/migration/savevm.c b/migration/savevm.c index e84b26e1c8..76b57a9888 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1317,7 +1317,7 @@ void qemu_savevm_state_setup(QEMUFile *f) MigrationState *ms = migrate_get_current(); SaveStateEntry *se; Error *local_err = NULL; - int ret; + int ret = 0; json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size()); json_writer_start_array(ms->vmdesc, "devices"); @@ -1351,6 +1351,10 @@ void qemu_savevm_state_setup(QEMUFile *f) } } + if (ret) { + return; + } + if (precopy_notify(PRECOPY_NOTIFY_SETUP, &local_err)) { error_report_err(local_err); } From patchwork Mon Mar 11 21:59:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589371 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 113CBC5475B for ; Mon, 11 Mar 2024 22:04:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngS-0000Mu-J8; Mon, 11 Mar 2024 17:59: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 1rjngP-0000Hd-1z for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:45 -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 1rjngN-0003zJ-7e for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194382; 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=0gY4gtbDoA8vveGI24uQ86jfhBn09tzoZ4ceN3ir39E=; b=MDFSlCOQF9z60kA+6Sa9vYaS/9H2CJqxxhi6OfrmrVOql4NpwEN8duaW9A7BFYucAY9Iej 4iTYlS6ydVtwv4XM5OEHY5iW8X6dDXQpYRz7EgBbIVlvKmJLdnEn5xFUEUe3XxRRVvj7/G 9aCD2II327yeyLQlLaZihXr+UKxQ3no= 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-247-_sh9AwjBODunqizGgXGRgw-1; Mon, 11 Mar 2024 17:59:41 -0400 X-MC-Unique: _sh9AwjBODunqizGgXGRgw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-690ca03e758so5295386d6.1 for ; Mon, 11 Mar 2024 14:59:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194380; x=1710799180; 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=0gY4gtbDoA8vveGI24uQ86jfhBn09tzoZ4ceN3ir39E=; b=C8grlHVqWKt9YYmCPzzkG98WipV3389YWRXI6cTAJw5Yub2T9IvMYFzp3gdoUHI7t5 17IKGrw2YnRN9HS/yaeuh94ta4j0eGXzLmsRk950GCkxq3yAeWoQMP27dCb2awJiVs5x 0hd0evfyXIT1UTa7rG9UHgwDqz4jG8KbK5Tg7oM+XDb/kraDpSxRxcFjb/k5mkRsAMrS mtVkwRp7e5Fr7R35sBfnMDWMdnI3oksBnV9Stx1RTJat2NMZuvdzEepWOpMdVvsxVmEL PzmeBQxY8bv8yksT3h6ot6Yzh0FTULM2GbCf6cvJZI7dFZyZXDOsXYf8yTn6NuS7ALSV Q+JA== X-Gm-Message-State: AOJu0Ywl5Tx+R+IdVXnS/UMqtahqfo4a3rAMQeNMnZxZL7+6cdiR1npc vTT2ngUPckYGxNG6slsnd3DqT/yr3V0ruWz/oT01609Pzi3DkC3IXE90j9hIGXt59DhdpsH2wcG m5HCrV9q+ZEuc5yW/YQ10ECnvIqgJCAb4JGvE8SsiumEc1IWA+MHprZz/yulv+vypzD57BKVAW2 iMgBt5slZIrt2pX5luUlJ8vnIz++daVkGyjw== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr136163qvo.3.1710194380647; Mon, 11 Mar 2024 14:59:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEoPP1WYLLpSMeU65gKxwcLLjZB4e+v4jIzD/uZCNUkeigL46BBe4tSeANo//Kh9Dh3b3NyQ== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr136142qvo.3.1710194380149; Mon, 11 Mar 2024 14:59:40 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:39 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 09/34] migration/multifd: Don't fsync when closing QIOChannelFile Date: Mon, 11 Mar 2024 17:59:00 -0400 Message-ID: <20240311215925.40618-10-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fabiano Rosas Commit bc38feddeb ("io: fsync before closing a file channel") added a fsync/fdatasync at the closing point of the QIOChannelFile to ensure integrity of the migration stream in case of QEMU crash. The decision to do the sync at qio_channel_close() was not the best since that function runs in the main thread and the fsync can cause QEMU to hang for several minutes, depending on the migration size and disk speed. To fix the hang, remove the fsync from qio_channel_file_close(). At this moment, the migration code is the only user of the fsync and we're taking the tradeoff of not having a sync at all, leaving the responsibility to the upper layers. Fixes: bc38feddeb ("io: fsync before closing a file channel") Reviewed-by: "Daniel P. Berrangé" Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240305195629.9922-1-farosas@suse.de Link: https://lore.kernel.org/r/20240305174332.2553-1-farosas@suse.de [peterx: add more comment to the qio_channel_close()] Signed-off-by: Peter Xu --- docs/devel/migration/main.rst | 3 ++- io/channel-file.c | 5 ----- migration/multifd.c | 28 +++++++++++++++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 8024275d6d..54385a23e5 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -44,7 +44,8 @@ over any transport. - file migration: do the migration using a file that is passed to QEMU by path. A file offset option is supported to allow a management application to add its own metadata to the start of the file without - QEMU interference. + QEMU interference. Note that QEMU does not flush cached file + data/metadata at the end of migration. In addition, support is included for migration using RDMA, which transports the page data using ``RDMA``, where the hardware takes care of diff --git a/io/channel-file.c b/io/channel-file.c index d4706fa592..a6ad7770c6 100644 --- a/io/channel-file.c +++ b/io/channel-file.c @@ -242,11 +242,6 @@ static int qio_channel_file_close(QIOChannel *ioc, { QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc); - if (qemu_fdatasync(fioc->fd) < 0) { - error_setg_errno(errp, errno, - "Unable to synchronize file data with storage device"); - return -1; - } if (qemu_close(fioc->fd) < 0) { error_setg_errno(errp, errno, "Unable to close file"); diff --git a/migration/multifd.c b/migration/multifd.c index d4a44da559..bf9d483f7a 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -710,16 +710,26 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp) if (p->c) { migration_ioc_unregister_yank(p->c); /* - * An explicit close() on the channel here is normally not - * required, but can be helpful for "file:" iochannels, where it - * will include fdatasync() to make sure the data is flushed to the - * disk backend. + * The object_unref() cannot guarantee the fd will always be + * released because finalize() of the iochannel is only + * triggered on the last reference and it's not guaranteed + * that we always hold the last refcount when reaching here. * - * The object_unref() cannot guarantee that because: (1) finalize() - * of the iochannel is only triggered on the last reference, and - * it's not guaranteed that we always hold the last refcount when - * reaching here, and, (2) even if finalize() is invoked, it only - * does a close(fd) without data flush. + * Closing the fd explicitly has the benefit that if there is any + * registered I/O handler callbacks on such fd, that will get a + * POLLNVAL event and will further trigger the cleanup to finally + * release the IOC. + * + * FIXME: It should logically be guaranteed that all multifd + * channels have no I/O handler callback registered when reaching + * here, because migration thread will wait for all multifd channel + * establishments to complete during setup. Since + * migrate_fd_cleanup() will be scheduled in main thread too, all + * previous callbacks should guarantee to be completed when + * reaching here. See multifd_send_state.channels_created and its + * usage. In the future, we could replace this with an assert + * making sure we're the last reference, or simply drop it if above + * is more clear to be justified. */ qio_channel_close(p->c, &error_abort); object_unref(OBJECT(p->c)); From patchwork Mon Mar 11 21:59:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589367 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 EBA8CC54E5D for ; Mon, 11 Mar 2024 22:04:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngS-0000MY-AI; Mon, 11 Mar 2024 17:59: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 1rjngR-0000Ia-0l for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59: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 1rjngP-0003zk-HN for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194384; 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=WuLmlhgoVqShMS6Vnf3dIC6HEgpMPj5YMMqJlGYRLLc=; b=jN8EGyeSyV/sUKUzPKi0pJoTv06jbL8vxEG+QEtbN14MaTACtS0qkdeGdWNmmiijWNI0By x+QlPwrG0piWWj/nOHo4UXKKndSDUCT1kOdGjJvbCdlON5v2LY/SyI0hj3YaAU5TFYt3Y6 0fYqTnZ0SQwVhJhQYmdgviJP2XptZSY= 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-102-91rwVLG_OSKl7W1GJoTj2Q-1; Mon, 11 Mar 2024 17:59:42 -0400 X-MC-Unique: 91rwVLG_OSKl7W1GJoTj2Q-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690ab2b0de1so15043856d6.0 for ; Mon, 11 Mar 2024 14:59:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194381; x=1710799181; 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=WuLmlhgoVqShMS6Vnf3dIC6HEgpMPj5YMMqJlGYRLLc=; b=LA5TXWkG/PRv4z5a1FU/2JjMqDVdzzW0TqnZB0CCLR2lEGX6MrtDEOh+1S6i0YbiWi 6eyWEMNMsvoSCGAesT258vAebEV2pKjkEPsrt7mqZXgqMN3S3ClR38rmUPswxuunHHzV iADhl/VcIsly767d2FMVcNCDl7KT6HBrfFJ39kuWGWS3iI3OQPRGh5/+m7K62iP3hEX5 oqxPbGX6UQh4roJXXkFZslTFWRUEZF4omWcJbg01DgXY4BhRgGFd/5NnTAR5PTyZnk+l Y0eHpMH/qrS/C5zNF2CWZxKc9sI3zdy7L+oMOY+wFm2lMRsdtqKYFSCmc5QhsSKBHcIE st+w== X-Gm-Message-State: AOJu0YxmIrXvQ38jMQnZ7tMH2YsBxzLGxmTUWItIY9sOwIs3uT5FPs8A dqrXPd7euCrKrd/lk6StBorVXtyDsbs5NZlN+LdK8mrRwleO55UK3IZbny5i3u1zAkZJjhocfby VGDe52PS6Q3324jbx2BMvEvTpAdG2PX/E/tNplbfq7k6kMyAmVcxbMDkYcZ+nn6KiurK+koIePy 3mBwLO5Z59ujzRhCRC+lMnQNKZncxieI2pTQ== X-Received: by 2002:ad4:44af:0:b0:690:cdd5:ea47 with SMTP id n15-20020ad444af000000b00690cdd5ea47mr130720qvt.4.1710194381590; Mon, 11 Mar 2024 14:59:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv8d12NTCRvvsNd9wzrQScou0t1spnOSAsponO2Hhy5fuiAC1GN9sG08iGDSGNcIwuXZPIhQ== X-Received: by 2002:ad4:44af:0:b0:690:cdd5:ea47 with SMTP id n15-20020ad444af000000b00690cdd5ea47mr130701qvt.4.1710194381131; Mon, 11 Mar 2024 14:59:41 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:40 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Yu Zhang , qemu-stable , Li Zhijian Subject: [PULL 10/34] migration/rdma: Fix a memory issue for migration Date: Mon, 11 Mar 2024 17:59:01 -0400 Message-ID: <20240311215925.40618-11-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Yu Zhang In commit 3fa9642ff7 change was made to convert the RDMA backend to accept MigrateAddress struct. However, the assignment of "host" leads to data corruption on the target host and the failure of migration. isock->host = rdma->host; By allocating the memory explicitly for it with g_strdup_printf(), the issue is fixed and the migration doesn't fail any more. Fixes: 3fa9642ff7 ("migration: convert rdma backend to accept MigrateAddress") Cc: qemu-stable Cc: Li Zhijian Link: https://lore.kernel.org/r/CAHEcVy4L_D6tuhJ8h=xLR4WaPaprJE3nnxZAEyUnoTrxQ6CF5w@mail.gmail.com Signed-off-by: Yu Zhang [peterx: use g_strdup() instead of g_strdup_printf(), per Zhijian] Signed-off-by: Peter Xu --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index a355dcea89..855753c671 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3357,7 +3357,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) goto err_rdma_dest_wait; } - isock->host = rdma->host; + isock->host = g_strdup(rdma->host); isock->port = g_strdup_printf("%d", rdma->port); /* From patchwork Mon Mar 11 21:59:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589368 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 BF50CC54E58 for ; Mon, 11 Mar 2024 22:04:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngV-0000PJ-F2; Mon, 11 Mar 2024 17:59: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 1rjngR-0000JS-Rx for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59: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 1rjngP-0003zp-V0 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194385; 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=fORkuH4iwhGbcpUM2sVmTdxDf+BTT9cK7aj0xk3UAko=; b=UJIJrSWuXGreveEez2e1i1yVjbIRxluuivHRxDrVV8NvplMocNQzhINnBd/T8TQ2vFVN4b UK5f9rd7bAGtpensIs7zPjDSJyNf7ROKjt3odnC4RggQqFte7E6bhP3OaNkZqgyyJTvACO JKXmQuX+35P1Y797mSvJW70V5P0nsxc= 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-558--Qy2BHw6MdanaiylZR3Ppw-1; Mon, 11 Mar 2024 17:59:44 -0400 X-MC-Unique: -Qy2BHw6MdanaiylZR3Ppw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6818b8cb840so15027036d6.1 for ; Mon, 11 Mar 2024 14:59:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194383; x=1710799183; 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=fORkuH4iwhGbcpUM2sVmTdxDf+BTT9cK7aj0xk3UAko=; b=I/a/K00dDoa1swJlMXp1x4ExiARvAhAklVEJk+sZMB9m/77v5+dLL6SoOgT1k8MuSK pHAgrKMA9awp4RKa6LnKDDjqGmL5PPD/KlSqLkoviuaI7Luohii2kKJSGTS82OVH7Bz1 QuC7TqzNCL0UTlmONdcYFbLxzi5usfuUT2azA4rKFgkhCNmlJv+Obah3a7wrTkrSXVfX iGHO6rIWcABIMmUXSL9IEl/tYeRQT7dyDJPTqw47hOogxqIWRaW9554rsO8KY6+xQFyH sVkJrIzQEryked/8TzKg8Ev/tnaHV1T+Hh6WjByVCBtAui9iOnSp/5C7BXQdQTRE7jxS B/sg== X-Gm-Message-State: AOJu0YyuIiNOfXq0xv7WImGkDNagnwHf3c6jLPfH3YMt/heVcJLiLew/ EqSPOKXFtz29eH2UW18W38QvJok/JMgg1oZD3Mhvz5P3xFCkOPZWyNJflVog6I4lTMTqmgwwuNO 7PC2XL+xmUDV8jG+2U3NZdBbMdkSyjLcTUHkkIp95MGLXtgT+vBRXPw9LaqUxZWcgBWWxyTUlYw beo2gI2Qt2xBTkkveiU1wz9oU/i9TUfNmNKA== X-Received: by 2002:a0c:fa91:0:b0:690:d74d:7e6d with SMTP id o17-20020a0cfa91000000b00690d74d7e6dmr3080639qvn.3.1710194383292; Mon, 11 Mar 2024 14:59:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmdq+BOAUDzA64mgLIx0/PUFj+sclgG3c+haYlxJyrE3DpgckObm3ja+I7jM1qU9HKSAqrzg== X-Received: by 2002:a0c:fa91:0:b0:690:d74d:7e6d with SMTP id o17-20020a0cfa91000000b00690d74d7e6dmr3080610qvn.3.1710194382810; Mon, 11 Mar 2024 14:59:42 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:41 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Jonathan Cameron Subject: [PULL 11/34] physmem: Rename addr1 to more informative mr_addr in flatview_read/write() and similar Date: Mon, 11 Mar 2024 17:59:02 -0400 Message-ID: <20240311215925.40618-12-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron The calls to flatview_read/write[_continue]() have parameters addr and addr1 but the names give no indication of what they are addresses of. Rename addr1 to mr_addr to reflect that it is the translated address offset within the MemoryRegion returned by flatview_translate(). Similarly rename the parameter in address_space_read/write_cached_slow() Suggested-by: Peter Xu Signed-off-by: Jonathan Cameron Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/20240307153710.30907-2-Jonathan.Cameron@huawei.com Signed-off-by: Peter Xu --- system/physmem.c | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 6e9ed97597..e92bed50a6 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2685,7 +2685,7 @@ static bool flatview_access_allowed(MemoryRegion *mr, MemTxAttrs attrs, static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, const void *ptr, - hwaddr len, hwaddr addr1, + hwaddr len, hwaddr mr_addr, hwaddr l, MemoryRegion *mr) { uint8_t *ram_ptr; @@ -2695,12 +2695,12 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, const uint8_t *buf = ptr; for (;;) { - if (!flatview_access_allowed(mr, attrs, addr1, l)) { + if (!flatview_access_allowed(mr, attrs, mr_addr, l)) { result |= MEMTX_ACCESS_ERROR; /* Keep going. */ } else if (!memory_access_is_direct(mr, true)) { release_lock |= prepare_mmio_access(mr); - l = memory_access_size(mr, l, addr1); + l = memory_access_size(mr, l, mr_addr); /* XXX: could force current_cpu to NULL to avoid potential bugs */ @@ -2715,13 +2715,13 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, (l == 8 && len >= 8)); #endif val = ldn_he_p(buf, l); - result |= memory_region_dispatch_write(mr, addr1, val, + result |= memory_region_dispatch_write(mr, mr_addr, val, size_memop(l), attrs); } else { /* RAM case */ - ram_ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); + ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, false); memmove(ram_ptr, buf, l); - invalidate_and_set_dirty(mr, addr1, l); + invalidate_and_set_dirty(mr, mr_addr, l); } if (release_lock) { @@ -2738,7 +2738,7 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, } l = len; - mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); + mr = flatview_translate(fv, addr, &mr_addr, &l, true, attrs); } return result; @@ -2749,22 +2749,22 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, const void *buf, hwaddr len) { hwaddr l; - hwaddr addr1; + hwaddr mr_addr; MemoryRegion *mr; l = len; - mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); + mr = flatview_translate(fv, addr, &mr_addr, &l, true, attrs); if (!flatview_access_allowed(mr, attrs, addr, len)) { return MEMTX_ACCESS_ERROR; } return flatview_write_continue(fv, addr, attrs, buf, len, - addr1, l, mr); + mr_addr, l, mr); } /* Called within RCU critical section. */ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *ptr, - hwaddr len, hwaddr addr1, hwaddr l, + hwaddr len, hwaddr mr_addr, hwaddr l, MemoryRegion *mr) { uint8_t *ram_ptr; @@ -2775,14 +2775,14 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, fuzz_dma_read_cb(addr, len, mr); for (;;) { - if (!flatview_access_allowed(mr, attrs, addr1, l)) { + if (!flatview_access_allowed(mr, attrs, mr_addr, l)) { result |= MEMTX_ACCESS_ERROR; /* Keep going. */ } else if (!memory_access_is_direct(mr, false)) { /* I/O case */ release_lock |= prepare_mmio_access(mr); - l = memory_access_size(mr, l, addr1); - result |= memory_region_dispatch_read(mr, addr1, &val, + l = memory_access_size(mr, l, mr_addr); + result |= memory_region_dispatch_read(mr, mr_addr, &val, size_memop(l), attrs); /* @@ -2798,7 +2798,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, stn_he_p(buf, l, val); } else { /* RAM case */ - ram_ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); + ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, false); memcpy(buf, ram_ptr, l); } @@ -2816,7 +2816,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, } l = len; - mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); + mr = flatview_translate(fv, addr, &mr_addr, &l, false, attrs); } return result; @@ -2827,16 +2827,16 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len) { hwaddr l; - hwaddr addr1; + hwaddr mr_addr; MemoryRegion *mr; l = len; - mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); + mr = flatview_translate(fv, addr, &mr_addr, &l, false, attrs); if (!flatview_access_allowed(mr, attrs, addr, len)) { return MEMTX_ACCESS_ERROR; } return flatview_read_continue(fv, addr, attrs, buf, len, - addr1, l, mr); + mr_addr, l, mr); } MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, @@ -3348,15 +3348,15 @@ MemTxResult address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, void *buf, hwaddr len) { - hwaddr addr1, l; + hwaddr mr_addr, l; MemoryRegion *mr; l = len; - mr = address_space_translate_cached(cache, addr, &addr1, &l, false, + mr = address_space_translate_cached(cache, addr, &mr_addr, &l, false, MEMTXATTRS_UNSPECIFIED); return flatview_read_continue(cache->fv, addr, MEMTXATTRS_UNSPECIFIED, buf, len, - addr1, l, mr); + mr_addr, l, mr); } /* Called from RCU critical section. address_space_write_cached uses this @@ -3366,15 +3366,15 @@ MemTxResult address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, const void *buf, hwaddr len) { - hwaddr addr1, l; + hwaddr mr_addr, l; MemoryRegion *mr; l = len; - mr = address_space_translate_cached(cache, addr, &addr1, &l, true, + mr = address_space_translate_cached(cache, addr, &mr_addr, &l, true, MEMTXATTRS_UNSPECIFIED); return flatview_write_continue(cache->fv, addr, MEMTXATTRS_UNSPECIFIED, buf, len, - addr1, l, mr); + mr_addr, l, mr); } #define ARG1_DECL MemoryRegionCache *cache From patchwork Mon Mar 11 21:59:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589369 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 DE623C5475B for ; Mon, 11 Mar 2024 22:04:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngb-0000XQ-Ik; Mon, 11 Mar 2024 17:59:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngV-0000PR-FJ for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:51 -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 1rjngS-00040F-RH for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194388; 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=yRGPg/czG58tLUCGpqFBbCYEw31JuRNr9OOpCiRQjy0=; b=ENQRDMj4Ie3GFkd3xiuyrKENvwAyDbTbJGE9TRJJu42zZE15pZIk0oALZWKcrzGt8yVmWJ aukyXLZRnSqvn5/zDPMHqFNFW6jO0ju4I9HI178LCCtvdq8dV+SJDzu7Reg2jE3qFtLKEn 9YKx8hjyVj0+oMyT5rwHDqp28Bd6pf4= 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-168-cFrAhoSZNYyDt_qie4EeQg-1; Mon, 11 Mar 2024 17:59:45 -0400 X-MC-Unique: cFrAhoSZNYyDt_qie4EeQg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690d3f5af86so4505506d6.0 for ; Mon, 11 Mar 2024 14:59:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194385; x=1710799185; 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=yRGPg/czG58tLUCGpqFBbCYEw31JuRNr9OOpCiRQjy0=; b=W1KvWT2tRY0wWw0nKTNivoH9rluTGl2dnttD38+yCPGFzSC64WbSNPEdfcDfV6Ty87 pkcUbBHq1ydnYf1mDuUdyP3OgR396y/GbkAJY5WSKBxLcjIhXq2PeC0jOMpFUqQHVqrT teJyU4unVwBEm48O2B2GpsM6f1eSN/Jw0kW11zptYs/K25NJJzhf0vo8AJnr4wQ+9+Cg PKMAyavqEEKS+APd23nxFau9IV7OsXhImN3o8eTDsnzSENoGb2DU9h1/KNC8fSi7a0oo lkisOGK3+Hj8M0QUMtHh8yzDNJmQS4tmHuTh4r3DP7qWAfuL2NfNW8NOJLoku5aUtuu4 W33A== X-Gm-Message-State: AOJu0YyOnHx/mTVBsl9/e0Bodin2QmniUFEGZKJaRX2/Od7qHaNnyjfR JeyTeTmAkO9v6jKT4kLXZ2Y6EAqxPi1nNgI3x42Br+9QJoE2Tk3h5pKuA7fP3N8HEzizpeC1Q4S 6JRXMa8Dzh4kKlxKxlx9mcql1j1QdnxSeHYsVEpicD7yk68qZ4MAyTlfwKI60F6hszzhbsNHToI 1nw6mDWcOQ2Rw7ThWP8O3320CJ7WWr36f3tA== X-Received: by 2002:ad4:5bec:0:b0:690:e47c:9bee with SMTP id k12-20020ad45bec000000b00690e47c9beemr406381qvc.4.1710194384861; Mon, 11 Mar 2024 14:59:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmNZoMikAaOW0gfJu6qy88OFt8U8twruAvieSn9O7B5S8Qzesk6AuVk9ZsOoQsvcC7OVnGCg== X-Received: by 2002:ad4:5bec:0:b0:690:e47c:9bee with SMTP id k12-20020ad45bec000000b00690e47c9beemr406360qvc.4.1710194384389; Mon, 11 Mar 2024 14:59:44 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:43 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Jonathan Cameron , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PULL 12/34] physmem: Reduce local variable scope in flatview_read/write_continue() Date: Mon, 11 Mar 2024 17:59:03 -0400 Message-ID: <20240311215925.40618-13-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Precursor to factoring out the inner loops for reuse. Reviewed-by: Peter Xu Signed-off-by: Jonathan Cameron Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/r/20240307153710.30907-3-Jonathan.Cameron@huawei.com Signed-off-by: Peter Xu --- system/physmem.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index e92bed50a6..e35aa29343 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2688,10 +2688,7 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, hwaddr len, hwaddr mr_addr, hwaddr l, MemoryRegion *mr) { - uint8_t *ram_ptr; - uint64_t val; MemTxResult result = MEMTX_OK; - bool release_lock = false; const uint8_t *buf = ptr; for (;;) { @@ -2699,7 +2696,9 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, result |= MEMTX_ACCESS_ERROR; /* Keep going. */ } else if (!memory_access_is_direct(mr, true)) { - release_lock |= prepare_mmio_access(mr); + uint64_t val; + bool release_lock = prepare_mmio_access(mr); + l = memory_access_size(mr, l, mr_addr); /* XXX: could force current_cpu to NULL to avoid potential bugs */ @@ -2717,18 +2716,21 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, val = ldn_he_p(buf, l); result |= memory_region_dispatch_write(mr, mr_addr, val, size_memop(l), attrs); + if (release_lock) { + bql_unlock(); + } + + } else { /* RAM case */ - ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, false); + + uint8_t *ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, + false); + memmove(ram_ptr, buf, l); invalidate_and_set_dirty(mr, mr_addr, l); } - if (release_lock) { - bql_unlock(); - release_lock = false; - } - len -= l; buf += l; addr += l; @@ -2767,10 +2769,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, hwaddr len, hwaddr mr_addr, hwaddr l, MemoryRegion *mr) { - uint8_t *ram_ptr; - uint64_t val; MemTxResult result = MEMTX_OK; - bool release_lock = false; uint8_t *buf = ptr; fuzz_dma_read_cb(addr, len, mr); @@ -2780,7 +2779,9 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, /* Keep going. */ } else if (!memory_access_is_direct(mr, false)) { /* I/O case */ - release_lock |= prepare_mmio_access(mr); + uint64_t val; + bool release_lock = prepare_mmio_access(mr); + l = memory_access_size(mr, l, mr_addr); result |= memory_region_dispatch_read(mr, mr_addr, &val, size_memop(l), attrs); @@ -2796,17 +2797,16 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, (l == 8 && len >= 8)); #endif stn_he_p(buf, l, val); + if (release_lock) { + bql_unlock(); + } } else { /* RAM case */ - ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, false); + uint8_t *ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, + false); memcpy(buf, ram_ptr, l); } - if (release_lock) { - bql_unlock(); - release_lock = false; - } - len -= l; buf += l; addr += l; From patchwork Mon Mar 11 21:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589363 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 45F8BC54E58 for ; Mon, 11 Mar 2024 22:03:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngX-0000Uu-NU; Mon, 11 Mar 2024 17:59:53 -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 1rjngV-0000Pc-IW for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:51 -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 1rjngT-00040L-8f for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194388; 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=ZYSgvTN7t6/1mUzIu1ZJuxJpeE9c58Iqz1Li8XbeIy4=; b=KKTDBxKP9w1swh+96f3iWCgnaXYD1IwHoVgyzaNB4bRAe2a9rCYxiXuysTNlv9z/hSDBnC UNq8sbAo6Sui651+6VYmUUT76AZgWdCSA0kt/Pu1G1/CG3ZLiYxSnFTS1/5x2PCVMahOr6 zCdnkhl1i8aJd19cjVuP/FNjSlu5OcU= 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-608-Q6qJFhJuMdqhnQ7aF5jtYQ-1; Mon, 11 Mar 2024 17:59:47 -0400 X-MC-Unique: Q6qJFhJuMdqhnQ7aF5jtYQ-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ab2b0de1so15043976d6.0 for ; Mon, 11 Mar 2024 14:59:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194386; x=1710799186; 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=ZYSgvTN7t6/1mUzIu1ZJuxJpeE9c58Iqz1Li8XbeIy4=; b=M276jH+59TL7jDehxmzzBveTBDSTPL2QOQE7c4v/lps7Mamv0gBaCLBWWGNNT7gK6o gpCYmGDQEJEYShDl7feOiSinMSFpC/4jOttvNXCydiKVPnBt1t1jL95MnS4h65HwXsBN qeLcj1SBrU81VKJnykGr7n7UVf05fAa9up7r2c2GX2b3oQPF8E4ka83uTqG9HyHrTg3t uhRIFUSfdOLHX525fbCtvt/GzC0fBNyb3UgJjVDrnn+WgjTcVlDQMgvaX5AhkrzR7qjz XQKubzshNDN1Z7N9iFoqHnOtiUZ3r1kjCERRRi+HIuW/Jg7LUNlJ3MfHblZvgkQBOfiV Gxjw== X-Gm-Message-State: AOJu0Yyd8gw9eQthwvvGy2rPIIyEj/liwfrZ3Tw4TvWqegfGgABUuemj o6lG9E1bUE6qG6xpI0lfOCLfXLv2pr/Ld5G1WaGrBGQzR7p+b7r+2UkHf6543nIaaSRiGuFmvPs WOW/kz8zC/TcXAXoqD83LCx4sEjcEMhJ/e2GvBX0wpQtT2RQlPaTMOGiz667BRHHFw9LL5YPByB c6hE4r1d2c4eOej9XWuR2WdPom4Ah3c8o0+A== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr136347qvo.3.1710194386549; Mon, 11 Mar 2024 14:59:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEq9hjgHMwGjne1kqoTLcdFTY7SEPw50PVak5JmXopJTgKo+USkUHX9sc6GXJ1EBqsSqdrBA== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr136314qvo.3.1710194385967; Mon, 11 Mar 2024 14:59:45 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:45 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Jonathan Cameron Subject: [PULL 13/34] physmem: Factor out body of flatview_read/write_continue() loop Date: Mon, 11 Mar 2024 17:59:04 -0400 Message-ID: <20240311215925.40618-14-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron This code will be reused for the address_space_cached accessors shortly. Also reduce scope of result variable now we aren't directly calling this in the loop. Signed-off-by: Jonathan Cameron Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/20240307153710.30907-4-Jonathan.Cameron@huawei.com Signed-off-by: Peter Xu --- system/physmem.c | 169 +++++++++++++++++++++++++++-------------------- 1 file changed, 99 insertions(+), 70 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index e35aa29343..737869a3f5 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2681,6 +2681,56 @@ static bool flatview_access_allowed(MemoryRegion *mr, MemTxAttrs attrs, return false; } +static MemTxResult flatview_write_continue_step(MemTxAttrs attrs, + const uint8_t *buf, + hwaddr len, hwaddr mr_addr, + hwaddr *l, MemoryRegion *mr) +{ + if (!flatview_access_allowed(mr, attrs, mr_addr, *l)) { + return MEMTX_ACCESS_ERROR; + } + + if (!memory_access_is_direct(mr, true)) { + uint64_t val; + MemTxResult result; + bool release_lock = prepare_mmio_access(mr); + + *l = memory_access_size(mr, *l, mr_addr); + /* + * XXX: could force current_cpu to NULL to avoid + * potential bugs + */ + + /* + * Assure Coverity (and ourselves) that we are not going to OVERRUN + * the buffer by following ldn_he_p(). + */ +#ifdef QEMU_STATIC_ANALYSIS + assert((*l == 1 && len >= 1) || + (*l == 2 && len >= 2) || + (*l == 4 && len >= 4) || + (*l == 8 && len >= 8)); +#endif + val = ldn_he_p(buf, *l); + result = memory_region_dispatch_write(mr, mr_addr, val, + size_memop(*l), attrs); + if (release_lock) { + bql_unlock(); + } + + return result; + } else { + /* RAM case */ + uint8_t *ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, l, + false); + + memmove(ram_ptr, buf, *l); + invalidate_and_set_dirty(mr, mr_addr, *l); + + return MEMTX_OK; + } +} + /* Called within RCU critical section. */ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, @@ -2692,44 +2742,8 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, const uint8_t *buf = ptr; for (;;) { - if (!flatview_access_allowed(mr, attrs, mr_addr, l)) { - result |= MEMTX_ACCESS_ERROR; - /* Keep going. */ - } else if (!memory_access_is_direct(mr, true)) { - uint64_t val; - bool release_lock = prepare_mmio_access(mr); - - l = memory_access_size(mr, l, mr_addr); - /* XXX: could force current_cpu to NULL to avoid - potential bugs */ - - /* - * Assure Coverity (and ourselves) that we are not going to OVERRUN - * the buffer by following ldn_he_p(). - */ -#ifdef QEMU_STATIC_ANALYSIS - assert((l == 1 && len >= 1) || - (l == 2 && len >= 2) || - (l == 4 && len >= 4) || - (l == 8 && len >= 8)); -#endif - val = ldn_he_p(buf, l); - result |= memory_region_dispatch_write(mr, mr_addr, val, - size_memop(l), attrs); - if (release_lock) { - bql_unlock(); - } - - - } else { - /* RAM case */ - - uint8_t *ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, - false); - - memmove(ram_ptr, buf, l); - invalidate_and_set_dirty(mr, mr_addr, l); - } + result |= flatview_write_continue_step(attrs, buf, len, mr_addr, &l, + mr); len -= l; buf += l; @@ -2763,6 +2777,52 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, mr_addr, l, mr); } +static MemTxResult flatview_read_continue_step(MemTxAttrs attrs, uint8_t *buf, + hwaddr len, hwaddr mr_addr, + hwaddr *l, + MemoryRegion *mr) +{ + if (!flatview_access_allowed(mr, attrs, mr_addr, *l)) { + return MEMTX_ACCESS_ERROR; + } + + if (!memory_access_is_direct(mr, false)) { + /* I/O case */ + uint64_t val; + MemTxResult result; + bool release_lock = prepare_mmio_access(mr); + + *l = memory_access_size(mr, *l, mr_addr); + result = memory_region_dispatch_read(mr, mr_addr, &val, size_memop(*l), + attrs); + + /* + * Assure Coverity (and ourselves) that we are not going to OVERRUN + * the buffer by following stn_he_p(). + */ +#ifdef QEMU_STATIC_ANALYSIS + assert((*l == 1 && len >= 1) || + (*l == 2 && len >= 2) || + (*l == 4 && len >= 4) || + (*l == 8 && len >= 8)); +#endif + stn_he_p(buf, *l, val); + + if (release_lock) { + bql_unlock(); + } + return result; + } else { + /* RAM case */ + uint8_t *ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, l, + false); + + memcpy(buf, ram_ptr, *l); + + return MEMTX_OK; + } +} + /* Called within RCU critical section. */ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *ptr, @@ -2774,38 +2834,7 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, fuzz_dma_read_cb(addr, len, mr); for (;;) { - if (!flatview_access_allowed(mr, attrs, mr_addr, l)) { - result |= MEMTX_ACCESS_ERROR; - /* Keep going. */ - } else if (!memory_access_is_direct(mr, false)) { - /* I/O case */ - uint64_t val; - bool release_lock = prepare_mmio_access(mr); - - l = memory_access_size(mr, l, mr_addr); - result |= memory_region_dispatch_read(mr, mr_addr, &val, - size_memop(l), attrs); - - /* - * Assure Coverity (and ourselves) that we are not going to OVERRUN - * the buffer by following stn_he_p(). - */ -#ifdef QEMU_STATIC_ANALYSIS - assert((l == 1 && len >= 1) || - (l == 2 && len >= 2) || - (l == 4 && len >= 4) || - (l == 8 && len >= 8)); -#endif - stn_he_p(buf, l, val); - if (release_lock) { - bql_unlock(); - } - } else { - /* RAM case */ - uint8_t *ram_ptr = qemu_ram_ptr_length(mr->ram_block, mr_addr, &l, - false); - memcpy(buf, ram_ptr, l); - } + result |= flatview_read_continue_step(attrs, buf, len, mr_addr, &l, mr); len -= l; buf += l; From patchwork Mon Mar 11 21:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589356 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 28661C5475B for ; Mon, 11 Mar 2024 22:00:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngd-0000YR-M7; Mon, 11 Mar 2024 18:00:01 -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 1rjngX-0000Vq-QZ for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:55 -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 1rjngV-00040b-NK for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194391; 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=XAW4kNcipci25Ftdw678I9V9K89A2Ws6lDYWYUOgtX4=; b=ZUoxYQRW7bVQ8ESAgVrIjreUkx3ov2HIH4T5w5R+MC2id5yuaJPAvhJW6MFGDZeTybceJd eXS13H1/DGMft+uhnSomn0pLA+bOlzRHVse8SNRLCAJamuNRUibXF6/9/kB9govWfstZkS 0uKc4HlM5VajyRfgdHTzGMez+20qE9Y= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-311-jOP7hcuSPSC3P7IoR2LPcg-1; Mon, 11 Mar 2024 17:59:49 -0400 X-MC-Unique: jOP7hcuSPSC3P7IoR2LPcg-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-7dc10e68417so93139241.0 for ; Mon, 11 Mar 2024 14:59:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194388; x=1710799188; 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=XAW4kNcipci25Ftdw678I9V9K89A2Ws6lDYWYUOgtX4=; b=kFYgDLJp4ni+urjoDAE6UQEy8h6V6bUJeNLWVsVM2hoqDgWZuMQn4ErknmGqN+7wJn pblqsYGNycjP6E+MQOkGZ0llo1JSpok9eFcV8v7+nwAoGlqp7gg4kZKZHpPLLxE4XqBB H5+4WQBPfnQd+0A9bUsPpiF0Dboza4PDulMKGiX8NcmKrh32rtLfDFrg7HxsFy/ap0BE PcPBTnNrCwAHP7ZkCqhRhqaZ5aLW/r5H3Wtc985jhitLTlmGRd95qP+Mn50MwvGB5RzI 0vRBK6WeLLzJcj6/ewV4W5gPEKm6cAFo+oGBxBHXEL1x1vvPAb5pHuKCMXafLOhpD8HS Tbbg== X-Gm-Message-State: AOJu0YzRBXP/CWx1uVfLeM+qL1olPufO3EqKVWVZ45DHCH9Mncku7a9g iP94XzGOMkjZQOSYGTm8h7E4+lMt8GLuHhJHqQE9OtLEvgcHJtl5hHPKXuQb7S7E5AgsdFNpLKq VuXI2o9xpzPRmWqUm0kh1kzSXuI3MnA/BolQnaaZF4WkKWJM4AC2GctnLtiJzamQVM/w4At9SVf I/TllVRHDrAjgglNX+bGyY8fjVJCskndimXA== X-Received: by 2002:a05:6102:3667:b0:473:240f:36b9 with SMTP id bg7-20020a056102366700b00473240f36b9mr3694363vsb.1.1710194388155; Mon, 11 Mar 2024 14:59:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+3+LK98FLCI/uSUmdZukHEWonLNFKhMsYvtB6u7kOyQt/iv/MoaUDFp56HNLXUVJax8598w== X-Received: by 2002:a05:6102:3667:b0:473:240f:36b9 with SMTP id bg7-20020a056102366700b00473240f36b9mr3694342vsb.1.1710194387675; Mon, 11 Mar 2024 14:59:47 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:46 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Jonathan Cameron Subject: [PULL 14/34] physmem: Fix wrong address in large address_space_read/write_cached_slow() Date: Mon, 11 Mar 2024 17:59:05 -0400 Message-ID: <20240311215925.40618-15-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron If the access is bigger than the MemoryRegion supports, flatview_read/write_continue() will attempt to update the Memory Region. but the address passed to flatview_translate() is relative to the cache, not to the FlatView. On arm/virt with interleaved CXL memory emulation and virtio-blk-pci this lead to the first part of descriptor being read from the CXL memory and the second part from PA 0x8 which happens to be a blank region of a flash chip and all ffs on this particular configuration. Note this test requires the out of tree ARM support for CXL, but the problem is more general. Avoid this by adding new address_space_read_continue_cached() and address_space_write_continue_cached() which share all the logic with the flatview versions except for the MemoryRegion lookup which is unnecessary as the MemoryRegionCache only covers one MemoryRegion. Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20240307153710.30907-5-Jonathan.Cameron@huawei.com Signed-off-by: Peter Xu --- system/physmem.c | 63 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 737869a3f5..6cfb7a80ab 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3370,6 +3370,59 @@ static inline MemoryRegion *address_space_translate_cached( return section.mr; } +/* Called within RCU critical section. */ +static MemTxResult address_space_write_continue_cached(MemTxAttrs attrs, + const void *ptr, + hwaddr len, + hwaddr mr_addr, + hwaddr l, + MemoryRegion *mr) +{ + MemTxResult result = MEMTX_OK; + const uint8_t *buf = ptr; + + for (;;) { + result |= flatview_write_continue_step(attrs, buf, len, mr_addr, &l, + mr); + + len -= l; + buf += l; + mr_addr += l; + + if (!len) { + break; + } + + l = len; + } + + return result; +} + +/* Called within RCU critical section. */ +static MemTxResult address_space_read_continue_cached(MemTxAttrs attrs, + void *ptr, hwaddr len, + hwaddr mr_addr, hwaddr l, + MemoryRegion *mr) +{ + MemTxResult result = MEMTX_OK; + uint8_t *buf = ptr; + + for (;;) { + result |= flatview_read_continue_step(attrs, buf, len, mr_addr, &l, mr); + len -= l; + buf += l; + mr_addr += l; + + if (!len) { + break; + } + l = len; + } + + return result; +} + /* Called from RCU critical section. address_space_read_cached uses this * out of line function when the target is an MMIO or IOMMU region. */ @@ -3383,9 +3436,8 @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, l = len; mr = address_space_translate_cached(cache, addr, &mr_addr, &l, false, MEMTXATTRS_UNSPECIFIED); - return flatview_read_continue(cache->fv, - addr, MEMTXATTRS_UNSPECIFIED, buf, len, - mr_addr, l, mr); + return address_space_read_continue_cached(MEMTXATTRS_UNSPECIFIED, + buf, len, mr_addr, l, mr); } /* Called from RCU critical section. address_space_write_cached uses this @@ -3401,9 +3453,8 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, l = len; mr = address_space_translate_cached(cache, addr, &mr_addr, &l, true, MEMTXATTRS_UNSPECIFIED); - return flatview_write_continue(cache->fv, - addr, MEMTXATTRS_UNSPECIFIED, buf, len, - mr_addr, l, mr); + return address_space_write_continue_cached(MEMTXATTRS_UNSPECIFIED, + buf, len, mr_addr, l, mr); } #define ARG1_DECL MemoryRegionCache *cache From patchwork Mon Mar 11 21:59:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589361 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 51343C5475B for ; Mon, 11 Mar 2024 22:03:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngq-0000ps-Tr; Mon, 11 Mar 2024 18:00:13 -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 1rjngZ-0000XA-Nr for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59: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 1rjngW-00041v-BR for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194391; 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=jQpFxxwXLTkQcHkAxj0keU82dn5pcaDLyf+EyopbQPc=; b=OUbW80B0gXFYfF8ymxGxQ40+mQugA9Y+bc61EgpkHIvehvUV3t5D87ED7jkxpgQ6MVbsiE kATW/iYYMmjf0L/l9ydELDJHrwurCEUgUL1jk88zqtZPLCx/ZqXwxZZNsArmx+lPL8bNLI bahm7MDhHzzzPcA4b5pCzcs1dc2I9AE= 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-663-LcsL9Nz0MxOMfVgJGQpS-A-1; Mon, 11 Mar 2024 17:59:50 -0400 X-MC-Unique: LcsL9Nz0MxOMfVgJGQpS-A-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ab2b0de1so15044036d6.0 for ; Mon, 11 Mar 2024 14:59:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194389; x=1710799189; 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=jQpFxxwXLTkQcHkAxj0keU82dn5pcaDLyf+EyopbQPc=; b=tcmHKcPrfTRfVmC2Q/yyUpW/ZJj+OYxc6/QUT41uXZh6ON7jcfYSu25HL26DpGgoUM eG7QmKDYeNVP8Z/b1vqZJ21Pl/QO2GQbSMUyf4GHDyzjGI1u3/dJYYf7E0pBSvFoe9/l PFPrmLv3VJ7ZrxDpgDS6oZDrf+OtzrfZa7Au2fFqVsMOHiT9ko4InCRX73lrsaECcPgl 3nyeN9GolRyYqNdQbOnRlmHnr2ZcnchPid06OFmAfxoLuCihwJDZ6FagBYn78ufZAgRD Pi2SOF2jqFGWpSFpdk9NwhoMI34O8P6ZC/m55p8I6hEC0BcROYepxDbhw13aGihCh/WA PBrg== X-Gm-Message-State: AOJu0YxbJcyyyTnSRzwkSOSeXiIAPd/GO0+HZtgcEgyds22Shx/cN/7t OKo7mbQtLlsBB5BXNm9mj82wH5VeEk5Xy4ybleFZScH3Rkz3h/s/9RDVJQHK/7iOMtBMdFXIQZJ JyHq5CbQ0RF72GQwC9/8bynrgie664MXMn/jddDdTjhpbmqn5UBHml/2YQRORpjkVIcLTNz7Tp8 ZiNbyqcC9d+XTZIPlmccCoH0ebx1socYUoog== X-Received: by 2002:ad4:44af:0:b0:690:cdd5:ea47 with SMTP id n15-20020ad444af000000b00690cdd5ea47mr130943qvt.4.1710194389469; Mon, 11 Mar 2024 14:59:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGh9+VY42YGZ+FJEdnCNH+diWVLZIuv5WxcOKLZw+FA191OPB63jMazUrHr6f7b5poNrlwGPg== X-Received: by 2002:ad4:44af:0:b0:690:cdd5:ea47 with SMTP id n15-20020ad444af000000b00690cdd5ea47mr130924qvt.4.1710194389011; Mon, 11 Mar 2024 14:59:49 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:48 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Anthony PERARD Subject: [PULL 15/34] migration: Fix format in error message Date: Mon, 11 Mar 2024 17:59:06 -0400 Message-ID: <20240311215925.40618-16-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Anthony PERARD In file_write_ramblock_iov(), "offset" is "uintptr_t" and not "ram_addr_t". While usually they are both equivalent, this is not the case with CONFIG_XEN_BACKEND. Use the right format. This will fix build on 32-bit. Fixes: f427d90b9898 ("migration/multifd: Support outgoing mapped-ram stream format") Signed-off-by: Anthony PERARD Link: https://lore.kernel.org/r/20240311123439.16844-1-anthony.perard@citrix.com Signed-off-by: Peter Xu --- migration/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/file.c b/migration/file.c index 164b079966..5054a60851 100644 --- a/migration/file.c +++ b/migration/file.c @@ -191,7 +191,7 @@ int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, */ offset = (uintptr_t) iov[slice_idx].iov_base - (uintptr_t) block->host; if (offset >= block->used_length) { - error_setg(errp, "offset " RAM_ADDR_FMT + error_setg(errp, "offset %" PRIxPTR "outside of ramblock %s range", offset, block->idstr); ret = -1; break; From patchwork Mon Mar 11 21:59:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589358 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 7D7FAC54E58 for ; Mon, 11 Mar 2024 22:00:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngj-0000aM-8q; Mon, 11 Mar 2024 18:00: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 1rjnga-0000XR-2y for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngY-00042S-2C for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194393; 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=WhLf5HZmmN9ikX3euKyXfeHxTjLkTSEYvxHa358xsjk=; b=Ywbn0TsKFnUBidh6lKaN+DjLO9ReSFwPXsDcrReXOf05/tZrLMd8x1QlCxg8C+Pb3eRFXf 8KNJtXn3+e5T5YBd5NZ50quhymazs1nvRgh0a2nzJaFJwrOjYWYc9tewz+Jxblx8pygoSO +4ewmMtrSCEXUjdWzUWF07KJjibevb8= 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-466-A6ys1P3aN6W3rsEBNjPrdA-1; Mon, 11 Mar 2024 17:59:52 -0400 X-MC-Unique: A6ys1P3aN6W3rsEBNjPrdA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690d3f5af86so4505686d6.0 for ; Mon, 11 Mar 2024 14:59:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194391; x=1710799191; 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=WhLf5HZmmN9ikX3euKyXfeHxTjLkTSEYvxHa358xsjk=; b=eOhAl6k7lYoN3ShhM+RfOkTnfKLl9TFAYtDQW8ATFcj9GLGovfzjg8k6oDrWooxCJ1 60M1tL92tL9PuOuVWSR/TI9vAP/EbgTtF7o6LGcLlX09KIpPYhxQcdsnrDxJQm7tM4Yg uHOygOfNjVQnYLy09FP1JMYkcpg7Ctw6iso99y/9VRSmRKBKOka1j9g2se4fTKFr/v4T JfRqF8vnsTxZwp+jbWfbOGu5ffX9tQjvvaULuvWYLxuFI4878wqTBLFbH5oL6P8CCS3X HXvIVOZx4KtkgyH49k1yJPqHBDOsvztCspm6KCnKeBxhF8obzc5dE1lW+DYUnf2s9REB KsIw== X-Gm-Message-State: AOJu0YzPd1zq2SaASiOlpW/xD+2pW81ym2ypvXPrQ2N0g0E8Xroc6A7t fHRb4BO9oABqHHdSiXy3K586oeaM6Br5kHYZCcHn+0C7ld+Fw1UYz8c53aAT59DXGPxsau6NBsP K9dvv3TR0818r6wquQT5D1eGTeTkOiN9f0MbsjAQy40/p3iIEZR0B0tNNiiCaqbmUkO1Di3F61X sno/E9jRzdShT99xUq2h2zDELVcHL5e4uwig== X-Received: by 2002:a0c:f04a:0:b0:68f:dc8d:8ad3 with SMTP id b10-20020a0cf04a000000b0068fdc8d8ad3mr7986269qvl.0.1710194391071; Mon, 11 Mar 2024 14:59:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJxKbmjh2sRX/zSB5/FmIRrIWBuL9JriqraGQcSeX+ou3L0u6BZg3VwVy/kBVQrXtpWumOBw== X-Received: by 2002:a0c:f04a:0:b0:68f:dc8d:8ad3 with SMTP id b10-20020a0cf04a000000b0068fdc8d8ad3mr7986231qvl.0.1710194390151; Mon, 11 Mar 2024 14:59:50 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:49 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 16/34] migration: export fewer options Date: Mon, 11 Mar 2024 17:59:07 -0400 Message-ID: <20240311215925.40618-17-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare A small number of migration options are accessed by migration clients, but to see them clients must include all of options.h, which is mostly for migration core code. migrate_mode() in particular will be needed by multiple clients. Refactor the option declarations so clients can see the necessary few via misc.h, which already exports a portion of the client API. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179319-294320-1-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/client-options.h | 24 ++++++++++++++++++++++++ include/migration/misc.h | 1 + migration/options.h | 6 +----- hw/vfio/migration.c | 1 - hw/virtio/virtio-balloon.c | 1 - system/dirtylimit.c | 1 - 6 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 include/migration/client-options.h diff --git a/include/migration/client-options.h b/include/migration/client-options.h new file mode 100644 index 0000000000..887fea1565 --- /dev/null +++ b/include/migration/client-options.h @@ -0,0 +1,24 @@ +/* + * QEMU public migration capabilities + * + * Copyright (c) 2012-2023 Red Hat Inc + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_MIGRATION_CLIENT_OPTIONS_H +#define QEMU_MIGRATION_CLIENT_OPTIONS_H + +/* capabilities */ + +bool migrate_background_snapshot(void); +bool migrate_dirty_limit(void); +bool migrate_postcopy_ram(void); +bool migrate_switchover_ack(void); + +/* parameters */ + +MigMode migrate_mode(void); + +#endif diff --git a/include/migration/misc.h b/include/migration/misc.h index 5d1aa593ed..4c226a40bb 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -17,6 +17,7 @@ #include "qemu/notify.h" #include "qapi/qapi-types-migration.h" #include "qapi/qapi-types-net.h" +#include "migration/client-options.h" /* migration/ram.c */ diff --git a/migration/options.h b/migration/options.h index 6ddd8dad9b..b6b69c2bb7 100644 --- a/migration/options.h +++ b/migration/options.h @@ -16,6 +16,7 @@ #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" +#include "migration/client-options.h" /* migration properties */ @@ -24,12 +25,10 @@ extern Property migration_properties[]; /* capabilities */ bool migrate_auto_converge(void); -bool migrate_background_snapshot(void); bool migrate_block(void); bool migrate_colo(void); bool migrate_compress(void); bool migrate_dirty_bitmaps(void); -bool migrate_dirty_limit(void); bool migrate_events(void); bool migrate_mapped_ram(void); bool migrate_ignore_shared(void); @@ -38,11 +37,9 @@ bool migrate_multifd(void); bool migrate_pause_before_switchover(void); bool migrate_postcopy_blocktime(void); bool migrate_postcopy_preempt(void); -bool migrate_postcopy_ram(void); bool migrate_rdma_pin_all(void); bool migrate_release_ram(void); bool migrate_return_path(void); -bool migrate_switchover_ack(void); bool migrate_validate_uuid(void); bool migrate_xbzrle(void); bool migrate_zero_blocks(void); @@ -84,7 +81,6 @@ uint8_t migrate_max_cpu_throttle(void); uint64_t migrate_max_bandwidth(void); uint64_t migrate_avail_switchover_bandwidth(void); uint64_t migrate_max_postcopy_bandwidth(void); -MigMode migrate_mode(void); int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); int migrate_multifd_zlib_level(void); diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index f82dcabc49..49c0016add 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -18,7 +18,6 @@ #include "sysemu/runstate.h" #include "hw/vfio/vfio-common.h" #include "migration/migration.h" -#include "migration/options.h" #include "migration/savevm.h" #include "migration/vmstate.h" #include "migration/qemu-file.h" diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 89f853fa9e..a59ff172bd 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -32,7 +32,6 @@ #include "qemu/error-report.h" #include "migration/misc.h" #include "migration/migration.h" -#include "migration/options.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" diff --git a/system/dirtylimit.c b/system/dirtylimit.c index b5607eb8c2..774ff44f79 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -26,7 +26,6 @@ #include "trace.h" #include "migration/misc.h" #include "migration/migration.h" -#include "migration/options.h" /* * Dirtylimit stop working if dirty page rate error From patchwork Mon Mar 11 21:59:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589360 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 A26F5C5475B for ; Mon, 11 Mar 2024 22:01:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngp-0000kl-4U; Mon, 11 Mar 2024 18:00:11 -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 1rjngb-0000XZ-65 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngZ-00042c-GC for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194394; 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=LdiPgufqKfGIeW6VzqT6zIl2qsu21GpUL7tBaZiFfOE=; b=BJKkRQGCdpZkaprjUv6R6t5oObcweoAc56PH9tezIWMaHFxLuVezbjtTZbmjCKDIVKLSaf VOMOhJ6w4vJuvBFEMr+o7xo0o/9myMGwqhIUPJOc3ImrOXqLP01PfdmkN3cB95+LGFzMt+ 3XTA73Cijx41yBdGHWJ0e/bZQ6xiFw8= 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-668--flSIQIvPHaymtQ6WrMl9g-1; Mon, 11 Mar 2024 17:59:52 -0400 X-MC-Unique: -flSIQIvPHaymtQ6WrMl9g-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ab2b0de1so15044076d6.0 for ; Mon, 11 Mar 2024 14:59:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194392; x=1710799192; 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=LdiPgufqKfGIeW6VzqT6zIl2qsu21GpUL7tBaZiFfOE=; b=LqY5dse8pQ56MXgIdH2GcOfj8ZcoKs+8QbzKWWVSxWCSOOwWt33BJPX7CV5seNR12+ frdjILeoNBLz2QKur9ZrtdFaDxg5zezP3HrwxfHK2iu7074y41PjAQ4afjSsur+BHtBB im/mxNjS5ph6RoylixDgyoLfHMi1+Y4Bm8yWli/7ASBm+iZtaPK8zeLKHAUbASn1ekEB 5tt+RyXbOeQwbkz8Xib0ENbGMNbUfiqIH88xVuXGO2TJuyCUbjoLeRk3fR/ldjbHDS2N c8mV5RfCXeAK8+HJCsgg7u2/5q6GGCldM7FhCgs9WVrxq2XKfBuEESB5F4rW2t8Cs1XG Bfuw== X-Gm-Message-State: AOJu0Yw9QDZwFszSAvByFcUVUAg/tOo9y3Z9dN6DkLgKnhzmbGyDpNxD LU5E8f0rfVxlnNLcG+CWEtkeNcmI71+UKJlSDOyKowjqmwOI2hrSvnlE4WyRBPiYIXNPb1BOkcL 0BCJwhUkTEU+zA8+ef71JC8DxgTPRxOSVO8IpO5JuoSR6+pnqhrAuTCZu5TxZfDTaFmeOJMlmMZ I+xiqxydw2mSDe7ltH5fIeLyxR13bLY8vo5w== X-Received: by 2002:a0c:ea50:0:b0:690:c345:369b with SMTP id u16-20020a0cea50000000b00690c345369bmr182983qvp.0.1710194391939; Mon, 11 Mar 2024 14:59:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHFQKS5O5FHgxznSgb3d70/N9RWf8Zv5DqjPVpCRxfdS5XAAlmNU1/g29PL1gzNNmMlrMeiQ== X-Received: by 2002:a0c:ea50:0:b0:690:c345:369b with SMTP id u16-20020a0cea50000000b00690c345369bmr182952qvp.0.1710194391450; Mon, 11 Mar 2024 14:59:51 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:51 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 17/34] migration: remove migration.h references Date: Mon, 11 Mar 2024 17:59:08 -0400 Message-ID: <20240311215925.40618-18-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Remove migration.h from files that no longer need it due to previous commits. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-2-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- hw/vfio/container.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/virtio-balloon.c | 1 - system/qdev-monitor.c | 1 - target/loongarch/kvm/kvm.c | 1 - tests/unit/test-vmstate.c | 1 - 6 files changed, 6 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index bd25b9fbad..ff081a12c2 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -32,7 +32,6 @@ #include "sysemu/reset.h" #include "trace.h" #include "qapi/error.h" -#include "migration/migration.h" #include "pci.h" VFIOGroupList vfio_group_list = diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index a1eea8547e..1af8621481 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -26,7 +26,6 @@ #include "qemu/sockets.h" #include "sysemu/runstate.h" #include "sysemu/cryptodev.h" -#include "migration/migration.h" #include "migration/postcopy-ram.h" #include "trace.h" #include "exec/ramblock.h" diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index a59ff172bd..609e39a821 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -31,7 +31,6 @@ #include "trace.h" #include "qemu/error-report.h" #include "migration/misc.h" -#include "migration/migration.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 09e07cab9b..c1243891c3 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -38,7 +38,6 @@ #include "qemu/option_int.h" #include "sysemu/block-backend.h" #include "migration/misc.h" -#include "migration/migration.h" #include "qemu/cutils.h" #include "hw/qdev-properties.h" #include "hw/clock.h" diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index c19978a970..11a69a3b4e 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -22,7 +22,6 @@ #include "hw/irq.h" #include "qemu/log.h" #include "hw/loader.h" -#include "migration/migration.h" #include "sysemu/runstate.h" #include "cpu-csr.h" #include "kvm_loongarch.h" diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index c4f9faa273..63f28f26f4 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -24,7 +24,6 @@ #include "qemu/osdep.h" -#include "../migration/migration.h" #include "migration/vmstate.h" #include "migration/qemu-file-types.h" #include "../migration/qemu-file.h" From patchwork Mon Mar 11 21:59:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589386 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 8700FC54E5D for ; Mon, 11 Mar 2024 22:11:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjngr-0000qD-49; Mon, 11 Mar 2024 18:00:13 -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 1rjngc-0000YM-EU for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjnga-00042y-Jn for qemu-devel@nongnu.org; Mon, 11 Mar 2024 17:59:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194395; 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=mNUhmEzp/58FEG6jAG2/JC7N9wqLD5mTyKauBdCXsmU=; b=JRi1Rn3/4vSSYTgrKaVhsd574CH2Ef6Dt3dLr+Rm1uBLgZnlvk6XcY2NMKKs17hxzYzI7B KHAsgpAYLYjNlKqv2T8vN5KWcP4dOnBcs9qCPXpXygW2s8nwJHU3KV1a4vMB2gmrgSbU7G w7g8h8BNeySFjUi85cpmAoIUPUbc8WQ= 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-683-oKMTK-22NVS68bXqeu5tYw-1; Mon, 11 Mar 2024 17:59:54 -0400 X-MC-Unique: oKMTK-22NVS68bXqeu5tYw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ca03e758so5295856d6.1 for ; Mon, 11 Mar 2024 14:59:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194393; x=1710799193; 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=mNUhmEzp/58FEG6jAG2/JC7N9wqLD5mTyKauBdCXsmU=; b=os5cZ16qt/aVqg+zorN8NLwPQxKXmC0gN1S4yVvx7S7ijNdHxV5Y9lrifZL5jAGIxH mJEi7JQqS8ULNWnPz7c9zMorIkTmNMA3BuZiNwdqYuI+BM5illBRpgtVdUXZByL6RSPl xKSOHc1HyHI2PT0sGQoHS3sujG+Y6cMGWn6aQtk8ZXgT0m9UXziZ41W/Co33CWJ40ZuR E1rssyzYN3OGDJWMUVUihHukPokeUiUQ+rK1GbGibAPw+pnr9yjVZy9G48oEVwWuMPJ6 Mv6DkUp6mHyZq4Mb6tqBbptY8XPr66eRqXepXt7r/xsr0VfMy2ZPg9zxSWKlPubxgx0z WXNg== X-Gm-Message-State: AOJu0Yy++xPxe/5ynyhvbTbF5Gu2ywStd1duvFjK3gynLE1V/GMgOnQm a4UQfFKPbbGIVHQTGVxs/tZqXGRJguAOs0sNkBbas5ju97qYcuqxsJIyLkCKJA8dRv0J4L6wOin QeJ03aV64nld3k2WS2/wRzmhQ0gfqFcoTy/dLEp8aWn/uS5Msw6bIAnlF4teS5xdtOm+OsUfEAM WYXB1oHcfr6STu2TAy9w45I1AZSssLwB2ecA== X-Received: by 2002:a05:6214:1743:b0:690:27a:e6 with SMTP id dc3-20020a056214174300b00690027a00e6mr121558qvb.5.1710194393475; Mon, 11 Mar 2024 14:59:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtGL2Cn4/57l0PYp+7R/5Wfss794xgkYagX6VxOzxB+7gOfsH4BLXmjjWYJLoushhekcEHuw== X-Received: by 2002:a05:6214:1743:b0:690:27a:e6 with SMTP id dc3-20020a056214174300b00690027a00e6mr121523qvb.5.1710194392817; Mon, 11 Mar 2024 14:59:52 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:52 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 18/34] migration: export migration_is_setup_or_active Date: Mon, 11 Mar 2024 17:59:09 -0400 Message-ID: <20240311215925.40618-19-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Delete the MigrationState parameter from migration_is_setup_or_active and move it to the public API in misc.h. Signed-off-by: Steve Sistare Reviewed-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/r/1710179338-294359-3-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 + migration/migration.h | 1 - hw/vfio/common.c | 2 +- migration/migration.c | 12 ++++++------ migration/ram.c | 5 ++--- net/vhost-vdpa.c | 3 +-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 4c226a40bb..79cff6224e 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -61,6 +61,7 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); +bool migration_is_setup_or_active(void); bool migrate_mode_is_cpr(MigrationState *); typedef enum MigrationEventType { diff --git a/migration/migration.h b/migration/migration.h index 65c0b61cbd..736460aa8b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -479,7 +479,6 @@ bool migrate_has_error(MigrationState *s); void migrate_fd_connect(MigrationState *s, Error *error_in); -bool migration_is_setup_or_active(int state); bool migration_is_running(int state); int migrate_init(MigrationState *s, Error **errp); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 059bfdc07a..896eab8103 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -152,7 +152,7 @@ static void vfio_set_migration_error(int err) { MigrationState *ms = migrate_get_current(); - if (migration_is_setup_or_active(ms->state)) { + if (migration_is_setup_or_active()) { WITH_QEMU_LOCK_GUARD(&ms->qemu_file_lock) { if (ms->to_dst_file) { qemu_file_set_error(ms->to_dst_file, err); diff --git a/migration/migration.c b/migration/migration.c index a49fcd53ee..af21403bad 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1081,9 +1081,11 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value) * 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(int state) +bool migration_is_setup_or_active(void) { - switch (state) { + MigrationState *s = current_migration; + + switch (s->state) { case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: @@ -1601,10 +1603,8 @@ bool migration_incoming_postcopy_advised(void) bool migration_in_bg_snapshot(void) { - MigrationState *s = migrate_get_current(); - return migrate_background_snapshot() && - migration_is_setup_or_active(s->state); + migration_is_setup_or_active(); } bool migration_is_idle(void) @@ -2297,7 +2297,7 @@ static void *source_return_path_thread(void *opaque) trace_source_return_path_thread_entry(); rcu_register_thread(); - while (migration_is_setup_or_active(ms->state)) { + while (migration_is_setup_or_active()) { trace_source_return_path_thread_loop_top(); header_type = qemu_get_be16(rp); diff --git a/migration/ram.c b/migration/ram.c index 2cd936d9ce..3ee8cb47d3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2909,10 +2909,9 @@ void qemu_guest_free_page_hint(void *addr, size_t len) RAMBlock *block; ram_addr_t offset; size_t used_len, start, npages; - MigrationState *s = migrate_get_current(); /* This function is currently expected to be used during live migration */ - if (!migration_is_setup_or_active(s->state)) { + if (!migration_is_setup_or_active()) { return; } @@ -3263,7 +3262,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) out: if (ret >= 0 - && migration_is_setup_or_active(migrate_get_current()->state)) { + && migration_is_setup_or_active()) { if (migrate_multifd() && migrate_multifd_flush_after_each_section() && !migrate_mapped_ram()) { ret = multifd_send_sync_main(); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e6bdb4562d..8564817073 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -26,7 +26,6 @@ #include #include "standard-headers/linux/virtio_net.h" #include "monitor/monitor.h" -#include "migration/migration.h" #include "migration/misc.h" #include "hw/virtio/vhost.h" @@ -355,7 +354,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(migrate_get_current()->state)) { + migration_is_setup_or_active()) { v->shadow_vqs_enabled = true; } else { v->shadow_vqs_enabled = false; From patchwork Mon Mar 11 21:59:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589366 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 761A6C54E58 for ; Mon, 11 Mar 2024 22:04:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnh3-00010R-4x; Mon, 11 Mar 2024 18:00:29 -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 1rjnge-0000Yy-LN for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:01 -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 1rjngc-00043N-Ue for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194398; 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=L9tqjm6MQlYl8InOWvUGruPRPvJCqkW54MwUESfEeMw=; b=K9CgTU25Q2wdlJSYYNPC8BmVA0QEFDfLI/4TXPPtaXux2DhCMQDAfjtWWgfpct6w21BRcU zfkd3CP74EkulcaWIkpOj5hWH26OW963ZEelaL9jHtehuM2IPdIo4yLO0c8DzAGBgvjh30 3AdVfZpgaYnXBLnYz+KnIiIVPIqulZU= 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-255-yMOVwB8UNxeCBfzcSb0YLw-1; Mon, 11 Mar 2024 17:59:56 -0400 X-MC-Unique: yMOVwB8UNxeCBfzcSb0YLw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690b5ad0e61so15723876d6.0 for ; Mon, 11 Mar 2024 14:59:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194396; x=1710799196; 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=L9tqjm6MQlYl8InOWvUGruPRPvJCqkW54MwUESfEeMw=; b=MkboWhdhsM1+2RxR+JOOhkfLigEmBxBozLRTpiY+/qBRQTHQ6AsmonOF0A5iqXl9/J M90iSHvxB+OVT50Kn4QyWerRldNRU+bKyzv58fMcfQdVuUxWjo2liv79hcVk9MB2Hsza LvMYU0Casc09K2RadXlv0J5MXgajdFLyo5M2x75ZOVIW3Bshqi3QBWBL84JRWH8ayBlw mqC9r/sDhYpAstvcJHgI/Ml/3ETF1fRizW2bXTg9VACRdUL23931DAFTR4Fmjh2RxWZO 6dnNIHD+5ZuDpkfcR8949ixbDBaJZ2q5gD0Q/Ains9iNqLpOvdP5bOXRfYtE6b9XQPui 3CLg== X-Gm-Message-State: AOJu0YxCQRWw/TUrptLSioKPvb80iIsP5pyY06LR1SRMt9oZliQtWBz1 BNvfWHUyKE2ASpSHaqVys8YoywO2MBEJpe8RWh99/F6P+/EdmsWPNB4PQSi1eaIshfPPClNwpDj 84zuBXYMacXKmIEiuUZVwDHhlVLcTaF6S1zSphRANpgfxi9BMlR7ibXqUWt8EHcpKgg9q42mvLR tpWFnOx3YsNvdadfkv0VDBB0QL3W7YenRB0A== X-Received: by 2002:a05:6214:1903:b0:68f:5d43:5e94 with SMTP id er3-20020a056214190300b0068f5d435e94mr7642141qvb.6.1710194396081; Mon, 11 Mar 2024 14:59:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdb58FTINcFo/TyBnyBN4wza3Lw0FmwS44hJGnus24rZHw2UHWKIiW52EfVqFpw1ctBQBXyw== X-Received: by 2002:a05:6214:1903:b0:68f:5d43:5e94 with SMTP id er3-20020a056214190300b0068f5d435e94mr7642114qvb.6.1710194395554; Mon, 11 Mar 2024 14:59:55 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:53 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 19/34] migration: export migration_is_active Date: Mon, 11 Mar 2024 17:59:10 -0400 Message-ID: <20240311215925.40618-20-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Delete the MigrationState parameter from migration_is_active so it can be exported and used without including migration.h. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-4-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 2 +- hw/vfio/common.c | 4 ++-- migration/migration.c | 10 ++++++---- system/dirtylimit.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 79cff6224e..e1f1bf853e 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,7 +60,7 @@ 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(MigrationState *); +bool migration_is_active(void); bool migration_is_setup_or_active(void); bool migrate_mode_is_cpr(MigrationState *); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 896eab8103..2dbbf62e15 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -182,7 +182,7 @@ static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) VFIODevice *vbasedev; MigrationState *ms = migrate_get_current(); - if (ms->state != MIGRATION_STATUS_ACTIVE && + if (!migration_is_active() && ms->state != MIGRATION_STATUS_DEVICE) { return false; } @@ -225,7 +225,7 @@ vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer) { VFIODevice *vbasedev; - if (!migration_is_active(migrate_get_current())) { + if (!migration_is_active()) { return false; } diff --git a/migration/migration.c b/migration/migration.c index af21403bad..17859cbaee 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1406,7 +1406,7 @@ static void migrate_fd_cleanup(MigrationState *s) qemu_fclose(tmp); } - assert(!migration_is_active(s)); + assert(!migration_is_active()); if (s->state == MIGRATION_STATUS_CANCELLING) { migrate_set_state(&s->state, MIGRATION_STATUS_CANCELLING, @@ -1637,8 +1637,10 @@ bool migration_is_idle(void) return false; } -bool migration_is_active(MigrationState *s) +bool migration_is_active(void) { + MigrationState *s = current_migration; + return (s->state == MIGRATION_STATUS_ACTIVE || s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); } @@ -3461,7 +3463,7 @@ static void *migration_thread(void *opaque) trace_migration_thread_setup_complete(); - while (migration_is_active(s)) { + while (migration_is_active()) { if (urgent || !migration_rate_exceeded(s->to_dst_file)) { MigIterateState iter_state = migration_iteration_run(s); if (iter_state == MIG_ITERATE_SKIP) { @@ -3607,7 +3609,7 @@ static void *bg_migration_thread(void *opaque) migration_bh_schedule(bg_migration_vm_start_bh, s); bql_unlock(); - while (migration_is_active(s)) { + while (migration_is_active()) { MigIterateState iter_state = bg_migration_iteration_run(s); if (iter_state == MIG_ITERATE_SKIP) { continue; diff --git a/system/dirtylimit.c b/system/dirtylimit.c index 774ff44f79..051e0311c1 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -83,7 +83,7 @@ static void vcpu_dirty_rate_stat_collect(void) int64_t period = DIRTYLIMIT_CALC_TIME_MS; if (migrate_dirty_limit() && - migration_is_active(s)) { + migration_is_active()) { period = s->parameters.x_vcpu_dirty_limit_period; } From patchwork Mon Mar 11 21:59:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589385 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 10BB1C5475B for ; Mon, 11 Mar 2024 22:10:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnhV-0001Sf-J3; Mon, 11 Mar 2024 18:00:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngk-0000gm-4t for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:09 -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 1rjngh-000447-L5 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194402; 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=My+6bHty8prCf1V92v4bay7C2hPg69ejSYnm4kkNJ50=; b=DbI9kwObc0wS6UiRwfEPd4wl3qUQnnzuPwGUKeR/LDtXUlPu80n5DsLbgfH4tFzPo0ce4m 5hNP9+4As5ns4giuFeFjdRXEpYI9ateJujn9lXeFvKReYsEv6HaDpbNtYtMu0YlkTCntqf CMsHDLKYFKjuVM5BAkmNctgrMMRGO8o= 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-151-BHY_1c6QNnSM13GRgehFwA-1; Mon, 11 Mar 2024 17:59:59 -0400 X-MC-Unique: BHY_1c6QNnSM13GRgehFwA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-690ca03e758so5295996d6.1 for ; Mon, 11 Mar 2024 14:59:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194398; x=1710799198; 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=My+6bHty8prCf1V92v4bay7C2hPg69ejSYnm4kkNJ50=; b=gKi+OUY2ZlftVUhmzQNrzUTRH5z5z10WOaP69NKXPDYFy3zu0LTHgbjM4hjzLEzq5W uyUYsURZHdHQeCrHNuMdNCTNXU7b8xbyU4QKZPM3DnxSGiCl5LldsRYNGFYZujz4NVZw j0AZ3xLeKX62yOY4G9xaCDTkOPYiqYEtIsLsFiqX2we+cNqJ5+E6TSbYOFAgNgxmJFAj 1VtYk1tB/saPtSD1+VSEQocUnpjjC9zBhAK1yqa5pqkq0EXpQ04shMq6wbUqgG58gN0T a3n15jURqkJUxwQmJ2FXZjvgQJI6TEy73AVZzXqGRYUnB9v7Q/6N5PHtEszjp/Bqop2B qxVw== X-Gm-Message-State: AOJu0Yx05YTuXGq4msgdRijq8fXpvcdVo44IDu+1MCVoi1NUQbmJO5Oc laPJ7ysXMY5VJh55yOzyxZYv3lXryE7f5xpwQliqTHzgs73v8f/NFhrdipFDPHjH3ytGTlw4aWQ lHkwJVeXjPfQxK0Yxkb9btmRFa46swoIYSUvBJrC90qI1lgSJnM5V2A233PmqFd5oJMvGIoDR88 HBHb9VFUFsAkM7QOKibnw9epJWQXwWEzF0RA== X-Received: by 2002:a05:6214:1743:b0:690:27a:e6 with SMTP id dc3-20020a056214174300b00690027a00e6mr121707qvb.5.1710194397858; Mon, 11 Mar 2024 14:59:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0huibPPrn6O+kiT2A5mcPgGGW7Whb6o71OmfewDwGL68vUJ7Oz6hHhOZOxsAWP3Z3efhtSg== X-Received: by 2002:a05:6214:1743:b0:690:27a:e6 with SMTP id dc3-20020a056214174300b00690027a00e6mr121685qvb.5.1710194397421; Mon, 11 Mar 2024 14:59:57 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:56 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 20/34] migration: export migration_is_running Date: Mon, 11 Mar 2024 17:59:11 -0400 Message-ID: <20240311215925.40618-21-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Delete the MigrationState parameter from migration_is_running and move it to the public API in misc.h. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-5-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 + migration/migration.h | 2 -- migration/migration.c | 10 ++++++---- migration/options.c | 4 ++-- migration/savevm.c | 2 +- system/dirtylimit.c | 2 +- target/riscv/kvm/kvm-cpu.c | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e1f1bf853e..7526977de6 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -106,6 +106,7 @@ int migration_call_notifiers(MigrationState *s, MigrationEventType type, bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); +bool migration_is_running(void); /* ...and after the device transmission */ /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ bool migration_in_incoming_postcopy(void); diff --git a/migration/migration.h b/migration/migration.h index 736460aa8b..e4983db9c9 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -479,8 +479,6 @@ bool migrate_has_error(MigrationState *s); void migrate_fd_connect(MigrationState *s, Error *error_in); -bool migration_is_running(int state); - int migrate_init(MigrationState *s, Error **errp); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ diff --git a/migration/migration.c b/migration/migration.c index 17859cbaee..546ba86c63 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1103,9 +1103,11 @@ bool migration_is_setup_or_active(void) } } -bool migration_is_running(int state) +bool migration_is_running(void) { - switch (state) { + MigrationState *s = current_migration; + + switch (s->state) { case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: @@ -1477,7 +1479,7 @@ static void migrate_fd_cancel(MigrationState *s) do { old_state = s->state; - if (!migration_is_running(old_state)) { + if (!migration_is_running()) { break; } /* If the migration is paused, kick it out of the pause */ @@ -1962,7 +1964,7 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, return true; } - if (migration_is_running(s->state)) { + if (migration_is_running()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return false; } diff --git a/migration/options.c b/migration/options.c index 40eb930940..642cfb00a3 100644 --- a/migration/options.c +++ b/migration/options.c @@ -681,7 +681,7 @@ bool migrate_cap_set(int cap, bool value, Error **errp) MigrationState *s = migrate_get_current(); bool new_caps[MIGRATION_CAPABILITY__MAX]; - if (migration_is_running(s->state)) { + if (migration_is_running()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return false; } @@ -725,7 +725,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, MigrationCapabilityStatusList *cap; bool new_caps[MIGRATION_CAPABILITY__MAX]; - if (migration_is_running(s->state) || migration_in_colo_state()) { + if (migration_is_running() || migration_in_colo_state()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } diff --git a/migration/savevm.c b/migration/savevm.c index 76b57a9888..388d7af7cd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1706,7 +1706,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) MigrationState *ms = migrate_get_current(); MigrationStatus status; - if (migration_is_running(ms->state)) { + if (migration_is_running()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return -EINVAL; } diff --git a/system/dirtylimit.c b/system/dirtylimit.c index 051e0311c1..1622bb7426 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -451,7 +451,7 @@ static bool dirtylimit_is_allowed(void) { MigrationState *ms = migrate_get_current(); - if (migration_is_running(ms->state) && + if (migration_is_running() && (!qemu_thread_is_self(&ms->thread)) && migrate_dirty_limit() && dirtylimit_in_service()) { diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index c7afdb1e81..cda7d78a77 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -44,7 +44,7 @@ #include "kvm_riscv.h" #include "sbi_ecall_interface.h" #include "chardev/char-fe.h" -#include "migration/migration.h" +#include "migration/misc.h" #include "sysemu/runstate.h" #include "hw/riscv/numa.h" @@ -729,7 +729,7 @@ static void kvm_riscv_put_regs_timer(CPUState *cs) * frequency. Therefore, we should check whether they are the same here * during the migration. */ - if (migration_is_running(migrate_get_current()->state)) { + if (migration_is_running()) { KVM_RISCV_GET_TIMER(cs, frequency, reg); if (reg != env->kvm_timer_frequency) { error_report("Dst Hosts timer frequency != Src Hosts"); From patchwork Mon Mar 11 21:59:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589387 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 670A8C54E58 for ; Mon, 11 Mar 2024 22:11:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjni1-000285-1I; Mon, 11 Mar 2024 18:01:25 -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 1rjngi-0000af-9L for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:05 -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 1rjngg-00043y-G4 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194401; 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=/rL6j1uu8QRSoTX9y8l1g+EBtq/hMZ1TFKKu6d9s4aA=; b=cnr4c5mhv1jmScm0oz9I7DLDr3vfHUQf9HHDLgE6PnXTNpAOMHo/jdkEzzdtn/zkEXtMTK mFvgFXjuS/ZjJRYI6ltm8mYIVJ7oF6EOT0urhB1KONpImnaFe+kmBZj/5dARfV1+wfVUhy MqMALbZFgK7KEjCC8Q2KZlI4FAVA69Y= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-303-1hGtw9PZMHuct1PVIV5Kuw-1; Mon, 11 Mar 2024 18:00:00 -0400 X-MC-Unique: 1hGtw9PZMHuct1PVIV5Kuw-1 Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-7dadf2f724aso283637241.1 for ; Mon, 11 Mar 2024 15:00:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194399; x=1710799199; 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=/rL6j1uu8QRSoTX9y8l1g+EBtq/hMZ1TFKKu6d9s4aA=; b=QFZSfIToL6i7S1SSQ5zLzqyD7U44eek8TcsWMSuSv7G6xObViyDS31xul6NFWM3xih DWTttFi9MzUi7klGu26A1deASdACWvrYkfWZS8qAZsHZHQYXqPyhGfATlNG02tNbNhi6 dpZ6CsXlDJoptGTRLc4rTpVTCrFs4IcO/aKBkijtO27RdDt7M34+g5/Zn8eqqKB6WpSr FFHDD8uFhEla/9l5jAQn9OKBrTtQFRni7HJ2SS7OnSUMXriKNWyE76JlzQ163oBPluZG 7HqUm5eKvD5PMbYbeChV7WtSROZVuKRYgdknS4h10OqPf6X3J7CK0OI1hstHttPSXHpc ENAw== X-Gm-Message-State: AOJu0YyR0x1s0Z/DdGPgLVUpUbZHG6w1n1PXP1eSqjqL0dribFR4SkZo V5ngdxNsVZ5AuvaW8H7JDNub3Xd5ogsbmWXMv/oAvShvZeF5tDveif/FuJuwgsq7ZGQ93qqIxlE 4hq28TdYh+NF2uDZ/uo9xZ5LrGz8C7Jq3jphi6/WXF0SYdnez4xXDeiBTIGy64l5gxGmG/ias/S IVu9w/3EW8KGQlMC8s0P/4o3kPMd4BmIpgVQ== X-Received: by 2002:a67:ef8f:0:b0:473:2819:36b7 with SMTP id r15-20020a67ef8f000000b00473281936b7mr3899053vsp.1.1710194399258; Mon, 11 Mar 2024 14:59:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQ9eDbklkf8lao26lC4p3ePnMkQ0/VPWRRE8mrFqdJXKE7DXSqhlH8iPtb9Q15Lv6fdjONVA== X-Received: by 2002:a67:ef8f:0:b0:473:2819:36b7 with SMTP id r15-20020a67ef8f000000b00473281936b7mr3899029vsp.1.1710194398813; Mon, 11 Mar 2024 14:59:58 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:58 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 21/34] migration: export vcpu_dirty_limit_period Date: Mon, 11 Mar 2024 17:59:12 -0400 Message-ID: <20240311215925.40618-22-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Define and export vcpu_dirty_limit_period to eliminate a dependency on MigrationState. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-6-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/client-options.h | 1 + migration/options.c | 7 +++++++ system/dirtylimit.c | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/migration/client-options.h b/include/migration/client-options.h index 887fea1565..59f4b55cf4 100644 --- a/include/migration/client-options.h +++ b/include/migration/client-options.h @@ -20,5 +20,6 @@ bool migrate_switchover_ack(void); /* parameters */ MigMode migrate_mode(void); +uint64_t migrate_vcpu_dirty_limit_period(void); #endif diff --git a/migration/options.c b/migration/options.c index 642cfb00a3..09178c6f60 100644 --- a/migration/options.c +++ b/migration/options.c @@ -924,6 +924,13 @@ const char *migrate_tls_hostname(void) return s->parameters.tls_hostname; } +uint64_t migrate_vcpu_dirty_limit_period(void) +{ + MigrationState *s = migrate_get_current(); + + return s->parameters.x_vcpu_dirty_limit_period; +} + uint64_t migrate_xbzrle_cache_size(void) { MigrationState *s = migrate_get_current(); diff --git a/system/dirtylimit.c b/system/dirtylimit.c index 1622bb7426..b0afaa0776 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -77,14 +77,13 @@ static bool dirtylimit_quit; static void vcpu_dirty_rate_stat_collect(void) { - MigrationState *s = migrate_get_current(); VcpuStat stat; int i = 0; int64_t period = DIRTYLIMIT_CALC_TIME_MS; if (migrate_dirty_limit() && migration_is_active()) { - period = s->parameters.x_vcpu_dirty_limit_period; + period = migrate_vcpu_dirty_limit_period(); } /* calculate vcpu dirtyrate */ From patchwork Mon Mar 11 21:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589372 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 ABBC5C5475B for ; Mon, 11 Mar 2024 22:04:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnh3-00010D-5B; Mon, 11 Mar 2024 18:00:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngk-0000gn-5t for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00: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 1rjngi-0004BH-BN for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194403; 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=THTiTAxd6rgV7ReJUkExaQ2OYvOSoENOQBQ/zZOVMUs=; b=TVzaSacUucR1PNoEnEFWm1QF4yZNr90LkxeSwiR8F8bydrugV5ZETk+jOUDFFcfUJYF5Un KuyfInDUIcy+UR/gJy0r0C7xp1qvfeoTpVuzLDy2q5FDf3Veh+usxuN/AGDvs65xu4PRqF 7dtPvcwJON7FHvD4o+BZnXPNq7mjRyo= 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-382-3VfiriHIN8OyYG9e9C8crg-1; Mon, 11 Mar 2024 18:00:01 -0400 X-MC-Unique: 3VfiriHIN8OyYG9e9C8crg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-690d3f5af86so4505906d6.0 for ; Mon, 11 Mar 2024 15:00:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194401; x=1710799201; 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=THTiTAxd6rgV7ReJUkExaQ2OYvOSoENOQBQ/zZOVMUs=; b=O42KEbYoHtwZlier/D5NVFTOVC5teVD/qzhCq9P9Vo4LWHrfz7n6zyiWGNwbTag9Fk aC8tqmHvoNx5217ZtP9V7YxGJNRDgovYMMJocKtXEdXUukI6lwWJ5s3JmfE/CSKQ4PiJ SDXD4hQPCs+Pr+5gISTwgxABz1ToWxAJIRXc6vU+uRMo1kBxdDsi5iAdnX3ImbJWyGVQ ke/LqtgvZfqyumOSqkdFQbxPwywVHzFRdtUZjy6QflkXlZah91wWdfMUVgJQ9ZfFGO7F lUHyRVZyKInQVv6qgo4Pk94akXIirlkFkT9N4ehmHyj2Fq/GizHQx1UQx/8iLx6hXqjO y09Q== X-Gm-Message-State: AOJu0Yxrhz72w/7zfmqxqXiUBp4TXSqIKTCIhSJ7tnfF3Ihks0D+GpgE Bkxz/V6Geal3j+a6v1Q61RJnRRRIPHmnhuOB/vyD8c+jknjporEgMCiVOLVTcnjNfKqYp8cyc9k HWo8Hh/46sN0QDCAT5a7eBlSp2tT2HQxFGHtH6NWMIFSFiA2rbQxHoi+sPFl7qrCOldjyrmYrOo KiCtQMoGCi1ibY6V6aT7voUmQru+vb6H7W8w== X-Received: by 2002:a0c:fa91:0:b0:690:d74d:7e6d with SMTP id o17-20020a0cfa91000000b00690d74d7e6dmr3081281qvn.3.1710194400901; Mon, 11 Mar 2024 15:00:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3DZYbMlwaBNcEenBSc9RXyxg2cLRlFPSBH6poWmfNscAFHMLO5ucsnw4NdmHcP2yPlqheeQ== X-Received: by 2002:a0c:fa91:0:b0:690:d74d:7e6d with SMTP id o17-20020a0cfa91000000b00690d74d7e6dmr3081256qvn.3.1710194400388; Mon, 11 Mar 2024 15:00:00 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.14.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:59:59 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 22/34] migration: migration_thread_is_self Date: Mon, 11 Mar 2024 17:59:13 -0400 Message-ID: <20240311215925.40618-23-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: Steve Sistare Define and export migration_thread_is_self to eliminate a dependency on MigrationState. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-7-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 + migration/migration.c | 7 +++++++ system/dirtylimit.c | 5 +---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 7526977de6..c4b5416357 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -61,6 +61,7 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(void); +bool migration_thread_is_self(void); bool migration_is_setup_or_active(void); bool migrate_mode_is_cpr(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 546ba86c63..afe72af0b1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1647,6 +1647,13 @@ bool migration_is_active(void) s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); } +bool migration_thread_is_self(void) +{ + MigrationState *s = current_migration; + + return qemu_thread_is_self(&s->thread); +} + bool migrate_mode_is_cpr(MigrationState *s) { return s->parameters.mode == MIG_MODE_CPR_REBOOT; diff --git a/system/dirtylimit.c b/system/dirtylimit.c index b0afaa0776..ab20da34bb 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -25,7 +25,6 @@ #include "sysemu/kvm.h" #include "trace.h" #include "migration/misc.h" -#include "migration/migration.h" /* * Dirtylimit stop working if dirty page rate error @@ -448,10 +447,8 @@ static void dirtylimit_cleanup(void) */ static bool dirtylimit_is_allowed(void) { - MigrationState *ms = migrate_get_current(); - if (migration_is_running() && - (!qemu_thread_is_self(&ms->thread)) && + !migration_thread_is_self() && migrate_dirty_limit() && dirtylimit_in_service()) { return false; From patchwork Mon Mar 11 21:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589375 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 43EE1C5475B for ; Mon, 11 Mar 2024 22:05:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnhy-0001yD-QF; Mon, 11 Mar 2024 18:01:23 -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 1rjngl-0000hB-IW for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00: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 1rjngj-0004FA-M8 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194405; 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=kYBBBuT1r3W8EJmKlTmpyZe13YIEZba26k1f9sq+pH8=; b=CDtfZe1W4a5H6UHQY77+lgE8EFuF6E5G4MQVHqbFwyo8owc7gbflqCGgRpyuHKT3iT653U lHg7cqCmsMlEBSzfylZTTPb7i/Z2QmRk3pqfoZmCTvhltoy5dKwXs5XeWYIh4OB0yHiIlV aGdlrfiuGdRluo5vBAFw/+8n08Opy/I= 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-534-ro7FiHiSPNKtyrYm8xcSig-1; Mon, 11 Mar 2024 18:00:02 -0400 X-MC-Unique: ro7FiHiSPNKtyrYm8xcSig-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-690c19ee50bso1968766d6.0 for ; Mon, 11 Mar 2024 15:00:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194402; x=1710799202; 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=kYBBBuT1r3W8EJmKlTmpyZe13YIEZba26k1f9sq+pH8=; b=jvS4CB3QRnlvTfEd3g30kbIStL0AZTEXKrQlXTUJKO/pmplaqW6+A7OafqXkWREIvG V/Co0VebG77P3FZgWyrypI1BjgO34lBFdVc4GPWV9I6wsIYDElnau3NYlhsBgw3/U0lw LrKV5ERCkcA2J21PtI+T5OaH2vSFDtwRZ4VNg/lZUe8ndDp7F87MPhs87x5IFS557dWM ujAB5z0RlaVboPyohy5qHmiqWb+mcwmfLuS4C9JAxJ/h35Q6RLKGhwf8k1Qw4L6sxD+v z4k4ovDI1WfSTQvmvX+dwqkYe2104UERtA5DXPClLm0/X6yiGFewtopyWzyBzusBvaz2 5qkQ== X-Gm-Message-State: AOJu0YyWGsocFGkC/3HBf0UlVYM9lTf70o/AslyjFtyYcZpMc5KnXg+6 FK9jaSIMgAJ6Kj75wq/xzN4uFoYSY6w/8kBfEP4IfQU4+J2mby/HALyXPfTnVjCuj5UOdpXUA0/ moIF/An+NU9ioggTHrQ7U5dGbQW5PJDmhN9h3zm9BZ2lqhXodnJY8uv/8QZRn/ZR5GPQj+TmvfD aSoosJAtHRfgyVs5KnCM/NuEdZtMXDN9i73w== X-Received: by 2002:ad4:58c5:0:b0:68f:1c80:d78e with SMTP id dh5-20020ad458c5000000b0068f1c80d78emr7453794qvb.0.1710194402037; Mon, 11 Mar 2024 15:00:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYMhtwNVbDITCwQRxVxFOrIlsV9jOD0yvJEQCL8Ij1gQ3Z9x/IJbFwL8oup7zt3dtUynxCYw== X-Received: by 2002:ad4:58c5:0:b0:68f:1c80:d78e with SMTP id dh5-20020ad458c5000000b0068f1c80d78emr7453758qvb.0.1710194401588; Mon, 11 Mar 2024 15:00:01 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:01 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 23/34] migration: migration_is_device Date: Mon, 11 Mar 2024 17:59:14 -0400 Message-ID: <20240311215925.40618-24-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: Steve Sistare Define and export migration_is_device to eliminate a dependency on MigrationState. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-8-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 + hw/vfio/common.c | 4 +--- migration/migration.c | 7 +++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index c4b5416357..28cfaed2c7 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -61,6 +61,7 @@ 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_thread_is_self(void); bool migration_is_setup_or_active(void); bool migrate_mode_is_cpr(MigrationState *); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 2dbbf62e15..de010680ff 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -180,10 +180,8 @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev) static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) { VFIODevice *vbasedev; - MigrationState *ms = migrate_get_current(); - if (!migration_is_active() && - ms->state != MIGRATION_STATUS_DEVICE) { + if (!migration_is_active() && !migration_is_device()) { return false; } diff --git a/migration/migration.c b/migration/migration.c index afe72af0b1..db1e627848 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1647,6 +1647,13 @@ bool migration_is_active(void) s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); } +bool migration_is_device(void) +{ + MigrationState *s = current_migration; + + return s->state == MIGRATION_STATUS_DEVICE; +} + bool migration_thread_is_self(void) { MigrationState *s = current_migration; From patchwork Mon Mar 11 21:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589383 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 31D75C5475B for ; Mon, 11 Mar 2024 22:10:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjniZ-0003cW-AY; Mon, 11 Mar 2024 18:02:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngo-0000ia-8H for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:10 -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 1rjngm-0004Gx-4I for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194407; 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=Iq0LE+iqlQL+6JCbSe4i1yV9MLceNgsbOkUlbT+WpVE=; b=X+rlK0T5fdj1/TNjKQPsFeftmlEIOGyXldcUff038MIMT1Ot/7LW6UmryatatUSBU+XZO7 /2ZBRdskv/SIHubuwUl/sjf81B+3Vyi0XT2rO+MhBC/SSWanoIYsVRU1t6lE+3AXeMXIIb rNLy1VUY9LkhrI3wDgYJ41mo2OtoCpg= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-2j1ARF9UPeCqDYlVtmAGLQ-1; Mon, 11 Mar 2024 18:00:05 -0400 X-MC-Unique: 2j1ARF9UPeCqDYlVtmAGLQ-1 Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-7dbbeb665a4so296896241.1 for ; Mon, 11 Mar 2024 15:00:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194404; x=1710799204; 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=Iq0LE+iqlQL+6JCbSe4i1yV9MLceNgsbOkUlbT+WpVE=; b=bIaOkAIXUBthOw2eKI33nbkK2pNA1I/ElI9lMrxyrKFPIOMlzBqPSUlil+yLa2fkKr UGrddwYAuOnl4cCyudo4rRkOg//6dc95TCUNOQspcjlPFa+pOxqamD6JnT4jlXjKZZ5o 55vumzdezWYaPz/UqBvRDqGl9HdJqcp6+dVj/J+BFIMNzU3jnGo0zcLOUlAFnkbW6pwr nOdsVA7HiNV8eQ5iD7u9BOBHn8r+rr5EiDtCqCZYwxbzAZ15dRqFsZgLHWQjQHtY47H8 SQf238OpB3/zst2q9few6EdniSJcb1g6aVecCn13yLWeaNJySuabUIeZQpU6qTnpmlrA eMbQ== X-Gm-Message-State: AOJu0Yw7Z8xU7zQ2C8TlMm4L6upFc4emWbBmF4qI26gTDCn4c/DbsApV g/6oO5y07WKp4SK4HgVWf1XKOgfAn5emIDCIYqlEE/l+MNclnXQWbbLhBbDtY8Nsb0hMmNc3gIm C7txSrtGq8DjAgD2yQnbXsXewhD9U9qJYd188NwLpYS1TtUGguPE5HKBH1V3F/fL9vyIWbG3cLf lScFmtONHO82aKE3tBZqQpuyunk+rMiPuE0Q== X-Received: by 2002:a67:fada:0:b0:472:e0f6:f3c1 with SMTP id g26-20020a67fada000000b00472e0f6f3c1mr4275458vsq.2.1710194403310; Mon, 11 Mar 2024 15:00:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0BAcimaAKH4NWH2PuxSa5oqdyY2y8p0uaKaz/ivqNI+H/8ZklqroVjXreqa6Xb5iZ3uE6Uw== X-Received: by 2002:a67:fada:0:b0:472:e0f6:f3c1 with SMTP id g26-20020a67fada000000b00472e0f6f3c1mr4275431vsq.2.1710194402865; Mon, 11 Mar 2024 15:00:02 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:02 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 24/34] migration: migration_file_set_error Date: Mon, 11 Mar 2024 17:59:15 -0400 Message-ID: <20240311215925.40618-25-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Define and export migration_file_set_error to eliminate a dependency on MigrationState. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-9-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 2 ++ hw/vfio/common.c | 9 +-------- hw/vfio/migration.c | 11 +++-------- migration/migration.c | 11 +++++++++++ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 28cfaed2c7..e521cd5229 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -109,6 +109,8 @@ bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); bool migration_is_running(void); +void migration_file_set_error(int err); + /* ...and after the device transmission */ /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ bool migration_in_incoming_postcopy(void); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index de010680ff..b44204eade 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -39,7 +39,6 @@ #include "sysemu/runstate.h" #include "trace.h" #include "qapi/error.h" -#include "migration/migration.h" #include "migration/misc.h" #include "migration/blocker.h" #include "migration/qemu-file.h" @@ -150,14 +149,8 @@ bool vfio_viommu_preset(VFIODevice *vbasedev) static void vfio_set_migration_error(int err) { - MigrationState *ms = migrate_get_current(); - if (migration_is_setup_or_active()) { - WITH_QEMU_LOCK_GUARD(&ms->qemu_file_lock) { - if (ms->to_dst_file) { - qemu_file_set_error(ms->to_dst_file, err); - } - } + migration_file_set_error(err); } } diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 49c0016add..a15fd486c6 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -17,13 +17,12 @@ #include "sysemu/runstate.h" #include "hw/vfio/vfio-common.h" -#include "migration/migration.h" +#include "migration/misc.h" #include "migration/savevm.h" #include "migration/vmstate.h" #include "migration/qemu-file.h" #include "migration/register.h" #include "migration/blocker.h" -#include "migration/misc.h" #include "qapi/error.h" #include "exec/ramlist.h" #include "exec/ram_addr.h" @@ -714,9 +713,7 @@ static void vfio_vmstate_change_prepare(void *opaque, bool running, * Migration should be aborted in this case, but vm_state_notify() * currently does not support reporting failures. */ - if (migrate_get_current()->to_dst_file) { - qemu_file_set_error(migrate_get_current()->to_dst_file, ret); - } + migration_file_set_error(ret); } trace_vfio_vmstate_change_prepare(vbasedev->name, running, @@ -746,9 +743,7 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state) * Migration should be aborted in this case, but vm_state_notify() * currently does not support reporting failures. */ - if (migrate_get_current()->to_dst_file) { - qemu_file_set_error(migrate_get_current()->to_dst_file, ret); - } + migration_file_set_error(ret); } trace_vfio_vmstate_change(vbasedev->name, running, RunState_str(state), diff --git a/migration/migration.c b/migration/migration.c index db1e627848..216f63d62b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3038,6 +3038,17 @@ static MigThrError postcopy_pause(MigrationState *s) } } +void migration_file_set_error(int err) +{ + MigrationState *s = current_migration; + + WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { + if (s->to_dst_file) { + qemu_file_set_error(s->to_dst_file, err); + } + } +} + static MigThrError migration_detect_error(MigrationState *s) { int ret; From patchwork Mon Mar 11 21:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13589365 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 A07D7C5475B for ; Mon, 11 Mar 2024 22:03:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnhR-0001HB-RD; Mon, 11 Mar 2024 18:00:50 -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 1rjngp-0000nL-NN for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:11 -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 1rjngm-0004HD-Vu for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194408; 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=e+7z8zapbeRNv2trHhs1cLEOfHBQW8nwm253n8XWXpE=; b=LR+vfOPVpsq7IkSJJ6Qy0Jh9J+lHjfxbLhLj003/gdw/IeF6btWjNCShWy4PcXcibcATBr SE1abMr7BdJBjrZC4ZaDcxyrR8VSu3Gy4ACN8NWClXkPQIngt0gCquVd2Ob5OdJcVoffSc Q4PKYJKAfqni2alnRHzgNFt0C1bn4VM= 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-382-qpUt04RPNc2iA3kFBkbKUg-1; Mon, 11 Mar 2024 18:00:05 -0400 X-MC-Unique: qpUt04RPNc2iA3kFBkbKUg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6818b8cb840so15028106d6.1 for ; Mon, 11 Mar 2024 15:00:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194404; x=1710799204; 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=e+7z8zapbeRNv2trHhs1cLEOfHBQW8nwm253n8XWXpE=; b=wSkMfWdRtUIHaVK383shYpoanHdGV4olaKrR/WGGhDdoEVWyUitPluF9qrx5vaWspR i/hDQ65N1LXHdQF/hpjVO/KNGuBD82RyayYyNUVO+Q4xj1p96teva4P0uKU4r6qPal64 /H1Z5rjpmP708mpo7a5gGUvgBekmHTZnJJsIvp1ez3P6RPx3b0Zt1m/ukByUh0/eBLB0 VUs8EGZDzMQngeuBJPlcXUdTa/evATvvMnMgyOJGydk/5vyXunaZjcwfC7JDdvu26utR nttWMRsyecR4pJH44cPWpFjqtamtLB4t8+haNLUSzJ2Rse5q+zR53v6kmDoAu41abKO3 nt9g== X-Gm-Message-State: AOJu0Yx4+ldY4gJJgrx3PYnVz/S2ZqAxIPK+9sYTtDEBuBi0QXqPDMRb lCl8ktNMkmMIqtkYK1fv2AtAN/egVqbtKASydOGnboLz7k8TIiq/a63TNbRkotQ9O43fE3VXqf0 3v5YWPDkyxXeUlmKLTRgLAQ0c0IjDJcrIzpZsmh6AVMbRxpDQfb7EBtFynndGwMOIxxtLECn+6s Y5FFpcyBrFgXFzI98hrcYcMgVV//AqHvqw5A== X-Received: by 2002:ad4:5bec:0:b0:690:e47c:9bee with SMTP id k12-20020ad45bec000000b00690e47c9beemr407188qvc.4.1710194404578; Mon, 11 Mar 2024 15:00:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1VfYyBAPHBu1KugNzJwJ+S3wiVaovQYm2Cfi6Y0taRC/52wi3infIRzm50ZphWSVjaAmb1A== X-Received: by 2002:ad4:5bec:0:b0:690:e47c:9bee with SMTP id k12-20020ad45bec000000b00690e47c9beemr407156qvc.4.1710194404131; Mon, 11 Mar 2024 15:00:04 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:03 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 25/34] migration: privatize colo interfaces Date: Mon, 11 Mar 2024 17:59:16 -0400 Message-ID: <20240311215925.40618-26-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Remove private migration interfaces from net/colo-compare.c and push them to migration/colo.c. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-10-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- migration/colo.c | 17 +++++++++++------ net/colo-compare.c | 3 +-- stubs/colo.c | 1 - 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 315e31fe32..84632a603e 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -63,9 +63,9 @@ static bool colo_runstate_is_stopped(void) return runstate_check(RUN_STATE_COLO) || !runstate_is_running(); } -static void colo_checkpoint_notify(void *opaque) +static void colo_checkpoint_notify(void) { - MigrationState *s = opaque; + MigrationState *s = migrate_get_current(); int64_t next_notify_time; qemu_event_set(&s->colo_checkpoint_event); @@ -74,10 +74,15 @@ static void colo_checkpoint_notify(void *opaque) timer_mod(s->colo_delay_timer, next_notify_time); } +static void colo_checkpoint_notify_timer(void *opaque) +{ + colo_checkpoint_notify(); +} + void colo_checkpoint_delay_set(void) { if (migration_in_colo_state()) { - colo_checkpoint_notify(migrate_get_current()); + colo_checkpoint_notify(); } } @@ -162,7 +167,7 @@ static void primary_vm_do_failover(void) * kick COLO thread which might wait at * qemu_sem_wait(&s->colo_checkpoint_sem). */ - colo_checkpoint_notify(s); + colo_checkpoint_notify(); /* * Wake up COLO thread which may blocked in recv() or send(), @@ -518,7 +523,7 @@ out: static void colo_compare_notify_checkpoint(Notifier *notifier, void *data) { - colo_checkpoint_notify(data); + colo_checkpoint_notify(); } static void colo_process_checkpoint(MigrationState *s) @@ -642,7 +647,7 @@ void migrate_start_colo_process(MigrationState *s) bql_unlock(); qemu_event_init(&s->colo_checkpoint_event, false); s->colo_delay_timer = timer_new_ms(QEMU_CLOCK_HOST, - colo_checkpoint_notify, s); + colo_checkpoint_notify_timer, NULL); qemu_sem_init(&s->colo_exit_sem, 0); colo_process_checkpoint(s); diff --git a/net/colo-compare.c b/net/colo-compare.c index f2dfc0ebdc..c4ad0ab71f 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -28,7 +28,6 @@ #include "sysemu/iothread.h" #include "net/colo-compare.h" #include "migration/colo.h" -#include "migration/migration.h" #include "util.h" #include "block/aio-wait.h" @@ -189,7 +188,7 @@ static void colo_compare_inconsistency_notify(CompareState *s) notify_remote_frame(s); } else { notifier_list_notify(&colo_compare_notifiers, - migrate_get_current()); + NULL); } } diff --git a/stubs/colo.c b/stubs/colo.c index 08c9f982d5..f8c069b739 100644 --- a/stubs/colo.c +++ b/stubs/colo.c @@ -2,7 +2,6 @@ #include "qemu/notify.h" #include "net/colo-compare.h" #include "migration/colo.h" -#include "migration/migration.h" #include "qemu/error-report.h" #include "qapi/qapi-commands-migration.h" From patchwork Mon Mar 11 21:59: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: 13589378 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 1BEB2C54E58 for ; Mon, 11 Mar 2024 22:08:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjni4-0002Ok-UB; Mon, 11 Mar 2024 18:01:29 -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 1rjngp-0000nU-PC for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00: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 1rjngn-0004HG-UH for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194408; 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=2OZEcnrxRNvKPm1DvrVRTFALc0OvjfuvU5sOoiUMpdc=; b=Kc3y99XE4uIInoZHuR7ptK2Fr0r/PR/nYJZoqzgPGjgzgYk2yvM6kV96YDiGJwNT2jX7Je okFqe1GreptC4dP8ekd8Dh39jwUe5Lg4EXxXfi0noBLJ/kyx+dbD3yZyXKd++AU5C2Zxz/ +MvKN7xEVzoTEn4vFxRkWomZ/TojxH0= 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-458-X6GrvQ-UMuieD-WPYlLCCg-1; Mon, 11 Mar 2024 18:00:06 -0400 X-MC-Unique: X6GrvQ-UMuieD-WPYlLCCg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690becce69eso10938186d6.1 for ; Mon, 11 Mar 2024 15:00:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194406; x=1710799206; 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=2OZEcnrxRNvKPm1DvrVRTFALc0OvjfuvU5sOoiUMpdc=; b=BLKK3bTXwjXpL+OE5Q9n+lmitiwmUAqs7kh1X5slOoEr4Tq44BQJcWfsWzOZIviP5N StE6/nTqF2xcIZAPO0fBXFIjcym9AgywbdVeDRxXT/eUG4I77jA29o6YyDDL7EmtcM+l +E2DWBuogxiDeqDjxBd8ltZlQrJhV85AlEL3to6fmKhtgRd/J8M/SsqYDvXThb6nv3XR OxXfp+IBlyWL4S0kIW+0GBqb2RRvfM+2xqFpL9QT2JYTJRvpftHXhPyjZghX9rCvlica BcHeIlquHuiV8jT0Ivu6/T6BoBEgEkC0HHpqnnPl+rw5CDBE/E9Q1gBtBBRJvJKEu/Z3 ePFw== X-Gm-Message-State: AOJu0YwC8HWq1CepB3dTu3R2zAT8QgtEuEBXyhFquN/nPpzkjLNya4MM MaIThSzT9PjRiyuKT4CzoqJt30fKzoausllYCycfyuubKcCQwM2iDijsox6SlA94amk1UXnnfy9 XwmRtN3CmB4ECTweY/PTLIJ8CLfayvBST+mgH3s0qk6V9R/w+oxmBWu53iU/Dl/rQnH35yZl3Fd dwqkb4iRBNHj9nL6omNQIPz6c7A77HxfA/BA== X-Received: by 2002:ad4:58c5:0:b0:690:a974:5b79 with SMTP id dh5-20020ad458c5000000b00690a9745b79mr7754134qvb.0.1710194405997; Mon, 11 Mar 2024 15:00:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDcHw0Svf4tCIp0dAh9DyX/XvaH3ed8lUOCGSOkQbv5VkrBrNhaVdH72AsUUIxHRVOKlOPOw== X-Received: by 2002:ad4:58c5:0:b0:690:a974:5b79 with SMTP id dh5-20020ad458c5000000b00690a9745b79mr7754102qvb.0.1710194405510; Mon, 11 Mar 2024 15:00:05 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:04 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 26/34] migration: delete unused accessors Date: Mon, 11 Mar 2024 17:59:17 -0400 Message-ID: <20240311215925.40618-27-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Steve Sistare Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-11-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 3 --- migration/migration.c | 10 ---------- 2 files changed, 13 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e521cd5229..d563d2c801 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -105,13 +105,10 @@ void migration_add_notifier_mode(NotifierWithReturn *notify, void migration_remove_notifier(NotifierWithReturn *notify); int migration_call_notifiers(MigrationState *s, MigrationEventType type, Error **errp); -bool migration_in_setup(MigrationState *); -bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); bool migration_is_running(void); void migration_file_set_error(int err); -/* ...and after the device transmission */ /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ bool migration_in_incoming_postcopy(void); /* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */ diff --git a/migration/migration.c b/migration/migration.c index 216f63d62b..644e073b7d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1548,16 +1548,6 @@ int migration_call_notifiers(MigrationState *s, MigrationEventType type, return ret; } -bool migration_in_setup(MigrationState *s) -{ - return s->state == MIGRATION_STATUS_SETUP; -} - -bool migration_has_finished(MigrationState *s) -{ - return s->state == MIGRATION_STATUS_COMPLETED; -} - bool migration_has_failed(MigrationState *s) { return (s->state == MIGRATION_STATUS_CANCELLED || From patchwork Mon Mar 11 21:59: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: 13589388 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 A51EEC54E58 for ; Mon, 11 Mar 2024 22:12:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnhV-0001Se-JU; Mon, 11 Mar 2024 18:00:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjngr-0000r8-6z for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:13 -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 1rjngo-0004HN-ET for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194409; 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=lIq9EpMeiKCu6O9A+NAt96bPDqnWgTrQUrVo9wmJlvA=; b=INCkRMXOUJaIBmC9rYfqomFd6aSQbReW39WvWbr3b4NQ1sQQ5Vkio3hyz53Eum48iqamZn 6z8Ky4qsQlr7qHMmkHG5Cfss+cNnMOjNQs+cr+uIbwutnDic3By+7rwDYVFdDTBoV7gP8D q/fOE6V5Wx3GDXMdBbpB1if2aHVTdzk= 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-321-v5fdqAhGNo-ntKNG1vKUFA-1; Mon, 11 Mar 2024 18:00:08 -0400 X-MC-Unique: v5fdqAhGNo-ntKNG1vKUFA-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6818b8cb840so15028376d6.1 for ; Mon, 11 Mar 2024 15:00:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194407; x=1710799207; 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=lIq9EpMeiKCu6O9A+NAt96bPDqnWgTrQUrVo9wmJlvA=; b=aj3QQyKfTaqD+yZHvq2GgzFvAAPT2sI7qo1KmzyuKykP43GnGlA5PfyNM9Dqbog090 4ecxWeFNmXJcg003NNziqd3QInlGOnuXD6Om1ugxTTQvNFO3nWMuxX/jBWv/vpfacmhI LSoiWB7KVrtLNv0ci5EP72h5XP0ErjCCg4neFGZtlKzmBc9DHeE/R7ByGM4LY/c1IiuW +ukveLpb3HDJjvaR3FheXvYE/ofX1230klwTOmzj5O2bMzsRnLeC3VTCZ3AVFeVmhAoc 12yY4BNANbvAInj+i4AvBgbuTCX1GllrZMNqFgBem7Wt2fVTcxD/MB3cF5/nqiF+UMXz 2wZQ== X-Gm-Message-State: AOJu0YzIuGdxHEUqyHKug4mfrjndhTHikG6gMDUtEhUfDoe8oFQsaur2 pn/ElpMZFEAcZ++TSrf+JMfoTzYyqssWgswaqtkTR54LmQCjoIpdj0aa4LFtyFr8eyemP9gJEqC lZ58GW1k808lMm7fnCSQNKow/0lAyqK0eNTbs4+L5e6pEK1nnJfYGVEztBiLZn4nePDt0qYhZqb daTMbfEgX9bZBC+t2MnHRvrrozKmymoBDq7w== X-Received: by 2002:ad4:4e6c:0:b0:690:b47e:60e3 with SMTP id ec12-20020ad44e6c000000b00690b47e60e3mr7387753qvb.5.1710194407433; Mon, 11 Mar 2024 15:00:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGP0gNPDOXkCdBgWOwrPCTgBobQvqvkHuhDlmEBkxrKeGWCqT/ju5dfVLAnkUisfWvZh7JHaA== X-Received: by 2002:ad4:4e6c:0:b0:690:b47e:60e3 with SMTP id ec12-20020ad44e6c000000b00690b47e60e3mr7387714qvb.5.1710194406897; Mon, 11 Mar 2024 15:00:06 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:06 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Steve Sistare Subject: [PULL 27/34] migration: purge MigrationState from public interface Date: Mon, 11 Mar 2024 17:59:18 -0400 Message-ID: <20240311215925.40618-28-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, 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_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: Steve Sistare Move remaining MigrationState references from the public file misc.h to the private file migration.h. Signed-off-by: Steve Sistare Link: https://lore.kernel.org/r/1710179338-294359-12-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 6 ++---- migration/migration.h | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index d563d2c801..c9e200f4eb 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -64,7 +64,6 @@ bool migration_is_active(void); bool migration_is_device(void); bool migration_thread_is_self(void); bool migration_is_setup_or_active(void); -bool migrate_mode_is_cpr(MigrationState *); typedef enum MigrationEventType { MIG_EVENT_PRECOPY_SETUP, @@ -103,16 +102,15 @@ void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode); void migration_remove_notifier(NotifierWithReturn *notify); -int migration_call_notifiers(MigrationState *s, MigrationEventType type, - Error **errp); -bool migration_has_failed(MigrationState *); bool migration_is_running(void); void migration_file_set_error(int err); /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ bool migration_in_incoming_postcopy(void); + /* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */ bool migration_incoming_postcopy_advised(void); + /* True if background snapshot is active */ bool migration_in_bg_snapshot(void); diff --git a/migration/migration.h b/migration/migration.h index e4983db9c9..8045e39c26 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -26,6 +26,7 @@ #include "qom/object.h" #include "postcopy-ram.h" #include "sysemu/runstate.h" +#include "migration/misc.h" struct PostcopyBlocktimeContext; @@ -479,12 +480,17 @@ bool migrate_has_error(MigrationState *s); void migrate_fd_connect(MigrationState *s, Error *error_in); +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp); + int migrate_init(MigrationState *s, Error **errp); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); bool migration_postcopy_is_alive(int state); MigrationState *migrate_get_current(void); +bool migration_has_failed(MigrationState *); +bool migrate_mode_is_cpr(MigrationState *); uint64_t ram_get_total_transferred_pages(void); From patchwork Mon Mar 11 21:59: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: 13589373 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 27E30C5475B for ; Mon, 11 Mar 2024 22:04:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnho-0001b7-3f; Mon, 11 Mar 2024 18:01:19 -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 1rjngr-0000rP-PM for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:13 -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 1rjngq-0004Hd-0W for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194411; 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=LgyHPzF/xmcyuUnqn1KinqQdKLq8XEiNwDRL/hsnc9k=; b=Q815McEMWocxBdr4+MASRneP1GBpS0VJ11U4X2Hy8bOazxNm3wNYDisonPWHOVO2gyH5Rl m6f7bmTXF4AmWpDtWz5rScFaEWe1F7urxs95gt85YZBYIxB7JnyZbfyLumWGhodegfD7pd fPG9TR/rbrFlJfYWfJu0PIocIXtjEuw= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-CneGIuaXPhGATvVsqo8f-Q-1; Mon, 11 Mar 2024 18:00:09 -0400 X-MC-Unique: CneGIuaXPhGATvVsqo8f-Q-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-7da965e700fso482477241.1 for ; Mon, 11 Mar 2024 15:00:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194409; x=1710799209; 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=LgyHPzF/xmcyuUnqn1KinqQdKLq8XEiNwDRL/hsnc9k=; b=X8Ms7bMT2+S8/c4QLeIFAmKGQkUM+Siw/qoGoEDBv/qAnHK8IHe8xqDl+hs7nL9hQH ZAOTOp9bsIjfy2iBeFMKqNgrQO9ok2HdLAgGChHx1umy1BDjTesfCWAVPaXqbZyuXCW3 HWjHcmEJwunNOeZDMu9wYwUlu7c3PYmbdOdj9Nf68ccjDpAlYBZR2jg14FsBulVMRZtk oPmnMbVKQqqowdbA4NmMmIKUWY1fGkdqszTyXWYp0j8/+zy9wahueACCZyjvOKgq+XUI B0yM68nYRlFsr4qq9NMfiixMuqM73N79n5AFJMuQv4Vb2EvGIbCpgkq6I7+cHR0oey0f fvIg== X-Gm-Message-State: AOJu0Yyqe/mkQRtnX3uZPR+ZsIfL0Dg+XJ4sscxyfE4IMVgYokILTUY+ zzZ77iP01zYKzEBfL0v3zFCaxTZqECRN5pldmdiZExAnxpKKZkdRVqytjcHrRLnGLWe9tAHh9Cy DXO6Ef4FqoVh+LUk+HPp/GGI/XHjjwUrnuC8O83lIqzeMUpiB3+q/LFjZTvHXc3r4Z7aGSp4les x5IjmEgDvqrGnmaMCIDY9r90cR9p7ckegpGA== X-Received: by 2002:a05:6102:5127:b0:473:1ac8:5ef5 with SMTP id bm39-20020a056102512700b004731ac85ef5mr307656vsb.2.1710194409071; Mon, 11 Mar 2024 15:00:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWoMYWpRefpIPYtlLxLHpZ3dnw8fpsVZGbhEl6K0NlO2iDafEQvp4Hkv4W1ty2lZhLvWTdxg== X-Received: by 2002:a05:6102:5127:b0:473:1ac8:5ef5 with SMTP id bm39-20020a056102512700b004731ac85ef5mr307632vsb.2.1710194408664; Mon, 11 Mar 2024 15:00:08 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:07 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit Subject: [PULL 28/34] migration/multifd: Allow zero pages in file migration Date: Mon, 11 Mar 2024 17:59:19 -0400 Message-ID: <20240311215925.40618-29-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fabiano Rosas Currently, it's an error to have no data pages in the multifd file migration because zero page detection is done in the migration thread and zero pages don't reach multifd. This is enforced with the pages->num assert. We're about to add zero page detection on the multifd thread. Fix the file_write_ramblock_iov() to stop considering p->iovs_num=0 an error. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240311180015.3359271-2-hao.xiang@linux.dev Signed-off-by: Peter Xu --- migration/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/file.c b/migration/file.c index 5054a60851..b0b963e0ce 100644 --- a/migration/file.c +++ b/migration/file.c @@ -159,7 +159,7 @@ void file_start_incoming_migration(FileMigrationArgs *file_args, Error **errp) int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, int niov, RAMBlock *block, Error **errp) { - ssize_t ret = -1; + ssize_t ret = 0; int i, slice_idx, slice_num; uintptr_t base, next, offset; size_t len; From patchwork Mon Mar 11 21:59: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: 13589381 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 26909C54E58 for ; Mon, 11 Mar 2024 22:10:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjni4-0002Hl-HP; Mon, 11 Mar 2024 18:01:28 -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 1rjngs-0000t9-Nx for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:15 -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 1rjngr-0004Hv-0t for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194412; 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=cOcK8yDXWw/GICYwFOPKzQtDbOuwzT4S8Ube17pNJRY=; b=NwonFKupMjfCNAeuVXE1H14p5Dvf5cH7BQiSQw5Y02YsgMiijPQJ6onH8WzJaprEx7DkCX 22lFgzx/FNUa2YQPU2LItsdapx7oAiq2GhSjgqTAhlSSjkcf1BIWT2SqGmn/t2nW3qhND3 v9T8JGbH91/VWs7YKOIPe4li+WCHUcU= 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-510-XhK9LIcHPmSJAafnghKSgQ-1; Mon, 11 Mar 2024 18:00:11 -0400 X-MC-Unique: XhK9LIcHPmSJAafnghKSgQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-690c19ee50bso1969276d6.0 for ; Mon, 11 Mar 2024 15:00:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194410; x=1710799210; 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=cOcK8yDXWw/GICYwFOPKzQtDbOuwzT4S8Ube17pNJRY=; b=mRZ7PTySL0WcDGDzlUj5gfwtCOLNVSoNCprai99FlDFn9+JN32xJ79QKfmJRV+7exN uH6AeMQYgzr5a6yutbYrs2le8wHcdeUodve6gJed95ioKeJvdXAweLrL+ibhKLLdQZgr zMpKhE/IdRA0IrVpe9VClhz1RPzxomk+D1dYQTQoNChQ8cHRkrO7azKRruGh567nL64Q ZetrV3fu3g66u32YY+SUL3TEllJAQ5hQ3TnrAHeZHkSGpFVcooFDHMslqbUEDQZ9JnHM c6peuGidmQuWK7NYxGXG97lRjessdAYHsVAs6xJUfcrHomqbzkAB2T0zM3CsLCD7gq3Q HNCg== X-Gm-Message-State: AOJu0YxDu64JOuicv7HSHPn4xxUhna6//55+/Tad/KhgYKk9G9h8rW6d Yl614lrppwkyS8EKOmGvAknKBTtExbL3owzMNDNtl1j9pby80J2sBJEzUKH8e4yt5gwpv1mla41 Zg8Coo5WGloEQoT8XPGJ+i07gfzyx1KcJm+665r8DDAuYUaB3MvADMI88cVWcz5/fkoEliSKkf0 3E2qqHkELj8GJP48s+SyaVuKcjj/1gUfx3ew== X-Received: by 2002:a05:6214:b0d:b0:690:b47e:6254 with SMTP id u13-20020a0562140b0d00b00690b47e6254mr7031146qvj.2.1710194410288; Mon, 11 Mar 2024 15:00:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1XAER6DsN8oow9CZ82i3jzaz+b8yjGED9gMcZS8Y0QgluQFZ8aEtW630Sl/FkYbr9alBYFA== X-Received: by 2002:a05:6214:b0d:b0:690:b47e:6254 with SMTP id u13-20020a0562140b0d00b00690b47e6254mr7031108qvj.2.1710194409789; Mon, 11 Mar 2024 15:00:09 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:09 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit Subject: [PULL 29/34] migration/multifd: Allow clearing of the file_bmap from multifd Date: Mon, 11 Mar 2024 17:59:20 -0400 Message-ID: <20240311215925.40618-30-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fabiano Rosas We currently only need to clear the mapped-ram file bitmap from the migration thread during save_zero_page. We're about to add support for zero page detection on the multifd thread, so allow ramblock_set_file_bmap_atomic() to also clear the bits. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240311180015.3359271-3-hao.xiang@linux.dev Signed-off-by: Peter Xu --- migration/ram.h | 3 ++- migration/multifd.c | 2 +- migration/ram.c | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/migration/ram.h b/migration/ram.h index b9ac0da587..08feecaf51 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -75,7 +75,8 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb, Error **errp); bool ramblock_page_is_discarded(RAMBlock *rb, ram_addr_t start); void postcopy_preempt_shutdown_file(MigrationState *s); void *postcopy_preempt_thread(void *opaque); -void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset); +void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset, + bool set); /* ram cache */ int colo_init_ram_cache(void); diff --git a/migration/multifd.c b/migration/multifd.c index bf9d483f7a..3ba922694e 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -115,7 +115,7 @@ static void multifd_set_file_bitmap(MultiFDSendParams *p) assert(pages->block); for (int i = 0; i < p->pages->num; i++) { - ramblock_set_file_bmap_atomic(pages->block, pages->offset[i]); + ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], true); } } diff --git a/migration/ram.c b/migration/ram.c index 3ee8cb47d3..dec2e73f8e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3149,9 +3149,13 @@ static void ram_save_file_bmap(QEMUFile *f) } } -void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset) +void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset, bool set) { - set_bit_atomic(offset >> TARGET_PAGE_BITS, block->file_bmap); + if (set) { + set_bit_atomic(offset >> TARGET_PAGE_BITS, block->file_bmap); + } else { + clear_bit_atomic(offset >> TARGET_PAGE_BITS, block->file_bmap); + } } /** From patchwork Mon Mar 11 21:59: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: 13589362 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 DC0EBC5475B for ; Mon, 11 Mar 2024 22:03:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjniQ-0003FR-9D; Mon, 11 Mar 2024 18:01:50 -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 1rjngv-000105-42 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:17 -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 1rjngs-0004IA-Tc for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194414; 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=Aa/VK3Y386Nj6ANAoIrWbcgvzkBYb9OIM3BHKMzIjQM=; b=gFDDuUNdV29ZLDqeUrIhhfVA7GsW8E+O/Goa4iLHhIwRcydKAqGUIuk0U5phC8zaGsz8kN 3VGiZ2IJ6pfMMf49sFGrEm8CtKeZUDoQXZ//LMepyAGdFlEPJdk45+w0QHQg/HKJDTbFpg jloei+fG860MdlH+gxexF3NGALSgjkg= 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-313-VQOuJGK_Pl-WGVKCMp6Ekg-1; Mon, 11 Mar 2024 18:00:12 -0400 X-MC-Unique: VQOuJGK_Pl-WGVKCMp6Ekg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690becce69eso10938596d6.1 for ; Mon, 11 Mar 2024 15:00:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194412; x=1710799212; 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=Aa/VK3Y386Nj6ANAoIrWbcgvzkBYb9OIM3BHKMzIjQM=; b=SXzP1gU78Paj4qFPWM6LOzQ88PZocfQvpMOMbrIznTvrAgFkXSbpGDN+DZU3YDhvbm K53WjM0Mry3LoXM+RO6GVsvdtpWv5H2VgjVHN9x3FXi5SppjCdyr9ZX4o8TTZfq4r4ou 5PVraAjW5MO1tXQjMA+C5kKoF8qVha86/DSUevriEY7rLREvcbXQwDwYc/s18Um/Ep92 28kSNPW8ehuzbCZOJR6EUy5SBv5sbXIIpcvHg0XZCpO6Iv6LKfL7XMWUD4ugTa8Cv90g eycx+JmbUXi+dVvExXlD3KKO+jIMil2gJWXHC6k0OW+Qet0xsdnAtiqwPGizwqPomwHA YZeA== X-Gm-Message-State: AOJu0YzP3l9pgdiB8FG5SP+vCiNGQ3O1kCh52/vJ8vpPJ7LitVtg/4/y NR/xFuAkTbOvss2Ld6c8ybS9Jr26TYCwknlda1P5mLGqOsqJ1NFe97W0L+gQWoYYiRe7tdfBwJT 4JgnICK7dXZIrKpC6z5UlEHbnE2wPDS6DvLukOYANXOUgrseaX1p5Bwsg9VWYxcn1vl9KI/9Elq lILKIEGhYDSmCNu0jGrmz7gcFqWTWevOg3SA== X-Received: by 2002:a05:6214:973:b0:690:c35c:7590 with SMTP id do19-20020a056214097300b00690c35c7590mr6385749qvb.2.1710194411946; Mon, 11 Mar 2024 15:00:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOCtSosAm6cQQs2KFnwD7jdeQDpH+OB5CaokpQTuFw7jTfEc74qZ97GbzlT3wWE0V6uECpiQ== X-Received: by 2002:a05:6214:973:b0:690:c35c:7590 with SMTP id do19-20020a056214097300b00690c35c7590mr6385719qvb.2.1710194411457; Mon, 11 Mar 2024 15:00:11 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:10 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Hao Xiang , Markus Armbruster Subject: [PULL 30/34] migration/multifd: Add new migration option zero-page-detection. Date: Mon, 11 Mar 2024 17:59:21 -0400 Message-ID: <20240311215925.40618-31-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hao Xiang This new parameter controls where the zero page checking is running. 1. If this parameter is set to 'legacy', zero page checking is done in the migration main thread. 2. If this parameter is set to 'none', zero page checking is disabled. Signed-off-by: Hao Xiang Reviewed-by: Peter Xu Acked-by: Markus Armbruster Link: https://lore.kernel.org/r/20240311180015.3359271-4-hao.xiang@linux.dev Signed-off-by: Peter Xu --- qapi/migration.json | 33 ++++++++++++++++++++++++++--- include/hw/qdev-properties-system.h | 4 ++++ migration/options.h | 1 + hw/core/qdev-properties-system.c | 10 +++++++++ migration/migration-hmp-cmds.c | 9 ++++++++ migration/options.c | 21 ++++++++++++++++++ migration/ram.c | 4 ++++ 7 files changed, 79 insertions(+), 3 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 51d188b902..83fdef73b9 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -670,6 +670,18 @@ { 'enum': 'MigMode', 'data': [ 'normal', 'cpr-reboot' ] } +## +# @ZeroPageDetection: +# +# @none: Do not perform zero page checking. +# +# @legacy: Perform zero page checking in main migration thread. +# +# Since: 9.0 +## +{ 'enum': 'ZeroPageDetection', + 'data': [ 'none', 'legacy' ] } + ## # @BitmapMigrationBitmapAliasTransform: # @@ -891,6 +903,10 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @zero-page-detection: Whether and how to detect zero pages. +# See description in @ZeroPageDetection. Default is 'legacy'. +# (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -924,7 +940,8 @@ 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] }, 'vcpu-dirty-limit', - 'mode'] } + 'mode', + 'zero-page-detection'] } ## # @MigrateSetParameters: @@ -1083,6 +1100,10 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @zero-page-detection: Whether and how to detect zero pages. +# See description in @ZeroPageDetection. Default is 'legacy'. +# (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1136,7 +1157,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*zero-page-detection': 'ZeroPageDetection'} } ## # @migrate-set-parameters: @@ -1311,6 +1333,10 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @zero-page-detection: Whether and how to detect zero pages. +# See description in @ZeroPageDetection. Default is 'legacy'. +# (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1361,7 +1387,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*zero-page-detection': 'ZeroPageDetection'} } ## # @query-migrate-parameters: diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properties-system.h index 626be87dd3..438f65389f 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -9,6 +9,7 @@ extern const PropertyInfo qdev_prop_reserved_region; extern const PropertyInfo qdev_prop_multifd_compression; extern const PropertyInfo qdev_prop_mig_mode; extern const PropertyInfo qdev_prop_granule_mode; +extern const PropertyInfo qdev_prop_zero_page_detection; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -50,6 +51,9 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_list; MigMode) #define DEFINE_PROP_GRANULE_MODE(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_granule_mode, GranuleMode) +#define DEFINE_PROP_ZERO_PAGE_DETECTION(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_zero_page_detection, \ + ZeroPageDetection) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) diff --git a/migration/options.h b/migration/options.h index b6b69c2bb7..ab8199e207 100644 --- a/migration/options.h +++ b/migration/options.h @@ -90,6 +90,7 @@ const char *migrate_tls_authz(void); const char *migrate_tls_creds(void); const char *migrate_tls_hostname(void); uint64_t migrate_xbzrle_cache_size(void); +ZeroPageDetection migrate_zero_page_detection(void); /* parameters setters */ diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index b45e90edb2..71a21bf24e 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -693,6 +693,16 @@ const PropertyInfo qdev_prop_granule_mode = { .set_default_value = qdev_propinfo_set_default_value_enum, }; +const PropertyInfo qdev_prop_zero_page_detection = { + .name = "ZeroPageDetection", + .description = "zero_page_detection values, " + "none,legacy", + .enum_table = &ZeroPageDetection_lookup, + .get = qdev_propinfo_get_enum, + .set = qdev_propinfo_set_enum, + .set_default_value = qdev_propinfo_set_default_value_enum, +}; + /* --- Reserved Region --- */ /* diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 99b49df5dd..7e96ae6ffd 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -344,6 +344,11 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION), MultiFDCompression_str(params->multifd_compression)); + assert(params->has_zero_page_detection); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_ZERO_PAGE_DETECTION), + qapi_enum_lookup(&ZeroPageDetection_lookup, + params->zero_page_detection)); monitor_printf(mon, "%s: %" PRIu64 " bytes\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); @@ -634,6 +639,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_multifd_zstd_level = true; visit_type_uint8(v, param, &p->multifd_zstd_level, &err); break; + case MIGRATION_PARAMETER_ZERO_PAGE_DETECTION: + p->has_zero_page_detection = true; + visit_type_ZeroPageDetection(v, param, &p->zero_page_detection, &err); + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size = true; if (!visit_type_size(v, param, &cache_size, &err)) { diff --git a/migration/options.c b/migration/options.c index 09178c6f60..8f2a3a2fa5 100644 --- a/migration/options.c +++ b/migration/options.c @@ -179,6 +179,9 @@ Property migration_properties[] = { DEFINE_PROP_MIG_MODE("mode", MigrationState, parameters.mode, MIG_MODE_NORMAL), + DEFINE_PROP_ZERO_PAGE_DETECTION("zero-page-detection", MigrationState, + parameters.zero_page_detection, + ZERO_PAGE_DETECTION_LEGACY), /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -938,6 +941,13 @@ uint64_t migrate_xbzrle_cache_size(void) return s->parameters.xbzrle_cache_size; } +ZeroPageDetection migrate_zero_page_detection(void) +{ + MigrationState *s = migrate_get_current(); + + return s->parameters.zero_page_detection; +} + /* parameter setters */ void migrate_set_block_incremental(bool value) @@ -1048,6 +1058,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit; params->has_mode = true; params->mode = s->parameters.mode; + params->has_zero_page_detection = true; + params->zero_page_detection = s->parameters.zero_page_detection; return params; } @@ -1084,6 +1096,7 @@ void migrate_params_init(MigrationParameters *params) params->has_x_vcpu_dirty_limit_period = true; params->has_vcpu_dirty_limit = true; params->has_mode = true; + params->has_zero_page_detection = true; } /* @@ -1398,6 +1411,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params, if (params->has_mode) { dest->mode = params->mode; } + + if (params->has_zero_page_detection) { + dest->zero_page_detection = params->zero_page_detection; + } } static void migrate_params_apply(MigrateSetParameters *params, Error **errp) @@ -1548,6 +1565,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) if (params->has_mode) { s->parameters.mode = params->mode; } + + if (params->has_zero_page_detection) { + s->parameters.zero_page_detection = params->zero_page_detection; + } } void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/migration/ram.c b/migration/ram.c index dec2e73f8e..260529f264 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1140,6 +1140,10 @@ static int save_zero_page(RAMState *rs, PageSearchStatus *pss, QEMUFile *file = pss->pss_channel; int len = 0; + if (migrate_zero_page_detection() == ZERO_PAGE_DETECTION_NONE) { + return 0; + } + if (!buffer_is_zero(p, TARGET_PAGE_SIZE)) { return 0; } From patchwork Mon Mar 11 21:59: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: 13589380 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 C7265C54E58 for ; Mon, 11 Mar 2024 22:09:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjnir-00040p-MO; Mon, 11 Mar 2024 18:02:18 -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 1rjnhL-0001Hf-4U for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:48 -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 1rjngy-0004IY-F5 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194417; 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=YNxPnbmMbEaICpUmDjWhNLqH4j4k4F7CKv7EwFIQJbk=; b=FkYGudp3ttD/nQObjdGnn9CfNZGvo6GmQARbFY+9L17SmQGVtEmVuBC3WIzOS+R2sLtucD +wKjej4A2xbd0gJ2p6Fi2RZ+wlIs1p1QKWelZTyCV98fKLCQPaONE584WCfm8F8hdg85Fz T5rXqEgmqye4heLvzowbGaA+CAxrkpk= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-g1HNb6wwMjCiMhc0d4yEBg-1; Mon, 11 Mar 2024 18:00:16 -0400 X-MC-Unique: g1HNb6wwMjCiMhc0d4yEBg-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6dde25ac92fso2724514a34.0 for ; Mon, 11 Mar 2024 15:00:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194414; x=1710799214; 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=YNxPnbmMbEaICpUmDjWhNLqH4j4k4F7CKv7EwFIQJbk=; b=vPgV9v1nWuptUAk8Cygz6hDtyx5j6S8cmRnYfFbolrWbCwqKcYcP+AZLO36ULfd2M8 CejyD1BNrO/0IhOZ85Q6O9MUKKa/JNnlw7sKcU+AfwIShgcjmXtSS92ACVCeYFzPj4KW jookLtOxjkVHCpHWOzVXPxLaAxQ22KDaqE7WenANfrXmni5pjozBIhQ1DlPWFtHkGF+v HMp6duO5lCuJ8j/8Vhu0q7+UA8AgZks2ilSjLrVPz9DSSLX+hrkxFb2FFCv8Bxo7TnH6 oxfqHBTmin+yR4d9JQFGXyXSI9dbINpHdRzGBms3ftqoiDmiHvSIVv3nLyJfFxMEAMok +SCw== X-Gm-Message-State: AOJu0Yww4pvB1wi62L7OsJoPem+J+1LtUxvnonEnfUN7tnw53AAcEq7h fvpB4PnNMb+Hfo3Ilo23HIHkE8oga6xQWMPaYN0Q586ItaT6upWziIvDWugvVYxy4YZ5TNV4ykT xDNJYT7gzQDbh+/xXQSOuQbBBWMSuWTDBgQNXsu2Mye0bV8CrnjjdBDO/bX4sdWfNk5CJgKMVhC IVCz+a0wpn+1r10+3JVgLU2Zuae4BJtGLXlA== X-Received: by 2002:a05:6808:20a7:b0:3c1:e136:133f with SMTP id s39-20020a05680820a700b003c1e136133fmr9258712oiw.2.1710194414045; Mon, 11 Mar 2024 15:00:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERM2B1Ty0SdR0wz/fJhQKRx7EPNmUoJxN6A4CCxSRyfTO2nGJpi3LU5hYUmDYE8X+3wIi3ew== X-Received: by 2002:a05:6808:20a7:b0:3c1:e136:133f with SMTP id s39-20020a05680820a700b003c1e136133fmr9258666oiw.2.1710194413452; Mon, 11 Mar 2024 15:00:13 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:12 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Hao Xiang , Markus Armbruster Subject: [PULL 31/34] migration/multifd: Implement zero page transmission on the multifd thread. Date: Mon, 11 Mar 2024 17:59:22 -0400 Message-ID: <20240311215925.40618-32-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hao Xiang 1. Add zero_pages field in MultiFDPacket_t. 2. Implements the zero page detection and handling on the multifd threads for non-compression, zlib and zstd compression backends. 3. Added a new value 'multifd' in ZeroPageDetection enumeration. 4. Adds zero page counters and updates multifd send/receive tracing format to track the newly added counters. Signed-off-by: Hao Xiang Acked-by: Markus Armbruster Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240311180015.3359271-5-hao.xiang@linux.dev Signed-off-by: Peter Xu --- qapi/migration.json | 7 ++- migration/multifd.h | 23 +++++++- hw/core/qdev-properties-system.c | 2 +- migration/multifd-zero-page.c | 87 ++++++++++++++++++++++++++++++ migration/multifd-zlib.c | 21 ++++++-- migration/multifd-zstd.c | 20 +++++-- migration/multifd.c | 90 +++++++++++++++++++++++++++----- migration/ram.c | 1 - migration/meson.build | 1 + migration/trace-events | 8 +-- 10 files changed, 228 insertions(+), 32 deletions(-) create mode 100644 migration/multifd-zero-page.c diff --git a/qapi/migration.json b/qapi/migration.json index 83fdef73b9..2684e4e9ac 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -677,10 +677,15 @@ # # @legacy: Perform zero page checking in main migration thread. # +# @multifd: Perform zero page checking in multifd sender thread if +# multifd migration is enabled, else in the main migration +# thread as for @legacy. +# # Since: 9.0 +# ## { 'enum': 'ZeroPageDetection', - 'data': [ 'none', 'legacy' ] } + 'data': [ 'none', 'legacy', 'multifd' ] } ## # @BitmapMigrationBitmapAliasTransform: diff --git a/migration/multifd.h b/migration/multifd.h index 7447c2bea3..c9d9b09239 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -55,14 +55,24 @@ typedef struct { /* size of the next packet that contains pages */ uint32_t next_packet_size; uint64_t packet_num; - uint64_t unused[4]; /* Reserved for future use */ + /* zero pages */ + uint32_t zero_pages; + uint32_t unused32[1]; /* Reserved for future use */ + uint64_t unused64[3]; /* Reserved for future use */ char ramblock[256]; + /* + * This array contains the pointers to: + * - normal pages (initial normal_pages entries) + * - zero pages (following zero_pages entries) + */ uint64_t offset[]; } __attribute__((packed)) MultiFDPacket_t; typedef struct { /* number of used pages */ uint32_t num; + /* number of normal pages */ + uint32_t normal_num; /* number of allocated pages */ uint32_t allocated; /* offset of each page */ @@ -136,6 +146,8 @@ typedef struct { uint64_t packets_sent; /* non zero pages sent through this channel */ uint64_t total_normal_pages; + /* zero pages sent through this channel */ + uint64_t total_zero_pages; /* buffers to send */ struct iovec *iov; /* number of iovs used */ @@ -194,12 +206,18 @@ typedef struct { uint8_t *host; /* non zero pages recv through this channel */ uint64_t total_normal_pages; + /* zero pages recv through this channel */ + uint64_t total_zero_pages; /* buffers to recv */ struct iovec *iov; /* Pages that are not zero */ ram_addr_t *normal; /* num of non zero pages */ uint32_t normal_num; + /* Pages that are zero */ + ram_addr_t *zero; + /* num of zero pages */ + uint32_t zero_num; /* used for de-compression methods */ void *compress_data; } MultiFDRecvParams; @@ -221,6 +239,9 @@ typedef struct { void multifd_register_ops(int method, MultiFDMethods *ops); void multifd_send_fill_packet(MultiFDSendParams *p); +bool multifd_send_prepare_common(MultiFDSendParams *p); +void multifd_send_zero_page_detect(MultiFDSendParams *p); +void multifd_recv_zero_page_process(MultiFDRecvParams *p); static inline void multifd_send_prepare_header(MultiFDSendParams *p) { diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 71a21bf24e..7eca2f2377 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -696,7 +696,7 @@ const PropertyInfo qdev_prop_granule_mode = { const PropertyInfo qdev_prop_zero_page_detection = { .name = "ZeroPageDetection", .description = "zero_page_detection values, " - "none,legacy", + "none,legacy,multifd", .enum_table = &ZeroPageDetection_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, diff --git a/migration/multifd-zero-page.c b/migration/multifd-zero-page.c new file mode 100644 index 0000000000..1ba38be636 --- /dev/null +++ b/migration/multifd-zero-page.c @@ -0,0 +1,87 @@ +/* + * Multifd zero page detection implementation. + * + * Copyright (c) 2024 Bytedance Inc + * + * Authors: + * Hao Xiang + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "exec/ramblock.h" +#include "migration.h" +#include "multifd.h" +#include "options.h" +#include "ram.h" + +static bool multifd_zero_page_enabled(void) +{ + return migrate_zero_page_detection() == ZERO_PAGE_DETECTION_MULTIFD; +} + +static void swap_page_offset(ram_addr_t *pages_offset, int a, int b) +{ + ram_addr_t temp; + + if (a == b) { + return; + } + + temp = pages_offset[a]; + pages_offset[a] = pages_offset[b]; + pages_offset[b] = temp; +} + +/** + * multifd_send_zero_page_detect: Perform zero page detection on all pages. + * + * Sorts normal pages before zero pages in p->pages->offset and updates + * p->pages->normal_num. + * + * @param p A pointer to the send params. + */ +void multifd_send_zero_page_detect(MultiFDSendParams *p) +{ + MultiFDPages_t *pages = p->pages; + RAMBlock *rb = pages->block; + int i = 0; + int j = pages->num - 1; + + if (!multifd_zero_page_enabled()) { + pages->normal_num = pages->num; + return; + } + + /* + * Sort the page offset array by moving all normal pages to + * the left and all zero pages to the right of the array. + */ + while (i <= j) { + uint64_t offset = pages->offset[i]; + + if (!buffer_is_zero(rb->host + offset, p->page_size)) { + i++; + continue; + } + + swap_page_offset(pages->offset, i, j); + ram_release_page(rb->idstr, offset); + j--; + } + + pages->normal_num = i; +} + +void multifd_recv_zero_page_process(MultiFDRecvParams *p) +{ + for (int i = 0; i < p->zero_num; i++) { + void *page = p->host + p->zero[i]; + if (!buffer_is_zero(page, p->page_size)) { + memset(page, 0, p->page_size); + } + } +} diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 6120faad65..83c0374380 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -123,13 +123,15 @@ static int zlib_send_prepare(MultiFDSendParams *p, Error **errp) int ret; uint32_t i; - multifd_send_prepare_header(p); + if (!multifd_send_prepare_common(p)) { + goto out; + } - for (i = 0; i < pages->num; i++) { + for (i = 0; i < pages->normal_num; i++) { uint32_t available = z->zbuff_len - out_size; int flush = Z_NO_FLUSH; - if (i == pages->num - 1) { + if (i == pages->normal_num - 1) { flush = Z_SYNC_FLUSH; } @@ -172,10 +174,10 @@ static int zlib_send_prepare(MultiFDSendParams *p, Error **errp) p->iov[p->iovs_num].iov_len = out_size; p->iovs_num++; p->next_packet_size = out_size; - p->flags |= MULTIFD_FLAG_ZLIB; +out: + p->flags |= MULTIFD_FLAG_ZLIB; multifd_send_fill_packet(p); - return 0; } @@ -261,6 +263,14 @@ static int zlib_recv(MultiFDRecvParams *p, Error **errp) p->id, flags, MULTIFD_FLAG_ZLIB); return -1; } + + multifd_recv_zero_page_process(p); + + if (!p->normal_num) { + assert(in_size == 0); + return 0; + } + ret = qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); if (ret != 0) { @@ -310,6 +320,7 @@ static int zlib_recv(MultiFDRecvParams *p, Error **errp) p->id, out_size, expected_size); return -1; } + return 0; } diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index cac236833d..02112255ad 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -118,16 +118,18 @@ static int zstd_send_prepare(MultiFDSendParams *p, Error **errp) int ret; uint32_t i; - multifd_send_prepare_header(p); + if (!multifd_send_prepare_common(p)) { + goto out; + } z->out.dst = z->zbuff; z->out.size = z->zbuff_len; z->out.pos = 0; - for (i = 0; i < pages->num; i++) { + for (i = 0; i < pages->normal_num; i++) { ZSTD_EndDirective flush = ZSTD_e_continue; - if (i == pages->num - 1) { + if (i == pages->normal_num - 1) { flush = ZSTD_e_flush; } z->in.src = p->pages->block->host + pages->offset[i]; @@ -161,10 +163,10 @@ static int zstd_send_prepare(MultiFDSendParams *p, Error **errp) p->iov[p->iovs_num].iov_len = z->out.pos; p->iovs_num++; p->next_packet_size = z->out.pos; - p->flags |= MULTIFD_FLAG_ZSTD; +out: + p->flags |= MULTIFD_FLAG_ZSTD; multifd_send_fill_packet(p); - return 0; } @@ -257,6 +259,14 @@ static int zstd_recv(MultiFDRecvParams *p, Error **errp) p->id, flags, MULTIFD_FLAG_ZSTD); return -1; } + + multifd_recv_zero_page_process(p); + + if (!p->normal_num) { + assert(in_size == 0); + return 0; + } + ret = qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); if (ret != 0) { diff --git a/migration/multifd.c b/migration/multifd.c index 3ba922694e..0179422f6d 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/rcu.h" #include "exec/target_page.h" #include "sysemu/sysemu.h" @@ -111,12 +112,17 @@ void multifd_send_channel_created(void) static void multifd_set_file_bitmap(MultiFDSendParams *p) { MultiFDPages_t *pages = p->pages; + uint32_t zero_num = p->pages->num - p->pages->normal_num; assert(pages->block); - for (int i = 0; i < p->pages->num; i++) { + for (int i = 0; i < p->pages->normal_num; i++) { ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], true); } + + for (int i = p->pages->num; i < zero_num; i++) { + ramblock_set_file_bmap_atomic(pages->block, pages->offset[i], false); + } } /* Multifd without compression */ @@ -153,13 +159,13 @@ static void multifd_send_prepare_iovs(MultiFDSendParams *p) { MultiFDPages_t *pages = p->pages; - for (int i = 0; i < pages->num; i++) { + for (int i = 0; i < pages->normal_num; i++) { p->iov[p->iovs_num].iov_base = pages->block->host + pages->offset[i]; p->iov[p->iovs_num].iov_len = p->page_size; p->iovs_num++; } - p->next_packet_size = pages->num * p->page_size; + p->next_packet_size = pages->normal_num * p->page_size; } /** @@ -178,6 +184,8 @@ static int nocomp_send_prepare(MultiFDSendParams *p, Error **errp) bool use_zero_copy_send = migrate_zero_copy_send(); int ret; + multifd_send_zero_page_detect(p); + if (!multifd_use_packets()) { multifd_send_prepare_iovs(p); multifd_set_file_bitmap(p); @@ -261,6 +269,13 @@ static int nocomp_recv(MultiFDRecvParams *p, Error **errp) p->id, flags, MULTIFD_FLAG_NOCOMP); return -1; } + + multifd_recv_zero_page_process(p); + + if (!p->normal_num) { + return 0; + } + for (int i = 0; i < p->normal_num; i++) { p->iov[i].iov_base = p->host + p->normal[i]; p->iov[i].iov_len = p->page_size; @@ -295,6 +310,7 @@ static void multifd_pages_reset(MultiFDPages_t *pages) * overwritten later when reused. */ pages->num = 0; + pages->normal_num = 0; pages->block = NULL; } @@ -386,11 +402,13 @@ void multifd_send_fill_packet(MultiFDSendParams *p) MultiFDPacket_t *packet = p->packet; MultiFDPages_t *pages = p->pages; uint64_t packet_num; + uint32_t zero_num = pages->num - pages->normal_num; int i; packet->flags = cpu_to_be32(p->flags); packet->pages_alloc = cpu_to_be32(p->pages->allocated); - packet->normal_pages = cpu_to_be32(pages->num); + packet->normal_pages = cpu_to_be32(pages->normal_num); + packet->zero_pages = cpu_to_be32(zero_num); packet->next_packet_size = cpu_to_be32(p->next_packet_size); packet_num = qatomic_fetch_inc(&multifd_send_state->packet_num); @@ -408,10 +426,11 @@ void multifd_send_fill_packet(MultiFDSendParams *p) } p->packets_sent++; - p->total_normal_pages += pages->num; + p->total_normal_pages += pages->normal_num; + p->total_zero_pages += zero_num; - trace_multifd_send(p->id, packet_num, pages->num, p->flags, - p->next_packet_size); + trace_multifd_send(p->id, packet_num, pages->normal_num, zero_num, + p->flags, p->next_packet_size); } static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) @@ -452,20 +471,29 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) p->normal_num = be32_to_cpu(packet->normal_pages); if (p->normal_num > packet->pages_alloc) { error_setg(errp, "multifd: received packet " - "with %u pages and expected maximum pages are %u", + "with %u normal pages and expected maximum pages are %u", p->normal_num, packet->pages_alloc) ; return -1; } + p->zero_num = be32_to_cpu(packet->zero_pages); + if (p->zero_num > packet->pages_alloc - p->normal_num) { + error_setg(errp, "multifd: received packet " + "with %u zero pages and expected maximum zero pages are %u", + p->zero_num, packet->pages_alloc - p->normal_num) ; + return -1; + } + p->next_packet_size = be32_to_cpu(packet->next_packet_size); p->packet_num = be64_to_cpu(packet->packet_num); p->packets_recved++; p->total_normal_pages += p->normal_num; + p->total_zero_pages += p->zero_num; - trace_multifd_recv(p->id, p->packet_num, p->normal_num, p->flags, - p->next_packet_size); + trace_multifd_recv(p->id, p->packet_num, p->normal_num, p->zero_num, + p->flags, p->next_packet_size); - if (p->normal_num == 0) { + if (p->normal_num == 0 && p->zero_num == 0) { return 0; } @@ -491,6 +519,18 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) p->normal[i] = offset; } + for (i = 0; i < p->zero_num; i++) { + uint64_t offset = be64_to_cpu(packet->offset[p->normal_num + i]); + + if (offset > (p->block->used_length - p->page_size)) { + error_setg(errp, "multifd: offset too long %" PRIu64 + " (max " RAM_ADDR_FMT ")", + offset, p->block->used_length); + return -1; + } + p->zero[i] = offset; + } + return 0; } @@ -918,6 +958,8 @@ static void *multifd_send_thread(void *opaque) stat64_add(&mig_stats.multifd_bytes, p->next_packet_size + p->packet_len); + stat64_add(&mig_stats.normal_pages, pages->normal_num); + stat64_add(&mig_stats.zero_pages, pages->num - pages->normal_num); multifd_pages_reset(p->pages); p->next_packet_size = 0; @@ -965,7 +1007,8 @@ out: rcu_unregister_thread(); migration_threads_remove(thread); - trace_multifd_send_thread_end(p->id, p->packets_sent, p->total_normal_pages); + trace_multifd_send_thread_end(p->id, p->packets_sent, p->total_normal_pages, + p->total_zero_pages); return NULL; } @@ -1316,6 +1359,8 @@ static void multifd_recv_cleanup_channel(MultiFDRecvParams *p) p->iov = NULL; g_free(p->normal); p->normal = NULL; + g_free(p->zero); + p->zero = NULL; multifd_recv_state->ops->recv_cleanup(p); } @@ -1449,7 +1494,7 @@ static void *multifd_recv_thread(void *opaque) flags = p->flags; /* recv methods don't know how to handle the SYNC flag */ p->flags &= ~MULTIFD_FLAG_SYNC; - has_data = !!p->normal_num; + has_data = p->normal_num || p->zero_num; qemu_mutex_unlock(&p->mutex); } else { /* @@ -1507,7 +1552,9 @@ static void *multifd_recv_thread(void *opaque) } rcu_unregister_thread(); - trace_multifd_recv_thread_end(p->id, p->packets_recved, p->total_normal_pages); + trace_multifd_recv_thread_end(p->id, p->packets_recved, + p->total_normal_pages, + p->total_zero_pages); return NULL; } @@ -1559,6 +1606,7 @@ int multifd_recv_setup(Error **errp) p->name = g_strdup_printf("multifdrecv_%d", i); p->iov = g_new0(struct iovec, page_count); p->normal = g_new0(ram_addr_t, page_count); + p->zero = g_new0(ram_addr_t, page_count); p->page_count = page_count; p->page_size = qemu_target_page_size(); } @@ -1633,3 +1681,17 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **errp) QEMU_THREAD_JOINABLE); qatomic_inc(&multifd_recv_state->count); } + +bool multifd_send_prepare_common(MultiFDSendParams *p) +{ + multifd_send_zero_page_detect(p); + + if (!p->pages->normal_num) { + p->next_packet_size = 0; + return false; + } + + multifd_send_prepare_header(p); + + return true; +} diff --git a/migration/ram.c b/migration/ram.c index 260529f264..c26435adc7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1288,7 +1288,6 @@ static int ram_save_multifd_page(RAMBlock *block, ram_addr_t offset) if (!multifd_queue_page(block, offset)) { return -1; } - stat64_add(&mig_stats.normal_pages, 1); return 1; } diff --git a/migration/meson.build b/migration/meson.build index 92b1cc4297..1eeb915ff6 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -22,6 +22,7 @@ system_ss.add(files( 'migration.c', 'multifd.c', 'multifd-zlib.c', + 'multifd-zero-page.c', 'ram-compress.c', 'options.c', 'postcopy-ram.c', diff --git a/migration/trace-events b/migration/trace-events index bf1a069632..f0e1cb80c7 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -128,21 +128,21 @@ postcopy_preempt_reset_channel(void) "" # multifd.c multifd_new_send_channel_async(uint8_t id) "channel %u" multifd_new_send_channel_async_error(uint8_t id, void *err) "channel=%u err=%p" -multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u flags 0x%x next packet size %u" +multifd_recv(uint8_t id, uint64_t packet_num, uint32_t normal, uint32_t zero, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u zero pages %u flags 0x%x next packet size %u" multifd_recv_new_channel(uint8_t id) "channel %u" multifd_recv_sync_main(long packet_num) "packet num %ld" multifd_recv_sync_main_signal(uint8_t id) "channel %u" multifd_recv_sync_main_wait(uint8_t id) "iter %u" multifd_recv_terminate_threads(bool error) "error %d" -multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %u packets %" PRIu64 " pages %" PRIu64 +multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages, uint64_t zero_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 " zero pages %" PRIu64 multifd_recv_thread_start(uint8_t id) "%u" -multifd_send(uint8_t id, uint64_t packet_num, uint32_t normal, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u flags 0x%x next packet size %u" +multifd_send(uint8_t id, uint64_t packet_num, uint32_t normal_pages, uint32_t zero_pages, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " normal pages %u zero pages %u flags 0x%x next packet size %u" multifd_send_error(uint8_t id) "channel %u" multifd_send_sync_main(long packet_num) "packet num %ld" multifd_send_sync_main_signal(uint8_t id) "channel %u" multifd_send_sync_main_wait(uint8_t id) "channel %u" multifd_send_terminate_threads(void) "" -multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 +multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t normal_pages, uint64_t zero_pages) "channel %u packets %" PRIu64 " normal pages %" PRIu64 " zero pages %" PRIu64 multifd_send_thread_start(uint8_t id) "%u" multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s" multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s" From patchwork Mon Mar 11 21:59: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: 13589384 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 4E918C5475B for ; Mon, 11 Mar 2024 22:10:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjniT-0003Js-CF; Mon, 11 Mar 2024 18:01:53 -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 1rjnh5-00018U-D4 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:34 -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 1rjngv-0004IU-MF for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194417; 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=zHO3KVsccLbSO3dagFiDmb3kOgh0ZDKG6oQA10xRTGU=; b=fYoK7emhnN8T3qUMioQm4NtAVct1G4B1kUeX3ocANqRkFjnNaJlDrI4CuXMeHdaqrl+GuM fVuNzcQMZOFOW62iZXzJtwPGR/klg4LqNnJkDTg1fCbEOX9S+tRzcuk8B9hS6o0OIYqJRw ZiRSeFR74IJLyjDuOVHxaD5S7jJqWGE= 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-155-exR3nK_aNxGlg-EjRbJc9A-1; Mon, 11 Mar 2024 18:00:15 -0400 X-MC-Unique: exR3nK_aNxGlg-EjRbJc9A-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ab2b0de1so15044736d6.0 for ; Mon, 11 Mar 2024 15:00:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194415; x=1710799215; 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=zHO3KVsccLbSO3dagFiDmb3kOgh0ZDKG6oQA10xRTGU=; b=A0sq5aALxYTKn7t+1Ju9j4FXAvua3QRkPm5vgZTZrotXsvxpdKxqY1YDfYDb9oozNE HKajxVDCoak4fWbficde2LpyQfoMMVtAon/1kEquy0FtmrhM0q0qpUJ2lO7chM6wEL5l wiF3HegSrY2omrG0Su95hvFYpOylMp4kQ94Z4qWGGMebc71sPe50Va8jEf0zDmtyq64E NBFMLe/if6l0GWc03tPYpqVVK5CGUtp6yRx4YfyAv9PhqUaYbr+vID9rXF7ZxBxevZ1R Trlv64hAY28QmPPWilkZxgUELsMiyuSQhBmxY2GPDZRQ7tV6gEMbNX+7RZm0fhsaRDDH t6FQ== X-Gm-Message-State: AOJu0Yx//ZYIf6zAD+gbLozbKNFPK/Myy0JQpJPIpzLKdBF0sQaZLBPc GtG34tiH7d7ZSFzbpKihgYgvrkW8ksrM82/vyI/9t9BJXFQPTJL9jhq4eGmMNpcFcELtXFoMfvM AksDHlv0uiJc+1SKi+2baQ9rhUqKEDNpo6CaG6ICpEL6yuWbR55mVQIBsIHrhdEDCpEh5Vzy71j 81pJuKCJokF/Xjy+eOnuEhxwITI1fvnIMHig== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr137655qvo.3.1710194414998; Mon, 11 Mar 2024 15:00:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6wzTo/bd4W+wKY+C8aSSQK8L0qubfiuss0rzPyDGZfHJxZysmn5RA3h6maKBpHTW/BTazMA== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr137617qvo.3.1710194414610; Mon, 11 Mar 2024 15:00:14 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:14 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Hao Xiang Subject: [PULL 32/34] migration/multifd: Implement ram_save_target_page_multifd to handle multifd version of MigrationOps::ram_save_target_page. Date: Mon, 11 Mar 2024 17:59:23 -0400 Message-ID: <20240311215925.40618-33-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hao Xiang 1. Add a dedicated handler for MigrationOps::ram_save_target_page in multifd live migration. 2. Refactor ram_save_target_page_legacy so that the legacy and multifd handlers don't have internal functions calling into each other. Signed-off-by: Hao Xiang Reviewed-by: Fabiano Rosas Message-Id: <20240226195654.934709-4-hao.xiang@bytedance.com> Link: https://lore.kernel.org/r/20240311180015.3359271-6-hao.xiang@linux.dev Signed-off-by: Peter Xu --- migration/ram.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c26435adc7..8deb84984f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2079,7 +2079,6 @@ static bool save_compress_page(RAMState *rs, PageSearchStatus *pss, */ static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss) { - RAMBlock *block = pss->block; ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; int res; @@ -2095,17 +2094,33 @@ static int ram_save_target_page_legacy(RAMState *rs, PageSearchStatus *pss) return 1; } + return ram_save_page(rs, pss); +} + +/** + * ram_save_target_page_multifd: send one target page to multifd workers + * + * Returns 1 if the page was queued, -1 otherwise. + * + * @rs: current RAM state + * @pss: data about the page we want to send + */ +static int ram_save_target_page_multifd(RAMState *rs, PageSearchStatus *pss) +{ + RAMBlock *block = pss->block; + ram_addr_t offset = ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; + /* - * Do not use multifd in postcopy as one whole host page should be - * placed. Meanwhile postcopy requires atomic update of pages, so even - * if host page size == guest page size the dest guest during run may - * still see partially copied pages which is data corruption. + * While using multifd live migration, we still need to handle zero + * page checking on the migration main thread. */ - if (migrate_multifd() && !migration_in_postcopy()) { - return ram_save_multifd_page(block, offset); + if (migrate_zero_page_detection() == ZERO_PAGE_DETECTION_LEGACY) { + if (save_zero_page(rs, pss, offset)) { + return 1; + } } - return ram_save_page(rs, pss); + return ram_save_multifd_page(block, offset); } /* Should be called before sending a host page */ @@ -3112,7 +3127,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } migration_ops = g_malloc0(sizeof(MigrationOps)); - migration_ops->ram_save_target_page = ram_save_target_page_legacy; + + if (migrate_multifd()) { + migration_ops->ram_save_target_page = ram_save_target_page_multifd; + } else { + migration_ops->ram_save_target_page = ram_save_target_page_legacy; + } bql_unlock(); ret = multifd_send_sync_main(); From patchwork Mon Mar 11 21:59: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: 13589370 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 EEC45C54E66 for ; Mon, 11 Mar 2024 22:04:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjniX-0003ZG-Iz; Mon, 11 Mar 2024 18:01:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjnh7-00018Y-9L for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:34 -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 1rjngy-0004Ic-FA for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194418; 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=W5D9hPe7YI8HTKjr9lPVCdDiZ9GlallD+BW1Y4cBBB8=; b=K2ZfXuiZE1lhCAog60PgBCgQ27/Vy0kJ/SDUt7fuF8HSz8SGmCt3Sqg0JcoSNtDvouFlZa +/+eXq+6HRmZUaMtS00IPGqO2Ihi2hyueEdBBPDG8y5t+CvGbIqAeudFhvz3Ezv4SpFENF zr2dQBrRRkQ8pOPAZyD9RFEt9cwOAOw= 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-307-OgqGKICIP0KCmXAq9CS5Jg-1; Mon, 11 Mar 2024 18:00:17 -0400 X-MC-Unique: OgqGKICIP0KCmXAq9CS5Jg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-68fba33cae0so6801206d6.1 for ; Mon, 11 Mar 2024 15:00:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194416; x=1710799216; 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=W5D9hPe7YI8HTKjr9lPVCdDiZ9GlallD+BW1Y4cBBB8=; b=RY1ZkPFmANNMqlkOuc1/nvRRBEMO43WcrcHHAJ9y4XvdJt9IrfybpV2TdpmRQ0czS7 R31Kpv9WrzFhV80EYt6ueyCZpsQS17eRjx9vNBwpD/IPDAyfREHd7FCdutX9MvLWAuKu NXmGiBcYjm4DF/PKmxwRNbUCih8pph6L77JXWn8HK6B3RSDzU8PhpoKkAtga0Q0N2iUQ jKFLZaelQjTt/tz/8dC5mBM/SMViVnorqplv/GIy3+CPaTwqBNknP0N7d1aHHuOLGORe Zj8PdEdropiY1tg5nfgizIXK76rfQ1K38TxagyEt5Zrn/Lz8tr3TN0uLvWP+5UCQ9Ygq 0AcQ== X-Gm-Message-State: AOJu0YzKEO+4+jAnOvYPABM6jXBX+gd+q6U6sJ3ia1uAl8rx1KnbZFAy Z9NngqdlBy7WAU84oAlWrLlAP+uxktfQGq4vESAvJHh7PamR9uld8MR6g1cvWNF6nWsx2HYH7zz 3P9R0noNHYaPB42EIA1SVJmDZArLzhcTJziffQiiXNSbc82XLflIfx6WuZ/B4YOkc4MFD/Xj5Xo QJ4FSkOh68uDD0Bkecij3d0gG4a/gdzn5muA== X-Received: by 2002:a05:6214:2dc7:b0:690:e44b:d739 with SMTP id nc7-20020a0562142dc700b00690e44bd739mr413654qvb.1.1710194416258; Mon, 11 Mar 2024 15:00:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXoiC4BlHAsGMjWzzkFWN55R4QoVKd6jom1q838J8px5fzau2GybR2f78afPLw+3NymwX9NA== X-Received: by 2002:a05:6214:2dc7:b0:690:e44b:d739 with SMTP id nc7-20020a0562142dc700b00690e44bd739mr413608qvb.1.1710194415717; Mon, 11 Mar 2024 15:00:15 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:15 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Hao Xiang Subject: [PULL 33/34] migration/multifd: Enable multifd zero page checking by default. Date: Mon, 11 Mar 2024 17:59:24 -0400 Message-ID: <20240311215925.40618-34-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hao Xiang 1. Set default "zero-page-detection" option to "multifd". Now zero page checking can be done in the multifd threads and this becomes the default configuration. 2. Handle migration QEMU9.0 -> QEMU8.2 compatibility. We provide backward compatibility where zero page checking is done from the migration main thread. Signed-off-by: Hao Xiang Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20240311180015.3359271-7-hao.xiang@linux.dev Signed-off-by: Peter Xu --- qapi/migration.json | 6 +++--- hw/core/machine.c | 4 +++- migration/options.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 2684e4e9ac..aa1b39bce1 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -909,7 +909,7 @@ # (Since 8.2) # # @zero-page-detection: Whether and how to detect zero pages. -# See description in @ZeroPageDetection. Default is 'legacy'. +# See description in @ZeroPageDetection. Default is 'multifd'. # (since 9.0) # # Features: @@ -1106,7 +1106,7 @@ # (Since 8.2) # # @zero-page-detection: Whether and how to detect zero pages. -# See description in @ZeroPageDetection. Default is 'legacy'. +# See description in @ZeroPageDetection. Default is 'multifd'. # (since 9.0) # # Features: @@ -1339,7 +1339,7 @@ # (Since 8.2) # # @zero-page-detection: Whether and how to detect zero pages. -# See description in @ZeroPageDetection. Default is 'legacy'. +# See description in @ZeroPageDetection. Default is 'multifd'. # (since 9.0) # # Features: diff --git a/hw/core/machine.c b/hw/core/machine.c index 9ac5d5389a..0e9d646b61 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -32,7 +32,9 @@ #include "hw/virtio/virtio-net.h" #include "audio/audio.h" -GlobalProperty hw_compat_8_2[] = {}; +GlobalProperty hw_compat_8_2[] = { + { "migration", "zero-page-detection", "legacy"}, +}; const size_t hw_compat_8_2_len = G_N_ELEMENTS(hw_compat_8_2); GlobalProperty hw_compat_8_1[] = { diff --git a/migration/options.c b/migration/options.c index 8f2a3a2fa5..9ed2fe4bee 100644 --- a/migration/options.c +++ b/migration/options.c @@ -181,7 +181,7 @@ Property migration_properties[] = { MIG_MODE_NORMAL), DEFINE_PROP_ZERO_PAGE_DETECTION("zero-page-detection", MigrationState, parameters.zero_page_detection, - ZERO_PAGE_DETECTION_LEGACY), + ZERO_PAGE_DETECTION_MULTIFD), /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), From patchwork Mon Mar 11 21:59: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: 13589374 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 930BEC5475B for ; Mon, 11 Mar 2024 22:05:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjniW-0003XF-FJ; Mon, 11 Mar 2024 18:01:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjnh7-00018Z-9D for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:34 -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 1rjnh0-0004Ip-0Q for qemu-devel@nongnu.org; Mon, 11 Mar 2024 18:00:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710194421; 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=REz2gEz/LcPOkgLWctbrSURC4iwk9Gc0HnBo9jeImt8=; b=edRgNGOQoQ9XIvmNOSyPG0uM7jZC2OEEhMcERd7PsN5VAyH4Nf6UlmwvA/5su3kNDg5NG+ 44Z4PLrMGT7pIOg05vbhFaU11KmCZ4qS4umqgqDejJ0G7tSRZ0xa7udBEMs7JSeNjR0wCo 9q0kOc7//5DRNlMBuU9U/1TmPvaUMvg= 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-647-YSXwEwj6OUevg1LN2PyfCA-1; Mon, 11 Mar 2024 18:00:19 -0400 X-MC-Unique: YSXwEwj6OUevg1LN2PyfCA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-690d3f5af86so4507026d6.0 for ; Mon, 11 Mar 2024 15:00:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710194418; x=1710799218; 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=REz2gEz/LcPOkgLWctbrSURC4iwk9Gc0HnBo9jeImt8=; b=YaLPH+PmcbV72UMzZcRm0taaB88WuknCr+JhYHlckmeqPvE0A6Vxnjq1Ojos8YTwTr m3+gb1u9mIexbfgWiQfYP+Tks19c1+uXrO3oOXgiQ9Br4hDPbDHKpeEhcUYbTsG21CjV kIIHQV34Ody3ESKpfzoPkMawgr0Op5CaycDZp+B9NEKbbYhuwlz7psrKxMVkehNeYZck TYj8gZmol72tv7gf8+MFuLygrb564lqk/uUOrsZ2PCcaSreOwt7vm05saXPBIOtRwDbH NwmUm/+6z6LFOTlKBStY3GxEiI9boxEmsdNWoRT7WggMcjfVHR8yIeof48pKzVxnoeLJ pgLw== X-Gm-Message-State: AOJu0YwD3jCsT/dRQaDE6CIoJZHARWsH6RCU2V5C46EfqnELW1ys7vol ICEEFdUpvwlKxhFDylLQLYSRa2o7Gwzq7r5uH8tRJ84IUz0YqPofdDrF8mxkgEfhLsJRMcJg51f DXgMnG/8CLoMotx4nrSWYIwCBuSkzKO8OmxfCs6z4oCDgy5YqxkP7kjQom7VWfe8PwJXuh1cLVp gNwRmXCKDgW7fdxsRb6XNIYZw7f2H2JBJU3A== X-Received: by 2002:ad4:5bec:0:b0:690:e47c:9bee with SMTP id k12-20020ad45bec000000b00690e47c9beemr408009qvc.4.1710194417626; Mon, 11 Mar 2024 15:00:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqXBKIl4UNeZ9L8akaPDVFSXlHkTf69VoScNoH1FN1qove6x2Exrf9MVAVPijERX6oYaerCg== X-Received: by 2002:ad4:5bec:0:b0:690:e47c:9bee with SMTP id k12-20020ad45bec000000b00690e47c9beemr407959qvc.4.1710194417079; Mon, 11 Mar 2024 15:00:17 -0700 (PDT) Received: from x1n.. (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d6-20020a0ce446000000b00690cec16254sm1541932qvm.68.2024.03.11.15.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 15:00:16 -0700 (PDT) From: peterx@redhat.com To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , peterx@redhat.com, Fabiano Rosas , David Hildenbrand , Prasad Pandit , Hao Xiang Subject: [PULL 34/34] migration/multifd: Add new migration test cases for legacy zero page checking. Date: Mon, 11 Mar 2024 17:59:25 -0400 Message-ID: <20240311215925.40618-35-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311215925.40618-1-peterx@redhat.com> References: <20240311215925.40618-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.029, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Hao Xiang Now that zero page checking is done on the multifd sender threads by default, we still provide an option for backward compatibility. This change adds a qtest migration test case to set the zero-page-detection option to "legacy" and run multifd migration with zero page checking on the migration main thread. Signed-off-by: Hao Xiang Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20240311180015.3359271-8-hao.xiang@linux.dev Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 4023d808f9..71895abb7f 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2771,6 +2771,24 @@ test_migrate_precopy_tcp_multifd_start(QTestState *from, return test_migrate_precopy_tcp_multifd_start_common(from, to, "none"); } +static void * +test_migrate_precopy_tcp_multifd_start_zero_page_legacy(QTestState *from, + QTestState *to) +{ + test_migrate_precopy_tcp_multifd_start_common(from, to, "none"); + migrate_set_parameter_str(from, "zero-page-detection", "legacy"); + return NULL; +} + +static void * +test_migration_precopy_tcp_multifd_start_no_zero_page(QTestState *from, + QTestState *to) +{ + test_migrate_precopy_tcp_multifd_start_common(from, to, "none"); + migrate_set_parameter_str(from, "zero-page-detection", "none"); + return NULL; +} + static void * test_migrate_precopy_tcp_multifd_zlib_start(QTestState *from, QTestState *to) @@ -2812,6 +2830,36 @@ static void test_multifd_tcp_none(void) test_precopy_common(&args); } +static void test_multifd_tcp_zero_page_legacy(void) +{ + MigrateCommon args = { + .listen_uri = "defer", + .start_hook = test_migrate_precopy_tcp_multifd_start_zero_page_legacy, + /* + * Multifd is more complicated than most of the features, it + * directly takes guest page buffers when sending, make sure + * everything will work alright even if guest page is changing. + */ + .live = true, + }; + test_precopy_common(&args); +} + +static void test_multifd_tcp_no_zero_page(void) +{ + MigrateCommon args = { + .listen_uri = "defer", + .start_hook = test_migration_precopy_tcp_multifd_start_no_zero_page, + /* + * Multifd is more complicated than most of the features, it + * directly takes guest page buffers when sending, make sure + * everything will work alright even if guest page is changing. + */ + .live = true, + }; + test_precopy_common(&args); +} + static void test_multifd_tcp_zlib(void) { MigrateCommon args = { @@ -3729,6 +3777,10 @@ int main(int argc, char **argv) } migration_test_add("/migration/multifd/tcp/plain/none", test_multifd_tcp_none); + migration_test_add("/migration/multifd/tcp/plain/zero-page/legacy", + test_multifd_tcp_zero_page_legacy); + migration_test_add("/migration/multifd/tcp/plain/zero-page/none", + test_multifd_tcp_no_zero_page); migration_test_add("/migration/multifd/tcp/plain/cancel", test_multifd_tcp_cancel); migration_test_add("/migration/multifd/tcp/plain/zlib",