From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013152; cv=none; d=zohomail.com; s=zohoarc; b=Hq5i1NSQRRjIF56WbMLD+UPhl9msq+VUD4MQuCbpZ05xDVXbiRoTzK5mQtkrj2TKWtMnu3bFI6Aps4eJ5sLIbyEyRBoL3TUvHJnP1XBIa1PWv2J5Hr+rqekfW9TelSzYYFwBvt3S1xQrQIc5ycIj8OJYZ6V18/M3q/Kvyy9Jivs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013152; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Zv6h0toate0j1Uvf9e0Pm8QwR7BudAmn5Vz4Z5ik9m4=; b=lNSSj16uL5V6O/xw5UGG3KIECiNXZQXxXetolwwPJMcxvAptOAhnQ5TDKjDu60U4KI1YTwvFEHkopwZIZUE1lqwM9+G0FtANiDGC0y2dMSLa0vuF9qONs26FdKGSuzJIK8GcHylIMeFBwvzTW5FcHtnJXgUatLpdiiK47Wjr8no= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699013152043538.0757299204257; Fri, 3 Nov 2023 05:05:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysv6-0007O6-0w; Fri, 03 Nov 2023 08:05: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 1qysv3-0007LR-S8 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:04:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qysv1-0001U3-Kq for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:04:57 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-1P9iJ9BTPIaSmNWezdmb8Q-1; Fri, 03 Nov 2023 08:04:53 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 560893C025BE; Fri, 3 Nov 2023 12:04:53 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id C975F492BE0; Fri, 3 Nov 2023 12:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013094; 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=Zv6h0toate0j1Uvf9e0Pm8QwR7BudAmn5Vz4Z5ik9m4=; b=dT/9qh4VISbrsmsZSwHhuKPn+9w0CijG2g1ufXKI9uHndIiej/zobE/BpnSS4nwQ3g62Kj lfj4Z4iadE8zqeo6gg2AbGnT0F4hD5+Vgz+A8nrP4lZCVQEs20sXYyogoWaYfW+hkmd+K8 ESUM8KmdtpPPJl0hH6TFmaZk1wUeWqQ= X-MC-Unique: 1P9iJ9BTPIaSmNWezdmb8Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras Subject: [PULL 1/7] system/dirtylimit: Fix a race situation Date: Fri, 3 Nov 2023 13:04:42 +0100 Message-ID: <20231103120448.58428-2-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013153869100004 Content-Type: text/plain; charset="utf-8" From: Hyman Huang Fix a race situation for global variable dirtylimit_state. Also, replace usleep by g_usleep to increase platform accessibility to the sleep function. Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <27c86239e21eda03d11ce5a3d07da3c229f562e3.1698847223.git.yong.h= uang@smartx.com> --- system/dirtylimit.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/system/dirtylimit.c b/system/dirtylimit.c index fa959d7743..3666c4cb7c 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -411,12 +411,20 @@ void dirtylimit_set_all(uint64_t quota, =20 void dirtylimit_vcpu_execute(CPUState *cpu) { - if (dirtylimit_in_service() && - dirtylimit_vcpu_get_state(cpu->cpu_index)->enabled && - cpu->throttle_us_per_full) { - trace_dirtylimit_vcpu_execute(cpu->cpu_index, - cpu->throttle_us_per_full); - usleep(cpu->throttle_us_per_full); + if (cpu->throttle_us_per_full) { + dirtylimit_state_lock(); + + if (dirtylimit_in_service() && + dirtylimit_vcpu_get_state(cpu->cpu_index)->enabled) { + dirtylimit_state_unlock(); + trace_dirtylimit_vcpu_execute(cpu->cpu_index, + cpu->throttle_us_per_full); + + g_usleep(cpu->throttle_us_per_full); + return; + } + + dirtylimit_state_unlock(); } } =20 --=20 2.41.0 From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013178; cv=none; d=zohomail.com; s=zohoarc; b=PuT9LmCHjTupQq6/HvNIQgG6fOvFfNZXbtdW8eBnqlNqzr9nSXIf0X9C6sk4itTfwAmVJrc/uM7Nqqy9xJ6LUfqj9YlB616qOZcBlArk/gEmy2nd0jGv8lknpECn2cvs1yhwgCUKnHpM0cI0NEC75rp6QsrTp0FI6SkJSVKrzqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013178; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eUGOHMrT/dHXBeGyGoGwtViWpxYmPvvbWsPWQxvPoUI=; b=SEnZOcZ5LFfr0NysluDF2gli2ic/tvm0jJGxaeGV2QQm5PO1oEY00rd4ks7m8oJ3DvaAIupYbp1+3U8Uii9y9u82cP6/SZTxToXxITHEIOklm2D/3ahqmLYJ7mN2UHOxUtcITVUg2m88mZwlhbnjRvhp7aSefRTvruuYqR/G7YU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699013178169548.3578813561438; Fri, 3 Nov 2023 05:06:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysvW-0007ZF-LU; Fri, 03 Nov 2023 08:05:26 -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 1qysv6-0007PW-PL for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:02 -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 1qysv5-0001Vw-Cd for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:00 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-_7FAY9f5N3Cyaz6mw7oJ1g-1; Fri, 03 Nov 2023 08:04:55 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C76B3C025BE; Fri, 3 Nov 2023 12:04:55 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E953492BE0; Fri, 3 Nov 2023 12:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013098; 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=eUGOHMrT/dHXBeGyGoGwtViWpxYmPvvbWsPWQxvPoUI=; b=J2JWlEJcZ5ii2QmNWFD54/Ji8aJwvtFrPcgoijQSIMscEoyPhehhyNR+RBuPsW5uiFKc7N HEeNWGZ/3qFl0ON8a2vQ4xEcxeO4JSApmNJSJssuakGLnZeifxAYJcqDfJF4l9KP8hOC6v KvBuDxR4mNjJJUSFJP3ii5oSpaBzzYU= X-MC-Unique: _7FAY9f5N3Cyaz6mw7oJ1g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras Subject: [PULL 2/7] system/dirtylimit: Drop the reduplicative check Date: Fri, 3 Nov 2023 13:04:43 +0100 Message-ID: <20231103120448.58428-3-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013180338100003 Content-Type: text/plain; charset="utf-8" From: Hyman Huang Checking if dirty limit is in service is done by the dirtylimit_query_all function, drop the reduplicative check in the qmp_query_vcpu_dirty_limit function. Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: --- system/dirtylimit.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/system/dirtylimit.c b/system/dirtylimit.c index 3666c4cb7c..495c7a7082 100644 --- a/system/dirtylimit.c +++ b/system/dirtylimit.c @@ -652,10 +652,6 @@ static struct DirtyLimitInfoList *dirtylimit_query_all= (void) =20 struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit(Error **errp) { - if (!dirtylimit_in_service()) { - return NULL; - } - return dirtylimit_query_all(); } =20 --=20 2.41.0 From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013159; cv=none; d=zohomail.com; s=zohoarc; b=EvkVtQgHS7A62jTTN6hVjzZUYT9lva2mEjNL6kZXIHgIV51z38NSpQ1AOTcN1aB8tTTLbotovCMNnvoWdOD2VZPlPtiWOlGS2VT6P4WF3qRmKLSO/EHgZTs+eABDv298UU2uKISWZX/aLgfprYFdz+yHv5q6AX8Fy4evjZlYQP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013159; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SJcPKlHqzZhiDYhH2sviJGZLv0KId/eEDc++hqWoApM=; b=QGqow6ils4dAZwABAOxn6MAS7/qloROvRwipGU2luBnMYracsp1qj80XcpIGxCmn74n9buiYiNpGz62CI5Gu1Zg6SK2Z8lTUimLQRdimMlcSXcHVIir1HmEPYHq6cl2w0OUQCDO806zqg4iOMQKXvWYtglHSRy+G1wQxvmqZBis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699013159757167.52213040505342; Fri, 3 Nov 2023 05:05:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysva-0007bT-FT; Fri, 03 Nov 2023 08:05:30 -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 1qysv9-0007QD-3u for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:03 -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 1qysv6-0001W4-PS for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:02 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-W0XqLH3gMz-VobbwqOsUhg-1; Fri, 03 Nov 2023 08:04:57 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 259A2101A53B; Fri, 3 Nov 2023 12:04:57 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74DFE492BE0; Fri, 3 Nov 2023 12:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013099; 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=SJcPKlHqzZhiDYhH2sviJGZLv0KId/eEDc++hqWoApM=; b=YtLJ4Vxk4Sb0pGR57sAnvJZKb/3ED771eAeghOg2V31hYb93W9BVQW4ocpUA/1+i7/myjL bis9UNazy/9vX1xKSCxzSdcKCFKEIq+BnFlLFoXeLTz0N6QZ7ucpa4ZNsijGcmL1Wyi4tK bWP55bv92Hv/FR4gxxOD42l7DyWzx7I= X-MC-Unique: W0XqLH3gMz-VobbwqOsUhg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras Subject: [PULL 3/7] tests: Add migration dirty-limit capability test Date: Fri, 3 Nov 2023 13:04:44 +0100 Message-ID: <20231103120448.58428-4-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013160415100001 Content-Type: text/plain; charset="utf-8" From: Hyman Huang Add migration dirty-limit capability test if kernel support dirty ring. Migration dirty-limit capability introduce dirty limit capability, two parameters: x-vcpu-dirty-limit-period and vcpu-dirty-limit are introduced to implement the live migration with dirty limit. The test case does the following things: 1. start src, dst vm and enable dirty-limit capability 2. start migrate and set cancel it to check if dirty limit stop working. 3. restart dst vm 4. start migrate and enable dirty-limit capability 5. check if migration satisfy the convergence condition during pre-switchover phase. Note that this test case involves many passes, so it runs in slow mode only. Signed-off-by: Hyman Huang Acked-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: --- tests/qtest/migration-test.c | 164 +++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index e803b46039..5752412b64 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -3091,6 +3091,166 @@ static void test_vcpu_dirty_limit(void) dirtylimit_stop_vm(vm); } =20 +static void migrate_dirty_limit_wait_showup(QTestState *from, + const int64_t period, + const int64_t value) +{ + /* Enable dirty limit capability */ + migrate_set_capability(from, "dirty-limit", true); + + /* Set dirty limit parameters */ + migrate_set_parameter_int(from, "x-vcpu-dirty-limit-period", period); + migrate_set_parameter_int(from, "vcpu-dirty-limit", value); + + /* Make sure migrate can't converge */ + migrate_ensure_non_converge(from); + + /* To check limit rate after precopy */ + migrate_set_capability(from, "pause-before-switchover", true); + + /* Wait for the serial output from the source */ + wait_for_serial("src_serial"); +} + +/* + * This test does: + * source destination + * start vm + * start incoming vm + * migrate + * wait dirty limit to begin + * cancel migrate + * cancellation check + * restart incoming vm + * migrate + * wait dirty limit to begin + * wait pre-switchover event + * convergence condition check + * + * And see if dirty limit migration works correctly. + * This test case involves many passes, so it runs in slow mode only. + */ +static void test_migrate_dirty_limit(void) +{ + g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + QTestState *from, *to; + int64_t remaining; + uint64_t throttle_us_per_full; + /* + * We want the test to be stable and as fast as possible. + * E.g., with 1Gb/s bandwith migration may pass without dirty limit, + * so we need to decrease a bandwidth. + */ + const int64_t dirtylimit_period =3D 1000, dirtylimit_value =3D 50; + const int64_t max_bandwidth =3D 400000000; /* ~400Mb/s */ + const int64_t downtime_limit =3D 250; /* 250ms */ + /* + * We migrate through unix-socket (> 500Mb/s). + * Thus, expected migration speed ~=3D bandwidth limit (< 500Mb/s). + * So, we can predict expected_threshold + */ + const int64_t expected_threshold =3D max_bandwidth * downtime_limit / = 1000; + int max_try_count =3D 10; + MigrateCommon args =3D { + .start =3D { + .hide_stderr =3D true, + .use_dirty_ring =3D true, + }, + .listen_uri =3D uri, + .connect_uri =3D uri, + }; + + /* Start src, dst vm */ + if (test_migrate_start(&from, &to, args.listen_uri, &args.start)) { + return; + } + + /* Prepare for dirty limit migration and wait src vm show up */ + migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_va= lue); + + /* Start migrate */ + migrate_qmp(from, uri, "{}"); + + /* Wait for dirty limit throttle begin */ + throttle_us_per_full =3D 0; + while (throttle_us_per_full =3D=3D 0) { + throttle_us_per_full =3D + read_migrate_property_int(from, "dirty-limit-throttle-time-per-rou= nd"); + usleep(100); + g_assert_false(got_src_stop); + } + + /* Now cancel migrate and wait for dirty limit throttle switch off */ + migrate_cancel(from); + wait_for_migration_status(from, "cancelled", NULL); + + /* Check if dirty limit throttle switched off, set timeout 1ms */ + do { + throttle_us_per_full =3D + read_migrate_property_int(from, "dirty-limit-throttle-time-per-rou= nd"); + usleep(100); + g_assert_false(got_src_stop); + } while (throttle_us_per_full !=3D 0 && --max_try_count); + + /* Assert dirty limit is not in service */ + g_assert_cmpint(throttle_us_per_full, =3D=3D, 0); + + args =3D (MigrateCommon) { + .start =3D { + .only_target =3D true, + .use_dirty_ring =3D true, + }, + .listen_uri =3D uri, + .connect_uri =3D uri, + }; + + /* Restart dst vm, src vm already show up so we needn't wait anymore */ + if (test_migrate_start(&from, &to, args.listen_uri, &args.start)) { + return; + } + + /* Start migrate */ + migrate_qmp(from, uri, "{}"); + + /* Wait for dirty limit throttle begin */ + throttle_us_per_full =3D 0; + while (throttle_us_per_full =3D=3D 0) { + throttle_us_per_full =3D + read_migrate_property_int(from, "dirty-limit-throttle-time-per-rou= nd"); + usleep(100); + g_assert_false(got_src_stop); + } + + /* + * The dirty limit rate should equals the return value of + * query-vcpu-dirty-limit if dirty limit cap set + */ + g_assert_cmpint(dirtylimit_value, =3D=3D, get_limit_rate(from)); + + /* Now, we have tested if dirty limit works, let it converge */ + migrate_set_parameter_int(from, "downtime-limit", downtime_limit); + migrate_set_parameter_int(from, "max-bandwidth", max_bandwidth); + + /* + * Wait for pre-switchover status to check if migration + * satisfy the convergence condition + */ + wait_for_migration_status(from, "pre-switchover", NULL); + + remaining =3D read_ram_property_int(from, "remaining"); + g_assert_cmpint(remaining, <, + (expected_threshold + expected_threshold / 100)); + + migrate_continue(from, "pre-switchover"); + + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + + test_migrate_end(from, to, true); +} + static bool kvm_dirty_ring_supported(void) { #if defined(__linux__) && defined(HOST_X86_64) @@ -3301,6 +3461,10 @@ int main(int argc, char **argv) */ if (g_test_slow()) { qtest_add_func("/migration/auto_converge", test_migrate_auto_conve= rge); + if (g_str_equal(arch, "x86_64") && + has_kvm && kvm_dirty_ring_supported()) { + qtest_add_func("/migration/dirty_limit", test_migrate_dirty_li= mit); + } } qtest_add_func("/migration/multifd/tcp/plain/none", test_multifd_tcp_none); --=20 2.41.0 From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013174; cv=none; d=zohomail.com; s=zohoarc; b=GDVSMuGuGu8Aiem9gmSeFB4K3D2L5NEXCt6Fw7ipTcJgfnL2tD0qAZZlH/Tj9lsF8E/vQnk3PefujyMIBIVoQMEtrvpPJnziGqawEHankJksc6Lu8yFWLuoYj3VdI/uLVG2DM/FAr8zXmDTEdxD7KBUn5x2489CGizwJvmJow+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013174; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+nJNRbEMQAtS6iL9v7wbR0wAMwKlEK6MBj5BV2t71xs=; b=kpk46N5Y8PnB9hamhPyFGRTdNYLQ6IF2pNMEO75o1Urw35MlYczfIS/VS0b5YyTNQRNk5nFtIHRwQrht2t8W1zKwyFHKfOQ4OJoW6vnf7P90uQHfZYDPCLPlJ0wVVewJc7Ep+2hvxnGchnvkd6ALw30bGPkuFqKfERj7YrNYkV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699013174185198.56122367255523; Fri, 3 Nov 2023 05:06:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysva-0007cA-Rv; Fri, 03 Nov 2023 08:05:30 -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 1qysvA-0007Qa-M1 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:14 -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 1qysv8-0001WV-Ko for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:04 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-ZLfeaU3aO-mwmCqOI1mkcg-1; Fri, 03 Nov 2023 08:04:59 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E97E1C0F2DF; Fri, 3 Nov 2023 12:04:59 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D756492BE0; Fri, 3 Nov 2023 12:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013101; 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=+nJNRbEMQAtS6iL9v7wbR0wAMwKlEK6MBj5BV2t71xs=; b=b0GZuxtsc94zx4by7/alhDq0K5cm+DuiZvo+ytMDWOEgawYUnDIQFkc0SD+69Jw0ohCz4b 7XEel9gulpV0uOrIKeVmxLPb1PqV6s3m5CM/lQH3hL6rHYURe8KhmqHpkKuEZbJvDvfqxo 9t/ZVikyOV6fP3rG9Ti3otzpaMGkE/8= X-MC-Unique: ZLfeaU3aO-mwmCqOI1mkcg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras Subject: [PULL 4/7] tests/migration: Introduce dirty-ring-size option into guestperf Date: Fri, 3 Nov 2023 13:04:45 +0100 Message-ID: <20231103120448.58428-5-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013176364100003 Content-Type: text/plain; charset="utf-8" From: Hyman Huang Dirty ring size configuration is not supported by guestperf tool. Introduce dirty-ring-size (ranges in [1024, 65536]) option so developers can play with dirty-ring and dirty-limit feature easier. To set dirty ring size with 4096 during migration test: $ ./tests/migration/guestperf.py --dirty-ring-size 4096 xxx Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Signed-off-by: Juan Quintela Message-ID: <8a388cec5c1f73a34d42515bbc43837e97ee3839.1698847223.git.yong.h= uang@smartx.com> --- tests/migration/guestperf/engine.py | 6 +++++- tests/migration/guestperf/hardware.py | 8 ++++++-- tests/migration/guestperf/shell.py | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestper= f/engine.py index da96ca034a..aabf6de4d9 100644 --- a/tests/migration/guestperf/engine.py +++ b/tests/migration/guestperf/engine.py @@ -325,7 +325,6 @@ def _get_common_args(self, hardware, tunnelled=3DFalse): cmdline =3D "'" + cmdline + "'" =20 argv =3D [ - "-accel", "kvm", "-cpu", "host", "-kernel", self._kernel, "-initrd", self._initrd, @@ -333,6 +332,11 @@ def _get_common_args(self, hardware, tunnelled=3DFalse= ): "-m", str((hardware._mem * 1024) + 512), "-smp", str(hardware._cpus), ] + if hardware._dirty_ring_size: + argv.extend(["-accel", "kvm,dirty-ring-size=3D%s" % + hardware._dirty_ring_size]) + else: + argv.extend(["-accel", "kvm"]) =20 argv.extend(self._get_qemu_serial_args()) =20 diff --git a/tests/migration/guestperf/hardware.py b/tests/migration/guestp= erf/hardware.py index 3145785ffd..f779cc050b 100644 --- a/tests/migration/guestperf/hardware.py +++ b/tests/migration/guestperf/hardware.py @@ -23,7 +23,8 @@ def __init__(self, cpus=3D1, mem=3D1, src_cpu_bind=3DNone, src_mem_bind=3DNone, dst_cpu_bind=3DNone, dst_mem_bind=3DNone, prealloc_pages =3D False, - huge_pages=3DFalse, locked_pages=3DFalse): + huge_pages=3DFalse, locked_pages=3DFalse, + dirty_ring_size=3D0): self._cpus =3D cpus self._mem =3D mem # GiB self._src_mem_bind =3D src_mem_bind # List of NUMA nodes @@ -33,6 +34,7 @@ def __init__(self, cpus=3D1, mem=3D1, self._prealloc_pages =3D prealloc_pages self._huge_pages =3D huge_pages self._locked_pages =3D locked_pages + self._dirty_ring_size =3D dirty_ring_size =20 =20 def serialize(self): @@ -46,6 +48,7 @@ def serialize(self): "prealloc_pages": self._prealloc_pages, "huge_pages": self._huge_pages, "locked_pages": self._locked_pages, + "dirty_ring_size": self._dirty_ring_size, } =20 @classmethod @@ -59,4 +62,5 @@ def deserialize(cls, data): data["dst_mem_bind"], data["prealloc_pages"], data["huge_pages"], - data["locked_pages"]) + data["locked_pages"], + data["dirty_ring_size"]) diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf= /shell.py index 8a809e3dda..7d6b8cd7cf 100644 --- a/tests/migration/guestperf/shell.py +++ b/tests/migration/guestperf/shell.py @@ -60,6 +60,8 @@ def __init__(self): parser.add_argument("--prealloc-pages", dest=3D"prealloc_pages", d= efault=3DFalse) parser.add_argument("--huge-pages", dest=3D"huge_pages", default= =3DFalse) parser.add_argument("--locked-pages", dest=3D"locked_pages", defau= lt=3DFalse) + parser.add_argument("--dirty-ring-size", dest=3D"dirty_ring_size", + default=3D0, type=3Dint) =20 self._parser =3D parser =20 @@ -89,7 +91,9 @@ def split_map(value): =20 locked_pages=3Dargs.locked_pages, huge_pages=3Dargs.huge_pages, - prealloc_pages=3Dargs.prealloc_pages) + prealloc_pages=3Dargs.prealloc_pages, + + dirty_ring_size=3Dargs.dirty_ring_size) =20 =20 class Shell(BaseShell): --=20 2.41.0 From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013212; cv=none; d=zohomail.com; s=zohoarc; b=YPzoxc5BuZVuiTczDQT4+6Sj1Bjs2leZzvGpUpcY+9JPzXE29ymQIa66vcF2jrEwtIYjEM3XYvtFvaHdGwqJy/jqI/vE7JUOaeootRwO6NhB5Td1Nn5D7cXly2JrJd3T4imWFRGf7i+Dq0favO4+XAlxAZGeSBqDDq4+bWoUMHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013212; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hRSHHwPnC2Z9YXzFyuFgbzYTpRZn4iKICC8SMLYuLFE=; b=azODQmS9GPEg+b8dVI3Fk8TiKeaJBsknXjjVEEjQTsV5lWptkJoqRw0WRAjjiZwJfeECXtND9/vfUTw+30+EXKLZrndBJ3eNAn6/PhPYLnamjz/ibhl/+AHWb5CXW5K8wBC8lGdddAneI8OwKEM2zFleoCEh3Lq5r/XopU688KI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699013212359243.228821925626; Fri, 3 Nov 2023 05:06:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysvm-0007mk-NY; Fri, 03 Nov 2023 08:05:42 -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 1qysvB-0007R8-9C for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:17 -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 1qysv9-0001X3-9P for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-mOSR6qidO6in4LrJJQIJmQ-1; Fri, 03 Nov 2023 08:05:01 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12D8F828AC0; Fri, 3 Nov 2023 12:05:01 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64401492BE0; Fri, 3 Nov 2023 12:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013102; 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=hRSHHwPnC2Z9YXzFyuFgbzYTpRZn4iKICC8SMLYuLFE=; b=YstK15IvBPuK0BrcjPYg0RhNukUjzYmacLPfpjrgEoPUX0Qm2NP3qp48Qwsohe0K2uWGXs rvyJ0nIDMtzxATb35ievpDoh2CWYgRQGrTXJW7rbNziydU6qakgwGiwK2yq+i8z+3r2GoI qhnuTOqyEnwQH3ICoki5Z8mUgFFE5dU= X-MC-Unique: mOSR6qidO6in4LrJJQIJmQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras Subject: [PULL 5/7] tests/migration: Introduce dirty-limit into guestperf Date: Fri, 3 Nov 2023 13:04:46 +0100 Message-ID: <20231103120448.58428-6-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013214512100007 Content-Type: text/plain; charset="utf-8" From: Hyman Huang Currently, guestperf does not cover the dirty-limit migration, support this feature. Note that dirty-limit requires 'dirty-ring-size' set. To enable dirty-limit, setting x-vcpu-dirty-limit-period as 500ms and x-vcpu-dirty-limit as 10MB/s: $ ./tests/migration/guestperf.py \ --dirty-ring-size 4096 \ --dirty-limit --x-vcpu-dirty-limit-period 500 \ --vcpu-dirty-limit 10 --output output.json \ To run the entire standardized set of dirty-limit-enabled comparisons, with unix migration: $ ./tests/migration/guestperf-batch.py \ --dirty-ring-size 4096 \ --dst-host localhost --transport unix \ --filter compr-dirty-limit* --output outputdir Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Message-Id: <516e7a55dfc6e33d33510be37eb24223de5dc072.1697815117.git.yong.h= uang@smartx.com> Message-ID: Signed-off-by: Juan Quintela --- tests/migration/guestperf/comparison.py | 23 +++++++++++++++++++++++ tests/migration/guestperf/engine.py | 17 +++++++++++++++++ tests/migration/guestperf/progress.py | 16 ++++++++++++++-- tests/migration/guestperf/scenario.py | 11 ++++++++++- tests/migration/guestperf/shell.py | 18 +++++++++++++++++- 5 files changed, 81 insertions(+), 4 deletions(-) diff --git a/tests/migration/guestperf/comparison.py b/tests/migration/gues= tperf/comparison.py index c03b3f6d7e..42cc0372d1 100644 --- a/tests/migration/guestperf/comparison.py +++ b/tests/migration/guestperf/comparison.py @@ -135,4 +135,27 @@ def __init__(self, name, scenarios): Scenario("compr-multifd-channels-64", multifd=3DTrue, multifd_channels=3D64), ]), + + # Looking at effect of dirty-limit with + # varying x_vcpu_dirty_limit_period + Comparison("compr-dirty-limit-period", scenarios =3D [ + Scenario("compr-dirty-limit-period-500", + dirty_limit=3DTrue, x_vcpu_dirty_limit_period=3D500), + Scenario("compr-dirty-limit-period-800", + dirty_limit=3DTrue, x_vcpu_dirty_limit_period=3D800), + Scenario("compr-dirty-limit-period-1000", + dirty_limit=3DTrue, x_vcpu_dirty_limit_period=3D1000), + ]), + + + # Looking at effect of dirty-limit with + # varying vcpu_dirty_limit + Comparison("compr-dirty-limit", scenarios =3D [ + Scenario("compr-dirty-limit-10MB", + dirty_limit=3DTrue, vcpu_dirty_limit=3D10), + Scenario("compr-dirty-limit-20MB", + dirty_limit=3DTrue, vcpu_dirty_limit=3D20), + Scenario("compr-dirty-limit-50MB", + dirty_limit=3DTrue, vcpu_dirty_limit=3D50), + ]), ] diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestper= f/engine.py index aabf6de4d9..608d7270f6 100644 --- a/tests/migration/guestperf/engine.py +++ b/tests/migration/guestperf/engine.py @@ -102,6 +102,8 @@ def _migrate_progress(self, vm): info.get("expected-downtime", 0), info.get("setup-time", 0), info.get("cpu-throttle-percentage", 0), + info.get("dirty-limit-throttle-time-per-round", 0), + info.get("dirty-limit-ring-full-time", 0), ) =20 def _migrate(self, hardware, scenario, src, dst, connect_uri): @@ -203,6 +205,21 @@ def _migrate(self, hardware, scenario, src, dst, conne= ct_uri): resp =3D dst.cmd("migrate-set-parameters", multifd_channels=3Dscenario._multifd_channels) =20 + if scenario._dirty_limit: + if not hardware._dirty_ring_size: + raise Exception("dirty ring size must be configured when " + "testing dirty limit migration") + + resp =3D src.cmd("migrate-set-capabilities", + capabilities =3D [ + { "capability": "dirty-limit", + "state": True } + ]) + resp =3D src.cmd("migrate-set-parameters", + x_vcpu_dirty_limit_period=3Dscenario._x_vcpu_dirty_limit_p= eriod) + resp =3D src.cmd("migrate-set-parameters", + vcpu_dirty_limit=3Dscenario._vcpu_dirty_limit) + resp =3D src.cmd("migrate", uri=3Dconnect_uri) =20 post_copy =3D False diff --git a/tests/migration/guestperf/progress.py b/tests/migration/guestp= erf/progress.py index ab1ee57273..d490584217 100644 --- a/tests/migration/guestperf/progress.py +++ b/tests/migration/guestperf/progress.py @@ -81,7 +81,9 @@ def __init__(self, downtime, downtime_expected, setup_time, - throttle_pcent): + throttle_pcent, + dirty_limit_throttle_time_per_round, + dirty_limit_ring_full_time): =20 self._status =3D status self._ram =3D ram @@ -91,6 +93,10 @@ def __init__(self, self._downtime_expected =3D downtime_expected self._setup_time =3D setup_time self._throttle_pcent =3D throttle_pcent + self._dirty_limit_throttle_time_per_round =3D \ + dirty_limit_throttle_time_per_round + self._dirty_limit_ring_full_time =3D \ + dirty_limit_ring_full_time =20 def serialize(self): return { @@ -102,6 +108,10 @@ def serialize(self): "downtime_expected": self._downtime_expected, "setup_time": self._setup_time, "throttle_pcent": self._throttle_pcent, + "dirty_limit_throttle_time_per_round": + self._dirty_limit_throttle_time_per_round, + "dirty_limit_ring_full_time": + self._dirty_limit_ring_full_time, } =20 @classmethod @@ -114,4 +124,6 @@ def deserialize(cls, data): data["downtime"], data["downtime_expected"], data["setup_time"], - data["throttle_pcent"]) + data["throttle_pcent"], + data["dirty_limit_throttle_time_per_round"], + data["dirty_limit_ring_full_time"]) diff --git a/tests/migration/guestperf/scenario.py b/tests/migration/guestp= erf/scenario.py index de70d9b2f5..154c4f5d5f 100644 --- a/tests/migration/guestperf/scenario.py +++ b/tests/migration/guestperf/scenario.py @@ -30,7 +30,9 @@ def __init__(self, name, auto_converge=3DFalse, auto_converge_step=3D10, compression_mt=3DFalse, compression_mt_threads=3D1, compression_xbzrle=3DFalse, compression_xbzrle_cache=3D10, - multifd=3DFalse, multifd_channels=3D2): + multifd=3DFalse, multifd_channels=3D2, + dirty_limit=3DFalse, x_vcpu_dirty_limit_period=3D500, + vcpu_dirty_limit=3D1): =20 self._name =3D name =20 @@ -60,6 +62,10 @@ def __init__(self, name, self._multifd =3D multifd self._multifd_channels =3D multifd_channels =20 + self._dirty_limit =3D dirty_limit + self._x_vcpu_dirty_limit_period =3D x_vcpu_dirty_limit_period + self._vcpu_dirty_limit =3D vcpu_dirty_limit + def serialize(self): return { "name": self._name, @@ -79,6 +85,9 @@ def serialize(self): "compression_xbzrle_cache": self._compression_xbzrle_cache, "multifd": self._multifd, "multifd_channels": self._multifd_channels, + "dirty_limit": self._dirty_limit, + "x_vcpu_dirty_limit_period": self._x_vcpu_dirty_limit_period, + "vcpu_dirty_limit": self._vcpu_dirty_limit, } =20 @classmethod diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf= /shell.py index 7d6b8cd7cf..c85d89efec 100644 --- a/tests/migration/guestperf/shell.py +++ b/tests/migration/guestperf/shell.py @@ -131,6 +131,17 @@ def __init__(self): parser.add_argument("--multifd-channels", dest=3D"multifd_channels= ", default=3D2, type=3Dint) =20 + parser.add_argument("--dirty-limit", dest=3D"dirty_limit", default= =3DFalse, + action=3D"store_true") + + parser.add_argument("--x-vcpu-dirty-limit-period", + dest=3D"x_vcpu_dirty_limit_period", + default=3D500, type=3Dint) + + parser.add_argument("--vcpu-dirty-limit", + dest=3D"vcpu_dirty_limit", + default=3D1, type=3Dint) + def get_scenario(self, args): return Scenario(name=3D"perfreport", downtime=3Dargs.downtime, @@ -154,7 +165,12 @@ def get_scenario(self, args): compression_xbzrle_cache=3Dargs.compression_xbzrle= _cache, =20 multifd=3Dargs.multifd, - multifd_channels=3Dargs.multifd_channels) + multifd_channels=3Dargs.multifd_channels, + + dirty_limit=3Dargs.dirty_limit, + x_vcpu_dirty_limit_period=3D\ + args.x_vcpu_dirty_limit_period, + vcpu_dirty_limit=3Dargs.vcpu_dirty_limit) =20 def run(self, argv): args =3D self._parser.parse_args(argv) --=20 2.41.0 From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013154; cv=none; d=zohomail.com; s=zohoarc; b=IegpB+Zb667uf2Dd2Qz3XgWnaY4nu8onU4N38w3WyN0FOTuAceOqejhqFeimo3b/EoTEfye3fh1bTsBAHYB5fUjw8OIpjMsvA4ktRnPPNG3HGHi1JVoyipGqNBMrgVOAueZnw3Q1052ynBov5iKzpdf/OBQypvQNdvpfbTdT9kU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013154; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OuumQ6CMhzFrUiWF8J0EXQY2x/d5itSYYSukSJVzVFw=; b=CwMZG3cqCjO3LTGmvbOKYI4nVoTxXZQ4DQQCYDdE103roTQ1b/nAqkr2n91ocmUsJ0LRS/li1NIatRQPf6aAE96mRTG+QXGo0n4wt2eWMgQxnphflavh38w36s1DxFto2LwF6Wcnu5i15qVxwx8FOkiUcNv2wpA9rwLkzhC9uN0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699013154323307.0749425365947; Fri, 3 Nov 2023 05:05:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysvf-0007dO-27; Fri, 03 Nov 2023 08:05:35 -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 1qysvG-0007UH-07 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:18 -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 1qysvC-0001aG-0b for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-LB7Hzr_wOI-Llf_vhby0Og-1; Fri, 03 Nov 2023 08:05:03 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDAB288D287; Fri, 3 Nov 2023 12:05:02 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A95C492BE0; Fri, 3 Nov 2023 12:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013105; 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=OuumQ6CMhzFrUiWF8J0EXQY2x/d5itSYYSukSJVzVFw=; b=BuP1yjAyXDG3+9qPNQnZcOzyqDb58EFFd1FqqSOTsfVsu1piLpZuCJJvfCqhxlicTL7a/R PrjT3SQcp8hYQo2AyELkqyV3tiZVWev0LjiSi9GAsHhOATXOXQ9l2KeLVBJmmxvuXrDx55 bDpdMnkmPyDSiFhEcXZw9HKgNrEm1MM= X-MC-Unique: LB7Hzr_wOI-Llf_vhby0Og-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras Subject: [PULL 6/7] docs/migration: Add the dirty limit section Date: Fri, 3 Nov 2023 13:04:47 +0100 Message-ID: <20231103120448.58428-7-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013156398100010 Content-Type: text/plain; charset="utf-8" From: Hyman Huang The dirty limit feature has been introduced since the 8.1 QEMU release but has not reflected in the document, add a section for that. Signed-off-by: Hyman Huang Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <0f2b2c63fec22ea23e4926cdeb567b7a0ebd8152.1698847223.git.yong.h= uang@smartx.com> --- docs/devel/migration.rst | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 240eb16d90..5adf4f12f7 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -594,6 +594,77 @@ path. Return path - opened by main thread, written by main thread AND post= copy thread (protected by rp_mutex) =20 +Dirty limit +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The dirty limit, short for dirty page rate upper limit, is a new capability +introduced in the 8.1 QEMU release that uses a new algorithm based on the = KVM +dirty ring to throttle down the guest during live migration. + +The algorithm framework is as follows: + +:: + + ------------------------------------------------------------------------= ------ + main --------------> throttle thread ------------> PREPARE(1) <-------- + thread \ | | + \ | | + \ V | + -\ CALCULATE(2) | + \ | | + \ | | + \ V | + \ SET PENALTY(3) ----- + -\ | + \ | + \ V + -> virtual CPU thread -------> ACCEPT PENALTY(4) + ------------------------------------------------------------------------= ------ + +When the qmp command qmp_set_vcpu_dirty_limit is called for the first time, +the QEMU main thread starts the throttle thread. The throttle thread, once +launched, executes the loop, which consists of three steps: + + - PREPARE (1) + + The entire work of PREPARE (1) is preparation for the second stage, + CALCULATE(2), as the name implies. It involves preparing the dirty + page rate value and the corresponding upper limit of the VM: + The dirty page rate is calculated via the KVM dirty ring mechanism, + which tells QEMU how many dirty pages a virtual CPU has had since the + last KVM_EXIT_DIRTY_RING_FULL exception; The dirty page rate upper + limit is specified by caller, therefore fetch it directly. + + - CALCULATE (2) + + Calculate a suitable sleep period for each virtual CPU, which will be + used to determine the penalty for the target virtual CPU. The + computation must be done carefully in order to reduce the dirty page + rate progressively down to the upper limit without oscillation. To + achieve this, two strategies are provided: the first is to add or + subtract sleep time based on the ratio of the current dirty page rate + to the limit, which is used when the current dirty page rate is far + from the limit; the second is to add or subtract a fixed time when + the current dirty page rate is close to the limit. + + - SET PENALTY (3) + + Set the sleep time for each virtual CPU that should be penalized based + on the results of the calculation supplied by step CALCULATE (2). + +After completing the three above stages, the throttle thread loops back +to step PREPARE (1) until the dirty limit is reached. + +On the other hand, each virtual CPU thread reads the sleep duration and +sleeps in the path of the KVM_EXIT_DIRTY_RING_FULL exception handler, that +is ACCEPT PENALTY (4). Virtual CPUs tied with writing processes will +obviously exit to the path and get penalized, whereas virtual CPUs involved +with read processes will not. + +In summary, thanks to the KVM dirty ring technology, the dirty limit +algorithm will restrict virtual CPUs as needed to keep their dirty page +rate inside the limit. This leads to more steady reading performance during +live migration and can aid in improving large guest responsiveness. + Postcopy =3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.41.0 From nobody Wed Nov 27 12:28:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699013210; cv=none; d=zohomail.com; s=zohoarc; b=BKxr2lLOh4Lwm88xx71yoMZ/GiqS7Jo5Arc4AbSAAFBnUkEAYtFuh53tfbvgiKxqOOsauSrdQKsye6z5XciD2WowobyNd+8sMf0GBKLzS5oGy4LS7S1yoBxvyOTxgp/qRK4M5Nztgo800UsDYU+/HxT+YWZATE1mMLTu5ivbozw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699013210; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Po37/l/PnN1kE4BKj/BqCDJtnhPBibDBhhPnhzgrvoQ=; b=cnREMBUElmJkL5+N2EwgRqPUvazjOBoQ9sSzSZT+6yyWrCoy2UtYJpOjwIdWQ+LzcPZF3Ma6KgSPttz2zUjbWP1E2gZi2pG4iXwRYRJ6QAd4FnSBkhcxcg5o5xIsJ1b/lEQ7jKWjWzZOqG9c+HfpQcFo0fRs/ekQCCCGiVBiTLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169901321051749.838690511142545; Fri, 3 Nov 2023 05:06:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qysvn-0007um-Hk; Fri, 03 Nov 2023 08:05:43 -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 1qysvM-0007Xk-52 for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:22 -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 1qysvI-0001f4-SR for qemu-devel@nongnu.org; Fri, 03 Nov 2023 08:05:15 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-WX0z8KULNASgPld8e0hcjg-1; Fri, 03 Nov 2023 08:05:08 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCB2385A59D; Fri, 3 Nov 2023 12:05:04 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F2FC492BE0; Fri, 3 Nov 2023 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699013111; 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=Po37/l/PnN1kE4BKj/BqCDJtnhPBibDBhhPnhzgrvoQ=; b=Vakv9sam2pieukPaRm36bL5i4XiqSTmx9A2CPaHN2O9OVI2kWSMfnpzo9zTsXzNpRvgCr9 tsOJFivsoaPW4ut43P/shAcxbEqbla3sN+QUD/ncRcFFqktMKoeuy4cw25NFv6TPltvLiO AWQYy+oB0+X69hE3PBnUS8yYC/P4WWU= X-MC-Unique: WX0z8KULNASgPld8e0hcjg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hyman Huang , Thomas Huth , Peter Xu , Paolo Bonzini , Fabiano Rosas , Laurent Vivier , Juan Quintela , Leonardo Bras , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 7/7] migration: Unlock mutex in error case Date: Fri, 3 Nov 2023 13:04:48 +0100 Message-ID: <20231103120448.58428-8-quintela@redhat.com> In-Reply-To: <20231103120448.58428-1-quintela@redhat.com> References: <20231103120448.58428-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.47, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699013212475100001 We were not unlocking bitmap mutex on the error case. To fix it forever change to enclose the code with WITH_QEMU_LOCK_GUARD(). Coverity CID 1523750. Fixes: a2326705e5 ("migration: Stop migration immediately in RDMA error pat= hs") Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Juan Quintela Message-ID: <20231103074245.55166-1-quintela@redhat.com> --- migration/ram.c | 106 ++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index a0f3b86663..8c7886ab79 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3030,71 +3030,71 @@ static int ram_save_iterate(QEMUFile *f, void *opaq= ue) * MAX_WAIT (if curious, further see commit 4508bd9ed8053ce) below, wh= ich * guarantees that we'll at least released it in a regular basis. */ - qemu_mutex_lock(&rs->bitmap_mutex); - WITH_RCU_READ_LOCK_GUARD() { - if (ram_list.version !=3D rs->last_version) { - ram_state_reset(rs); - } - - /* Read version before ram_list.blocks */ - smp_rmb(); - - ret =3D rdma_registration_start(f, RAM_CONTROL_ROUND); - if (ret < 0) { - qemu_file_set_error(f, ret); - goto out; - } - - t0 =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - i =3D 0; - while ((ret =3D migration_rate_exceeded(f)) =3D=3D 0 || - postcopy_has_request(rs)) { - int pages; - - if (qemu_file_get_error(f)) { - break; + WITH_QEMU_LOCK_GUARD(&rs->bitmap_mutex) { + WITH_RCU_READ_LOCK_GUARD() { + if (ram_list.version !=3D rs->last_version) { + ram_state_reset(rs); } =20 - pages =3D ram_find_and_save_block(rs); - /* no more pages to sent */ - if (pages =3D=3D 0) { - done =3D 1; - break; - } + /* Read version before ram_list.blocks */ + smp_rmb(); =20 - if (pages < 0) { - qemu_file_set_error(f, pages); - break; + ret =3D rdma_registration_start(f, RAM_CONTROL_ROUND); + if (ret < 0) { + qemu_file_set_error(f, ret); + goto out; } =20 - rs->target_page_count +=3D pages; + t0 =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + i =3D 0; + while ((ret =3D migration_rate_exceeded(f)) =3D=3D 0 || + postcopy_has_request(rs)) { + int pages; =20 - /* - * During postcopy, it is necessary to make sure one whole host - * page is sent in one chunk. - */ - if (migrate_postcopy_ram()) { - compress_flush_data(); - } + if (qemu_file_get_error(f)) { + break; + } + + pages =3D ram_find_and_save_block(rs); + /* no more pages to sent */ + if (pages =3D=3D 0) { + done =3D 1; + break; + } =20 - /* - * we want to check in the 1st loop, just in case it was the 1= st - * time and we had to sync the dirty bitmap. - * qemu_clock_get_ns() is a bit expensive, so we only check ea= ch - * some iterations - */ - if ((i & 63) =3D=3D 0) { - uint64_t t1 =3D (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - = t0) / - 1000000; - if (t1 > MAX_WAIT) { - trace_ram_save_iterate_big_wait(t1, i); + if (pages < 0) { + qemu_file_set_error(f, pages); break; } + + rs->target_page_count +=3D pages; + + /* + * During postcopy, it is necessary to make sure one whole= host + * page is sent in one chunk. + */ + if (migrate_postcopy_ram()) { + compress_flush_data(); + } + + /* + * we want to check in the 1st loop, just in case it was t= he 1st + * time and we had to sync the dirty bitmap. + * qemu_clock_get_ns() is a bit expensive, so we only chec= k each + * some iterations + */ + if ((i & 63) =3D=3D 0) { + uint64_t t1 =3D (qemu_clock_get_ns(QEMU_CLOCK_REALTIME= ) - t0) / + 1000000; + if (t1 > MAX_WAIT) { + trace_ram_save_iterate_big_wait(t1, i); + break; + } + } + i++; } - i++; } } - qemu_mutex_unlock(&rs->bitmap_mutex); =20 /* * Must occur before EOS (or any QEMUFile operation) --=20 2.41.0