From nobody Sun Nov 24 07:44:44 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 ARC-Seal: i=1; a=rsa-sha256; t=1725892039; cv=none; d=zohomail.com; s=zohoarc; b=cRKMBRIw3SPDgRyZz2832cSDI24h7a5FPL7Bm8U1Ps0z5kUK/uewgXoKxQSzcaZKvcbYceC6LILcKQczS0ut7XZvSQHsOpJF9qe500A9LN3nBTwcad4bVkOI+aUduLBjY+LtFNidjmMyTpuzBznAVCTe01GgK/oFsCk/bs8VzdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725892039; 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=PMsMrxXIYF55uyEUpAg6oCulZa95qOnP3qJj8dOgMPY=; b=UTABr+4yFoOYS/7/f3dWKCI+VcRNZleUp2QEDZSxeHG9QCCKUKvv9JZk6FP3kR0+MP5C/9m5MxlK+L66cx7WvPgkFlcgUTRSPHAQlSFg+IHIUkzJQ+WNco6wABsMlUT+IO6ROFc8DLp1VUt+2HtdHHbpQvEzPbQeEwad3O2KNk4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725892039318112.34118139368775; Mon, 9 Sep 2024 07:27:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1snfLb-0002Ya-O0; Mon, 09 Sep 2024 10:26: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 1snfLS-00028L-BG for qemu-devel@nongnu.org; Mon, 09 Sep 2024 10:26:22 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1snfLO-0004Un-BV for qemu-devel@nongnu.org; Mon, 09 Sep 2024 10:26:20 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7163489149eso3529633a12.1 for ; Mon, 09 Sep 2024 07:26:17 -0700 (PDT) Received: from localhost.localdomain ([118.114.94.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58b2a88sm3561164b3a.46.2024.09.09.07.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 07:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1725891976; x=1726496776; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PMsMrxXIYF55uyEUpAg6oCulZa95qOnP3qJj8dOgMPY=; b=MGBDKqVf7zq8wAW3+BY7XkO/pil5AP3J+ti/4GeFhh9q5UA3zmI5gSJEQBNUApmOJb vpE/rHwKulVSGhl28tNhsDonNsNGdmdPrQsTu/Hh9NGDCMA17y0aWTcAyEBJrmFil0XK nGngOZTybIc4hb8+uxJOXrrneK7uHiWNDnCGVZssLs/MiSRG+Fkzid08hBk9kSQkefwt lRqElvgu1xFkqQmq5ihY8dfMnwNlp6hhpX8XPgD51OPaZZSO7i6J47TNmGbB2olgv/pF GS1hMkqI768SEt0r54ca0daQR+xiybs259BIKDJhLo1WhD8QP6rR434ekLz+8+ziKIIb FJZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725891976; x=1726496776; 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=PMsMrxXIYF55uyEUpAg6oCulZa95qOnP3qJj8dOgMPY=; b=xQm9FOJgb9U2qPkfW2OKOyhg6zlhXm3mgOp5lIirOvKeWEg8yEbIxK5FAmT0LnV2BZ S19Bjkmw2K4ISbUOW7vgRiVod+0L6wuGL51VIGMVglXZe/F0MD2buxVy67TZq/T/GOXw Nh3/uyfLkNjzyMG+5oU05Hcj7bNAg4rx8aEETreyZKr8huJDYJnVkMOnPa/AlWQEMPyu 7Ned2dNUdTyFLSricOodZSSC91kp6c/Bze3hc2rw1QsAOXUMP+B7KQP6oqXaozQC/G/9 9l4v8JdUvOPsf7adTd8KxFqxHUTBoV/j04ym1P/P2eFVAx1v/51Rp7rjr3x+prDMjfu+ q4BA== X-Gm-Message-State: AOJu0YymySucwhvn0EJ6AeDwN+zAiVWIhAmNPt7wysOkpsGV8URHvLhE 9FUW2uGUZelqyX7sFis7NB2Cfn0zpgvWS0iOx+Mg69LxzJ9M95D3l8B/qW9JwbrGuOB0yypVKSA GX0vitg== X-Google-Smtp-Source: AGHT+IEMbRYQFUUG8WXjkKSYiGzZOuXV4BZYZPDJVrOdXLDhURhSEXi6aehjLoqkl7nz0x3xD8X6sA== X-Received: by 2002:a05:6a20:4387:b0:1cf:41aa:f6a1 with SMTP id adf61e73a8af0-1cf41ab0323mr3357398637.20.1725891975541; Mon, 09 Sep 2024 07:26:15 -0700 (PDT) From: Hyman Huang To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , Eric Blake , Markus Armbruster , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , yong.huang@smartx.com Subject: [PATCH RESEND RFC 07/10] tests/migration-tests: Add test case for periodic throttle Date: Mon, 9 Sep 2024 22:25:40 +0800 Message-Id: <8eae7759cdef113ff2fd5a77c9374b51dcd72284.1725891841.git.yong.huang@smartx.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::535; envelope-from=yong.huang@smartx.com; helo=mail-pg1-x535.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @smartx-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1725892040198116600 Content-Type: text/plain; charset="utf-8" To make sure periodic throttle feature doesn't regression any features and functionalities, enable this feature in the auto-converge migration test. Signed-off-by: Hyman Huang --- tests/qtest/migration-test.c | 56 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 2fb10658d4..61d7182f88 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -281,6 +281,11 @@ static uint64_t get_migration_pass(QTestState *who) return read_ram_property_int(who, "iteration-count"); } =20 +static uint64_t get_migration_dirty_sync_count(QTestState *who) +{ + return read_ram_property_int(who, "dirty-sync-count"); +} + static void read_blocktime(QTestState *who) { QDict *rsp_return; @@ -710,6 +715,11 @@ typedef struct { PostcopyRecoveryFailStage postcopy_recovery_fail_stage; } MigrateCommon; =20 +typedef struct { + /* CPU throttle parameters */ + bool periodic; +} AutoConvergeArgs; + static int test_migrate_start(QTestState **from, QTestState **to, const char *uri, MigrateStart *args) { @@ -2778,12 +2788,13 @@ static void test_validate_uri_channels_none_set(voi= d) * To make things even worse, we need to run the initial stage at * 3MB/s so we enter autoconverge even when host is (over)loaded. */ -static void test_migrate_auto_converge(void) +static void test_migrate_auto_converge_args(AutoConvergeArgs *input_args) { g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); MigrateStart args =3D {}; QTestState *from, *to; int64_t percentage; + bool periodic =3D (input_args && input_args->periodic); =20 /* * We want the test to be stable and as fast as possible. @@ -2791,6 +2802,7 @@ static void test_migrate_auto_converge(void) * so we need to decrease a bandwidth. */ const int64_t init_pct =3D 5, inc_pct =3D 25, max_pct =3D 95; + const int64_t periodic_throttle_interval =3D 2; =20 if (test_migrate_start(&from, &to, uri, &args)) { return; @@ -2801,6 +2813,12 @@ static void test_migrate_auto_converge(void) migrate_set_parameter_int(from, "cpu-throttle-increment", inc_pct); migrate_set_parameter_int(from, "max-cpu-throttle", max_pct); =20 + if (periodic) { + migrate_set_parameter_bool(from, "cpu-periodic-throttle", true); + migrate_set_parameter_int(from, "cpu-periodic-throttle-interval", + periodic_throttle_interval); + } + /* * Set the initial parameters so that the migration could not converge * without throttling. @@ -2827,6 +2845,29 @@ static void test_migrate_auto_converge(void) } while (true); /* The first percentage of throttling should be at least init_pct */ g_assert_cmpint(percentage, >=3D, init_pct); + + if (periodic) { + /* + * Check if periodic sync take effect, set the timeout with 20s + * (max_try_count * 1s), if extra sync doesn't show up, fail test. + */ + uint64_t iteration_count, dirty_sync_count; + bool extra_sync =3D false; + int max_try_count =3D 20; + + /* Check if periodic sync take effect */ + while (--max_try_count) { + usleep(1000 * 1000); + iteration_count =3D get_migration_pass(from); + dirty_sync_count =3D get_migration_dirty_sync_count(from); + if (dirty_sync_count > iteration_count) { + extra_sync =3D true; + break; + } + } + g_assert(extra_sync); + } + /* Now, when we tested that throttling works, let it converge */ migrate_ensure_converge(from); =20 @@ -2849,6 +2890,17 @@ static void test_migrate_auto_converge(void) test_migrate_end(from, to, true); } =20 +static void test_migrate_auto_converge(void) +{ + test_migrate_auto_converge_args(NULL); +} + +static void test_migrate_auto_converge_periodic_throttle(void) +{ + AutoConvergeArgs args =3D {.periodic =3D true}; + test_migrate_auto_converge_args(&args); +} + static void * test_migrate_precopy_tcp_multifd_start_common(QTestState *from, QTestState *to, @@ -3900,6 +3952,8 @@ int main(int argc, char **argv) if (g_test_slow()) { migration_test_add("/migration/auto_converge", test_migrate_auto_converge); + migration_test_add("/migration/auto_converge_periodic_throttle", + test_migrate_auto_converge_periodic_throttle); if (g_str_equal(arch, "x86_64") && has_kvm && kvm_dirty_ring_supported()) { migration_test_add("/migration/dirty_limit", --=20 2.39.1