From patchwork Mon Feb 26 09:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571715 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 316FA5D75D; Mon, 26 Feb 2024 09:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940335; cv=none; b=Cs+/OOeM2QTvQ1zUpo2Hub/r/BcPxuOHQYofGOyhM5XpmTeSWa2vhwwjp98lzIOy34jmDBt6jPlq1e20YVKtwGy+EGfWz395X5xvnksfeGjwrrBHyUIbQCgc1V2lv7IWzCnntWloEGnV3g58RqqjzUiYQaelRspGxe7SyFFZSBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940335; c=relaxed/simple; bh=01++PoAiahxeiEZNtxpYl/vmuayxoq+N5H5tupQgni4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GNFV7irpKeTwRZ9ZdQhtZw3wMYLxum6R3hViBJQbJRKPkqeSeWKI+COauoOKZM1KrvD3wd7ABGcbMajAU1HPxYKV2bFQGqhNvKWcUkQQwSVKfoEjSlTTEplC63G4iaNgXIh7vvhJ9Rfyssfl7sEnTSJcMBzz+DGVLZHC8Cgcq2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c5V7GA/r; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c5V7GA/r" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5dc949f998fso1889232a12.3; Mon, 26 Feb 2024 01:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940333; x=1709545133; darn=vger.kernel.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=6vnjHCFtfaL9mXwWGPHpDHfEXciN5WUW1+wFbKGrPaI=; b=c5V7GA/r6UNl3YbOuMMKJ7TzcN9/Cy1mfJdYagk45BSywKsM2AmgBWLcXBCabAoBMV mVZNsNRZzujM62ftXkWFTtf9v83V5ft8RndQcUA/h9a3Ws4u6ArXZYhWbkvdYmc5hs8W 9hmbeOXFFzTBprXK24407lPU8cv18AsdcgawNwzSaraXkROvtYhM1Qp7bGeiuFhcL9AD 00/cJghattlvL/wrP2V9pfc0m4fChgDyNSUhzg9ep/jBQwz7rhVTi45y2nIezV7UzOcT vuXaBlI7Lb8edrEGqCgCMQUSxfuQMAQjXOoLhnP0OXeNDohcsrMzsI7dq3ncvpIHfAsU GqGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940333; x=1709545133; 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=6vnjHCFtfaL9mXwWGPHpDHfEXciN5WUW1+wFbKGrPaI=; b=h8zuJFSFIRUmhJv3kKDmzpdSvEaDACqCwBTMZIK7bS1UjovPTSYBuIhQuMZ5lCZ1fg KEoZ/UWUvDRiX6mEBuGxXDxhKe0AfoQgbngcRfR86oEtSULNfHKdZ2bn9ykHBaLmxMNz nc+lkRY5VlM2nIcd0YIYdrtYD/mdYd1rvaPzw5e2CZgMaErwyylakAVtrvQRdCcpmYqm yGs9U0vEbugcGfJmluTXhcuhxi99iXMMemdMaoIr5hzXBLvnZRFUvXUdAralEkkVrfvb 02oBqjGEK7tpiBVyGDB/DntzdMgjwSsYXdzv7aVhk7sDVd3ynys7X3fXraXc+b6N1d/c KoRg== X-Forwarded-Encrypted: i=1; AJvYcCUUUHklPi03E8RlIHxMMi8f7nLsqoxFFuFLYBLsvCIMFREygDN199WhtVpoIbojhJZYh3A+/t2Ql53wRfp3TBM9WwwyNVqZi48aIWxPJDKQYKJgu2l5t0d+3ZdqBng6qA== X-Gm-Message-State: AOJu0YxjEZO+avkAQq1u9T64WUjH3TS6B+zwrc2a4C6wSFLRDm52t5aq 4WXyAgCnlQvc9qLB7pSTZItyFIH6GWo030nx9DQsEWK9JiYoGlO5 X-Google-Smtp-Source: AGHT+IG2EnUxjMz0a/WUt7Yj1hLPi5khQWrO2IMM+XfUlR+14mHZyrTHTnCdcYQxIaN+sjSzMymj9g== X-Received: by 2002:a17:90a:9913:b0:29a:11b6:a333 with SMTP id b19-20020a17090a991300b0029a11b6a333mr4192571pjp.15.1708940333437; Mon, 26 Feb 2024 01:38:53 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:38:53 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 1/7] arch-run: Keep infifo open Date: Mon, 26 Feb 2024 19:38:26 +1000 Message-ID: <20240226093832.1468383-2-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The infifo fifo that is used to send characters to QEMU console is only able to receive one character before the cat process exits. Supporting interactions between test and harness involving multiple characters requires the fifo to remain open. This also allows us to let the cat out of the bag, simplifying the input pipeline. Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- scripts/arch-run.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 6daef3218..e5b36a07b 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -158,6 +158,11 @@ run_migration () mkfifo ${src_outfifo} mkfifo ${dst_outfifo} + # Holding both ends of the input fifo open prevents opens from + # blocking and readers getting EOF when a writer closes it. + mkfifo ${dst_infifo} + exec {dst_infifo_fd}<>${dst_infifo} + eval "$migcmdline" \ -chardev socket,id=mon,path=${src_qmp},server=on,wait=off \ -mon chardev=mon,mode=control > ${src_outfifo} & @@ -191,14 +196,10 @@ run_migration () do_migration () { - # We have to use cat to open the named FIFO, because named FIFO's, - # unlike pipes, will block on open() until the other end is also - # opened, and that totally breaks QEMU... - mkfifo ${dst_infifo} eval "$migcmdline" \ -chardev socket,id=mon,path=${dst_qmp},server=on,wait=off \ -mon chardev=mon,mode=control -incoming unix:${dst_incoming} \ - < <(cat ${dst_infifo}) > ${dst_outfifo} & + < ${dst_infifo} > ${dst_outfifo} & incoming_pid=$! cat ${dst_outfifo} | tee ${dst_out} | filter_quiet_msgs & @@ -245,7 +246,6 @@ do_migration () # keypress to dst so getchar completes and test continues echo > ${dst_infifo} - rm ${dst_infifo} # Ensure the incoming socket is removed, ready for next destination if [ -S ${dst_incoming} ] ; then From patchwork Mon Feb 26 09:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571716 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A32435D8F8; Mon, 26 Feb 2024 09:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940342; cv=none; b=A8fSxar9tZjyds3VVE+RuZIJo0RmfmLpFvoyMBB9/rIAut8NDZjqcCg6QQ4NRvWr2D2EuP1bv24EPTb3hW+OWwRbfh1y0947mwqibZSCSxk7JnBwtQfcxt8YcE+8E9KJO/qXKT+5meqQagQJA27AfAYc+qeG3L1baHnuXyVTEJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940342; c=relaxed/simple; bh=wsx7BsMuBLw39joSdYo5FDkv0qdEtnTE4Cwdt+maEYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wc6suXXAzosRl4SBHfiImehdojB0Kc2DSo4JX8EG1AqutH0I17jhxtReaZnkkJT3UQ4RbVsQxM6vf4y7d5ZJ2nAwyyIIvK9EZatxEQCUiEuU3pIuDEaMh+I4j1owmbo8a0FxFvuhQUVXL99MPeOD5kbbuQOicm/Bwml/+o67AsM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J0shKZjw; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J0shKZjw" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-299354e5f01so1592955a91.1; Mon, 26 Feb 2024 01:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940340; x=1709545140; darn=vger.kernel.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=ONMw/aUYjeV89BATWOApXz401ptx8GI2JoexNBRfWig=; b=J0shKZjwPzgJx+iZti4mhySmTLiAXU4tl7QdQk85xI8TyjkuxsXFW5Q0LNz86EBRjt muMMMfMD9JW69894b13Qzol9ewaWqJEWqHhDBxqh1hbFDCm8UPQHS+E51m842poPPGtL G6OH+QQOKwRbSHQ2lY8EcAktMcOUBRR+R4cdE+pFSLkoWqqgfG6/cOMhkT/nkgGlO8/v ddGehqOibNXWAkfiTeCxLmn7pN3guHs4isi/KJH8lpBcNY4YvydG4o5Apv6K18vH1q+I 9QQIEU7I5YSsmURny6a7zha8GEnvW0dIbCEvKzDLF80GvxwSsNzzIPwKdIEdDxTdqEuk EYtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940340; x=1709545140; 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=ONMw/aUYjeV89BATWOApXz401ptx8GI2JoexNBRfWig=; b=hVl+nR4Fx07mywKaaOf0SuC8GKcvIzoC/aBDUH5oZIj+8b8B06wlWzROpaMfes9NWQ /t/8W+Yg1VmBCZflpLQZ1eVjhUcQB106u3Hef3UKCfnDJKTOjJ+DQI7KAcw57yzAHaEq tcr4vvXA/ZLGB9TH0Z30cgIjWT4WaqH3j5IvqAwH0J6h5zxNetUU+AXY93cqipXPuAVV 5pqyB1s6z3FG2nh2KPUgLxZWYxarNvkgRB2P/EhUObFw/XhMlm8B3WohgDfKZfQX39jy DE63vH6xZzi+nXibo5bzG2Ek2QX22ZwVOg2Jrj7dVUCcnajHrbsJp0n9iaIjWtTiG5tb OQIw== X-Forwarded-Encrypted: i=1; AJvYcCUUtcc2N1l789m/enqFJLlVQBFWDZAmOWtIiYuBUbeD0K8ZFVjNeXwdyk2DEFvb22CgVkM3pZbP/81fhf2fGXdwDpjG+ydApcXY6G+WR1g+0QzWHQPRMh1xDspmMF3dPQ== X-Gm-Message-State: AOJu0YxYeKvm74LykesH2qRGjg25sgM9wWmE0MldEILMLNk72XQ5bLWA tAAiXUpCHNI9BU0fSox30u9c/dmn/BIe/FEXgm/mDpYd5YxIsnJaySX31K9x X-Google-Smtp-Source: AGHT+IG8Lyq/lSbfkngouOGrJUMUuWUk/DM4NGMBnzl8BD3XkX5WjjmPgixo8kXQDh0Qy0uQtYwdYg== X-Received: by 2002:a17:90b:f0a:b0:299:d975:89ea with SMTP id br10-20020a17090b0f0a00b00299d97589eamr8526892pjb.21.1708940339907; Mon, 26 Feb 2024 01:38:59 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:38:59 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 2/7] migration: Add a migrate_skip command Date: Mon, 26 Feb 2024 19:38:27 +1000 Message-ID: <20240226093832.1468383-3-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Tests that are run with MIGRATION=yes but skip due to some requirement not being met will show as a failure due to the harness requirement to see one successful migration. The workaround for this is to migrate in test's skip path. Add a new command that just tells the harness to not expect a migration. Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- common/selftest-migration.c | 14 ++++++++----- lib/migrate.c | 19 ++++++++++++++++- lib/migrate.h | 2 ++ powerpc/unittests.cfg | 6 ++++++ s390x/unittests.cfg | 5 +++++ scripts/arch-run.bash | 41 +++++++++++++++++++++++++++++-------- 6 files changed, 73 insertions(+), 14 deletions(-) diff --git a/common/selftest-migration.c b/common/selftest-migration.c index 54b5d6b2d..0afd8581c 100644 --- a/common/selftest-migration.c +++ b/common/selftest-migration.c @@ -14,14 +14,18 @@ int main(int argc, char **argv) { - int i = 0; - report_prefix_push("migration"); - for (i = 0; i < NR_MIGRATIONS; i++) - migrate_quiet(); + if (argc > 1 && !strcmp(argv[1], "skip")) { + migrate_skip(); + report(true, "migration skipping"); + } else { + int i; - report(true, "simple harness stress test"); + for (i = 0; i < NR_MIGRATIONS; i++) + migrate_quiet(); + report(true, "simple harness stress"); + } report_prefix_pop(); diff --git a/lib/migrate.c b/lib/migrate.c index 92d1d957d..1d22196b7 100644 --- a/lib/migrate.c +++ b/lib/migrate.c @@ -39,7 +39,24 @@ void migrate_once(void) if (migrated) return; - migrated = true; + migrate(); } + +/* + * When the test has been started in migration mode, but the test case is + * skipped and no migration point is reached, this can be used to tell the + * harness not to mark it as a failure to migrate. + */ +void migrate_skip(void) +{ + static bool did_migrate_skip; + + if (did_migrate_skip) + return; + did_migrate_skip = true; + + puts("Skipped VM migration (quiet)\n"); + (void)getchar(); +} diff --git a/lib/migrate.h b/lib/migrate.h index 95b9102b0..db6e0c501 100644 --- a/lib/migrate.h +++ b/lib/migrate.h @@ -9,3 +9,5 @@ void migrate(void); void migrate_quiet(void); void migrate_once(void); + +void migrate_skip(void); diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg index 7ce57de02..89abf2095 100644 --- a/powerpc/unittests.cfg +++ b/powerpc/unittests.cfg @@ -40,6 +40,12 @@ groups = selftest file = selftest-migration.elf groups = selftest migration +[selftest-migration-skip] +file = selftest-migration.elf +machine = pseries +groups = selftest migration +extra_params = -append "skip" + [spapr_hcall] file = spapr_hcall.elf diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index a7ad522ca..f613602d3 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -28,6 +28,11 @@ extra_params = -append 'test 123' file = selftest-migration.elf groups = selftest migration +[selftest-migration-skip] +file = selftest-migration.elf +groups = selftest migration +extra_params = -append "skip" + [intercept] file = intercept.elf diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index e5b36a07b..d0f6f098f 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -124,12 +124,17 @@ qmp_events () filter_quiet_msgs () { - grep -v "Now migrate the VM (quiet)" + grep -v "Now migrate the VM (quiet)" | + grep -v "Skipped VM migration (quiet)" } seen_migrate_msg () { - grep -q -e "Now migrate the VM" < $1 + if [ $skip_migration -eq 1 ]; then + grep -q -e "Now migrate the VM" < $1 + else + grep -q -e "Now migrate the VM" -e "Skipped VM migration" < $1 + fi } run_migration () @@ -142,7 +147,7 @@ run_migration () migcmdline=$@ trap 'trap - TERM ; kill 0 ; exit 2' INT TERM - trap 'rm -f ${src_out} ${dst_out} ${src_outfifo} ${dst_outfifo} ${dst_incoming} ${src_qmp} ${dst_qmp} ${dst_infifo}' RETURN EXIT + trap 'rm -f ${src_out} ${dst_out} ${src_outfifo} ${dst_outfifo} ${dst_incoming} ${src_qmp} ${dst_qmp} ${src_infifo} ${dst_infifo}' RETURN EXIT dst_incoming=$(mktemp -u -t mig-helper-socket-incoming.XXXXXXXXXX) src_out=$(mktemp -t mig-helper-stdout1.XXXXXXXXXX) @@ -151,21 +156,26 @@ run_migration () dst_outfifo=$(mktemp -u -t mig-helper-fifo-stdout2.XXXXXXXXXX) src_qmp=$(mktemp -u -t mig-helper-qmp1.XXXXXXXXXX) dst_qmp=$(mktemp -u -t mig-helper-qmp2.XXXXXXXXXX) - dst_infifo=$(mktemp -u -t mig-helper-fifo-stdin.XXXXXXXXXX) + src_infifo=$(mktemp -u -t mig-helper-fifo-stdin1.XXXXXXXXXX) + dst_infifo=$(mktemp -u -t mig-helper-fifo-stdin2.XXXXXXXXXX) src_qmpout=/dev/null dst_qmpout=/dev/null + skip_migration=0 mkfifo ${src_outfifo} mkfifo ${dst_outfifo} # Holding both ends of the input fifo open prevents opens from # blocking and readers getting EOF when a writer closes it. + mkfifo ${src_infifo} mkfifo ${dst_infifo} + exec {src_infifo_fd}<>${src_infifo} exec {dst_infifo_fd}<>${dst_infifo} eval "$migcmdline" \ -chardev socket,id=mon,path=${src_qmp},server=on,wait=off \ - -mon chardev=mon,mode=control > ${src_outfifo} & + -mon chardev=mon,mode=control \ + < ${src_infifo} > ${src_outfifo} & live_pid=$! cat ${src_outfifo} | tee ${src_out} | filter_quiet_msgs & @@ -179,8 +189,11 @@ run_migration () # Wait for test exit or further migration messages. if ! seen_migrate_msg ${src_out} ; then sleep 0.1 - else + elif grep -q "Now migrate the VM" < ${src_out} ; then do_migration || return $? + elif [ $skip_migration -eq 0 ] && grep -q "Skipped VM migration" < ${src_out} ; then + echo > ${src_infifo} # Resume src and carry on. + break; fi done @@ -207,10 +220,10 @@ do_migration () # "Now migrate VM" or similar console message. while ! seen_migrate_msg ${src_out} ; do if ! ps -p ${live_pid} > /dev/null ; then - echo "ERROR: Test exit before migration point." >&2 echo > ${dst_infifo} - qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null + echo "ERROR: Test exit before migration point." >&2 + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null return 3 fi sleep 0.1 @@ -220,6 +233,15 @@ do_migration () while ! [ -S ${dst_incoming} ] ; do sleep 0.1 ; done while ! [ -S ${dst_qmp} ] ; do sleep 0.1 ; done + if [ $skip_migration -eq 0 ] && grep -q "Skipped VM migration" < ${src_out} ; then + # May not get any migrations, exit to main loop for now... + echo > ${dst_infifo} + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null + echo > ${src_infifo} # Resume src and carry on. + skip_migration=1 + return 0 + fi + qmp ${src_qmp} '"migrate", "arguments": { "uri": "unix:'${dst_incoming}'" }' > ${src_qmpout} # Wait for the migration to complete @@ -263,6 +285,9 @@ do_migration () tmp=${src_out} src_out=${dst_out} dst_out=${tmp} + tmp=${src_infifo} + src_infifo=${dst_infifo} + dst_infifo=${tmp} tmp=${src_outfifo} src_outfifo=${dst_outfifo} dst_outfifo=${tmp} From patchwork Mon Feb 26 09:38:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571717 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76CA25D909; Mon, 26 Feb 2024 09:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940349; cv=none; b=j4Ugn5kils9IXhFm7aBh2+JZNF8sxznsg/89hZXAuM+L6BE16gJoKcuXNxEyyW1XSiVW+BHJjAbOth/tsqjWWPaOxjY9GZEzF/kwznTF/AWwqYN+H9cNr20Z+PlueMQEJITmzzF9ZBL04Qo/h+INDN3pFqvmiEjaL2tdg1w9h3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940349; c=relaxed/simple; bh=iA7DaoP+QuzBYk7Rfrwd+LjSvPic0A1ECWLT/5NJYi0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QiTsmsNc/1dVVlrxlz/7zLMMJU3o+psMKUUbJy+1PXpIgRihkiECkfwxHbXnZLLrjwLnxcdirTHLQM2NIMoANo0slcVWOOh24xp5k3asBEfzDuMEMS52XCS0mkBjegoN8Vq+j4NddTNKmHe/F82EQf7w3Mbm07ujyw0lHqq/wsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E+huvIjH; arc=none smtp.client-ip=209.85.215.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E+huvIjH" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso2784865a12.1; Mon, 26 Feb 2024 01:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940347; x=1709545147; darn=vger.kernel.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=uC/70SEJzTHOJH25vt3H9h8+D3sESjLNUn4k7CqK+9E=; b=E+huvIjHMVsobA8XDev+PADz32hMv07aiZj2mEGezUB573NQfh3S7meYIAIWLQFdqt 96b5+HLNUchvWCljMBsPL8Ln8uxqsmzuBOErRGSkGSbz3SFAZFGeRzbngsQ4Kj5BvF6z 2DqSPcuu21cb2OOuTnx8JdMKH7WI/OEO/uvNV04O1IDNu6lUGbMhJmcZXhCXmgVhr6a4 XnDg1FbVcbhirmAvbg27/d2KEYIaTK7+B5LZsCKsu0TDePdOQ36LKlr+LHQR4kEb+2s+ jTq8goaUzHjVtUl/6gXhDsKjL9+scHl3s/J1JbAXmfquhPG5w1X9lPaF1sO+d6GdzW6Z qRuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940347; x=1709545147; 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=uC/70SEJzTHOJH25vt3H9h8+D3sESjLNUn4k7CqK+9E=; b=eDuto3WkW2lkofUGy4NAjY2t9FCs2eeH2wMWkJhmNyJHPzT2aNfmZuJ8QfKSoYDd+o XsaXw5IvTDo7vE+UAGVNWf+NPJOnaVt+Qa5jE6Sxv/Wf1G79zJIo4XOBUwJRgDwOOXJy B6hhzOU1SdloJDpwEoIoMjr/Fuc3Qj+rkK1sb24c/xUGJortlj/Aq0tL4Wgik05TQH78 HfgDNx2d6XNalSGlMn2FDrsQDBOMY1/o25Qr8B0RrM70DN2Cn1iBL6X4zfI8B/55VGtO 0qO8dPLVrQyyDOPzkY1dlAijkTIk40kxR/BvypvYMKTpJhZsbbvLtz/UBQkk8tHPtscE PIiw== X-Forwarded-Encrypted: i=1; AJvYcCUCaVapJMBABFV1bN3eSB+2YbTQJ0eY2LaUDa1ZGUJQjbW1oTY5+3ir6oQk6ablaVryzxRXkQXwXuWu+4JccFnx+EeQvB3ebo+hAUU4997DUmHbQ9xcfYCvAwVOipZ4fg== X-Gm-Message-State: AOJu0YxcQQxkSShYzn6ctdM86fUf/j727OHSR25R0zWrPZX6aX2nrXkc kCmSAktVpCl0hzAyLVz5LbHFmrs+jHL+Z74xZCECUUHUwP1Hnj3L X-Google-Smtp-Source: AGHT+IGVHjLqOx0JzfzvBlojtHENa9XElZf47hWf9jVMVAK+crqgExNKzAI0S0P3U/MhCCZoNTPxcg== X-Received: by 2002:a17:90a:9bc5:b0:29a:be1a:ea40 with SMTP id b5-20020a17090a9bc500b0029abe1aea40mr1608384pjw.9.1708940346798; Mon, 26 Feb 2024 01:39:06 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:39:06 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 3/7] (arm|s390): Use migrate_skip in test cases Date: Mon, 26 Feb 2024 19:38:28 +1000 Message-ID: <20240226093832.1468383-4-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Have tests use the new migrate_skip command in skip paths, rather than calling migrate_once to prevent harness reporting an error. s390x/migration.c adds a new command that looks like it was missing previously. Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- arm/gic.c | 21 ++++++++++++--------- s390x/migration-cmm.c | 8 ++++---- s390x/migration-skey.c | 4 +++- s390x/migration.c | 1 + 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/arm/gic.c b/arm/gic.c index c950b0d15..bbf828f17 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -782,13 +782,15 @@ static void test_its_migration(void) struct its_device *dev2, *dev7; cpumask_t mask; - if (its_setup1()) + if (its_setup1()) { + migrate_skip(); return; + } dev2 = its_get_device(2); dev7 = its_get_device(7); - migrate_once(); + migrate(); stats_reset(); cpumask_clear(&mask); @@ -819,8 +821,10 @@ static void test_migrate_unmapped_collection(void) int pe0 = 0; u8 config; - if (its_setup1()) + if (its_setup1()) { + migrate_skip(); return; + } if (!errata(ERRATA_UNMAPPED_COLLECTIONS)) { report_skip("Skipping test, as this test hangs without the fix. " @@ -836,7 +840,7 @@ static void test_migrate_unmapped_collection(void) its_send_mapti(dev2, 8192, 0, col); gicv3_lpi_set_config(8192, LPI_PROP_DEFAULT); - migrate_once(); + migrate(); /* on the destination, map the collection */ its_send_mapc(col, true); @@ -875,8 +879,10 @@ static void test_its_pending_migration(void) void *ptr; int i; - if (its_prerequisites(4)) + if (its_prerequisites(4)) { + migrate_skip(); return; + } dev = its_create_device(2 /* dev id */, 8 /* nb_ites */); its_send_mapd(dev, true); @@ -923,7 +929,7 @@ static void test_its_pending_migration(void) gicv3_lpi_rdist_enable(pe0); gicv3_lpi_rdist_enable(pe1); - migrate_once(); + migrate(); /* let's wait for the 256 LPIs to be handled */ mdelay(1000); @@ -970,17 +976,14 @@ int main(int argc, char **argv) } else if (!strcmp(argv[1], "its-migration")) { report_prefix_push(argv[1]); test_its_migration(); - migrate_once(); report_prefix_pop(); } else if (!strcmp(argv[1], "its-pending-migration")) { report_prefix_push(argv[1]); test_its_pending_migration(); - migrate_once(); report_prefix_pop(); } else if (!strcmp(argv[1], "its-migrate-unmapped-collection")) { report_prefix_push(argv[1]); test_migrate_unmapped_collection(); - migrate_once(); report_prefix_pop(); } else if (strcmp(argv[1], "its-introspection") == 0) { report_prefix_push(argv[1]); diff --git a/s390x/migration-cmm.c b/s390x/migration-cmm.c index 43673f18e..b4043a80e 100644 --- a/s390x/migration-cmm.c +++ b/s390x/migration-cmm.c @@ -55,12 +55,12 @@ int main(void) { report_prefix_push("migration-cmm"); - if (!check_essa_available()) + if (!check_essa_available()) { report_skip("ESSA is not available"); - else + migrate_skip(); + } else { test_migration(); - - migrate_once(); + } report_prefix_pop(); return report_summary(); diff --git a/s390x/migration-skey.c b/s390x/migration-skey.c index 8d6d8ecfe..1a196ae1e 100644 --- a/s390x/migration-skey.c +++ b/s390x/migration-skey.c @@ -169,6 +169,7 @@ static void test_skey_migration_parallel(void) if (smp_query_num_cpus() == 1) { report_skip("need at least 2 cpus for this test"); + migrate_skip(); goto error; } @@ -233,6 +234,7 @@ int main(int argc, char **argv) if (test_facility(169)) { report_skip("storage key removal facility is active"); + migrate_skip(); goto error; } @@ -247,11 +249,11 @@ int main(int argc, char **argv) break; default: print_usage(); + migrate_skip(); break; } error: - migrate_once(); report_prefix_pop(); return report_summary(); } diff --git a/s390x/migration.c b/s390x/migration.c index 269e272de..115afb731 100644 --- a/s390x/migration.c +++ b/s390x/migration.c @@ -164,6 +164,7 @@ int main(void) if (smp_query_num_cpus() == 1) { report_skip("need at least 2 cpus for this test"); + migrate_skip(); goto done; } From patchwork Mon Feb 26 09:38:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571718 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 328C75D909; Mon, 26 Feb 2024 09:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940355; cv=none; b=eooeFa8SFaukxyZ26kjpaZCpMzWv9U/P++eig6p/27cE/2LhvzhoovpkfEAMAiaZWNVkwXnjglMphV217dUhljz/84xeUrN8RVTOzQf9dDMAfie8M2Jo2PbQxsWdSq3Esv0W3BpLBTWRXvQWgqK0bSgyPWOyX7OL/d5FE3C+juI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940355; c=relaxed/simple; bh=d2m4KiVJDyN7PsW2g2JBJpBikHcPI0nV2gmM4169iL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dHmky5e8qkOgpOJfuJrqBjh7PbRHpqKHtaa0IdkwOh7nP5bzQERt6cenfFJsWoKvHyqfiwX1iNH7U+8V3YsvSwHKzEPZzv/8sLiCezSRwo4y7GitZZfxZNaAGM/TNZHrQRbj0BrKMqW5ewBiq43NDPAAw0AdvdJAkeBpw3Nx6V0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aCwRTsUI; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aCwRTsUI" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3bd72353d9fso1911838b6e.3; Mon, 26 Feb 2024 01:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940353; x=1709545153; darn=vger.kernel.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=yFmFHP+QtAW/gWzWjKPE8XCHxHNjIB3oHgOxryrYW4g=; b=aCwRTsUIliA6bndK9+1jXsD66HhPrd6f+odRh+JnyC4OikWQB3Qj99xGP0XeLdY/ve n/ODLm1E1dxNMGvdqJN+iNYONKYHrOAY4kmjQu9wgjrwU/UhbVLNebhRnBBTYP1JhqLO M+Niismppq2MJBzqGpfzRT8apvdgRMjQfpq1M7RpvhuEBdQZ5WUYpkYuy2VZONvjSLYa ZmSn0PaNdLmgLQuZQZjbsM7ZOWHoeUZGX7ZjGQHzxqU4XIVA119NSAi/WPpyFaH4mz4U 24NJ5wRQkcxq0dzHBHBCmdo11vvRgAXOyYj3cWYYsavY2B5nGYglGwCeDr1i8RecW8J0 vhng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940353; x=1709545153; 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=yFmFHP+QtAW/gWzWjKPE8XCHxHNjIB3oHgOxryrYW4g=; b=s9LGcAAkG8KG+7UuXkleo8D3NocwVyuQ2U+lgh1ng5cya4gujtsvc3A3HJknqmZjzG LL/lforkYc/I5V3Jm3UBCNMV2PpI/t5BTdxpylDb7PK7Lh2NyyyEJu2Ee2+6JMVm8wqa 1T01jBFBLX/HYcXBSBqbh3CxSXz1o6pj71oyfL8NO72K2S7oie4dbjg/y0m11OUV1H/l 2pkxqCT+wThY5M92Os4fDrfFWFevB2DJmcSCMCZQZDqRQVyAPkLUclGZjyy805m8ccp0 YJU+qDmUnT07CgAE3oSI102PhalzkKgAKZFWRHpkJlEl+2rdXuOFwW/PxLgNBm3iuNZ4 BXqg== X-Forwarded-Encrypted: i=1; AJvYcCWG0HQkatLxBj4uVF7TYFDxBrCIEh0NpF10Z2WCK88SwmEPbqWW87LsrbLvjxMpOOHaLnyZZERU1KFoifE912UCOOwR70vOeuCXqFTebgkU7PUOQwjQM/pNdIbHEzKZxQ== X-Gm-Message-State: AOJu0YyCxu/MfXTAmVb5GxgzVHbA6JVDr6XS9oDtpaBXemssce0EF261 Mrl5Lr7YYHIQJhHKOriPtMqRpHsHtXiOlgkuLvEzgZr1Kor1n9Vc X-Google-Smtp-Source: AGHT+IEK7riyiXe4XBkSjXiTYaRk18fYrorXjR0yQSzy+Aw89puQe4obWJbTPsgNr5FUiDSgZ2fE9Q== X-Received: by 2002:a05:6358:3386:b0:17b:b573:a437 with SMTP id i6-20020a056358338600b0017bb573a437mr73248rwd.8.1708940353115; Mon, 26 Feb 2024 01:39:13 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:39:12 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 4/7] powerpc: add asm/time.h header with delay and get_clock_us/ms Date: Mon, 26 Feb 2024 19:38:29 +1000 Message-ID: <20240226093832.1468383-5-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This matches s390x clock and delay APIs, so common test code can start using time facilities. Signed-off-by: Nicholas Piggin Reviewed-by: Thomas Huth --- lib/powerpc/asm/processor.h | 21 --------------------- lib/powerpc/asm/time.h | 30 ++++++++++++++++++++++++++++++ lib/powerpc/processor.c | 11 +++++++++++ lib/powerpc/smp.c | 1 + lib/ppc64/asm/time.h | 1 + powerpc/spapr_vpa.c | 1 + powerpc/sprs.c | 1 + powerpc/tm.c | 1 + 8 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 lib/powerpc/asm/time.h create mode 100644 lib/ppc64/asm/time.h diff --git a/lib/powerpc/asm/processor.h b/lib/powerpc/asm/processor.h index 4ad6612b3..fe1052939 100644 --- a/lib/powerpc/asm/processor.h +++ b/lib/powerpc/asm/processor.h @@ -43,25 +43,4 @@ static inline void mtmsr(uint64_t msr) asm volatile ("mtmsrd %[msr]" :: [msr] "r" (msr) : "memory"); } -static inline uint64_t get_tb(void) -{ - return mfspr(SPR_TB); -} - -extern void delay(uint64_t cycles); -extern void udelay(uint64_t us); -extern void sleep_tb(uint64_t cycles); -extern void usleep(uint64_t us); - -static inline void mdelay(uint64_t ms) -{ - while (ms--) - udelay(1000); -} - -static inline void msleep(uint64_t ms) -{ - usleep(ms * 1000); -} - #endif /* _ASMPOWERPC_PROCESSOR_H_ */ diff --git a/lib/powerpc/asm/time.h b/lib/powerpc/asm/time.h new file mode 100644 index 000000000..72fcb1bd0 --- /dev/null +++ b/lib/powerpc/asm/time.h @@ -0,0 +1,30 @@ +#ifndef _ASMPOWERPC_TIME_H_ +#define _ASMPOWERPC_TIME_H_ + +#include +#include + +static inline uint64_t get_tb(void) +{ + return mfspr(SPR_TB); +} + +extern uint64_t get_clock_us(void); +extern uint64_t get_clock_ms(void); +extern void delay(uint64_t cycles); +extern void udelay(uint64_t us); +extern void sleep_tb(uint64_t cycles); +extern void usleep(uint64_t us); + +static inline void mdelay(uint64_t ms) +{ + while (ms--) + udelay(1000); +} + +static inline void msleep(uint64_t ms) +{ + usleep(ms * 1000); +} + +#endif /* _ASMPOWERPC_TIME_H_ */ diff --git a/lib/powerpc/processor.c b/lib/powerpc/processor.c index b224fc8eb..ad0d95666 100644 --- a/lib/powerpc/processor.c +++ b/lib/powerpc/processor.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -54,6 +55,16 @@ void do_handle_exception(struct pt_regs *regs) abort(); } +uint64_t get_clock_us(void) +{ + return get_tb() * 1000000 / tb_hz; +} + +uint64_t get_clock_ms(void) +{ + return get_tb() * 1000 / tb_hz; +} + void delay(uint64_t cycles) { uint64_t start = get_tb(); diff --git a/lib/powerpc/smp.c b/lib/powerpc/smp.c index afe436179..3e211eba8 100644 --- a/lib/powerpc/smp.c +++ b/lib/powerpc/smp.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/lib/ppc64/asm/time.h b/lib/ppc64/asm/time.h new file mode 100644 index 000000000..326d2887a --- /dev/null +++ b/lib/ppc64/asm/time.h @@ -0,0 +1 @@ +#include "../../powerpc/asm/time.h" diff --git a/powerpc/spapr_vpa.c b/powerpc/spapr_vpa.c index 6a3fe5e3f..c2075e157 100644 --- a/powerpc/spapr_vpa.c +++ b/powerpc/spapr_vpa.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/powerpc/sprs.c b/powerpc/sprs.c index 57e487ceb..285976488 100644 --- a/powerpc/sprs.c +++ b/powerpc/sprs.c @@ -26,6 +26,7 @@ #include #include #include +#include #include uint64_t before[1024], after[1024]; diff --git a/powerpc/tm.c b/powerpc/tm.c index 7fa916366..6b1ceeb6e 100644 --- a/powerpc/tm.c +++ b/powerpc/tm.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include From patchwork Mon Feb 26 09:38:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571719 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 189655DF0C; Mon, 26 Feb 2024 09:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940361; cv=none; b=GF6aZdWjATuYF68k/Y7NCAFcwy0FUD1CrrKTvbgi4UO/hN/mn8qj+6kAd/CbYsJrKBE0aSDYEIAGFT37kogMsvNP0aQv/XFEtizTt4GKAm061a/A4T6TiCAHXvhctUNivm7A6K7ssiBnUNGxPlv/451gyMN56z7NF5wVUdf/+Ls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940361; c=relaxed/simple; bh=aidDpGUNOhroDLY0H6jPOoGBVRns5KrAKiGzCb72D2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sTcbIuR+O3LaWVTAAUvohbT0KKrPklt0ITujtN17z7lQs+8YRakicvhuXz9SS5j/MHBM9bbw20FyqzInCz4R19rfJG+NCxWHHMGM1rX3si4caoPnZAGIBVGHfxo5YEgWEk0ooBvjVyy6X0P6q9svf97VTOaNiqX2YqVQxBTDINQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FBOPT8Wj; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FBOPT8Wj" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so1815764a12.3; Mon, 26 Feb 2024 01:39:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940359; x=1709545159; darn=vger.kernel.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=WfqFlNeWfcRgXj7UGW4upVJVIE+P49J1N2eRNhWx+y8=; b=FBOPT8WjavSY++IxWpZzRRngI+2mRW0pcgwtk495HIyQztrvbAliYDy2PA15KS2w21 +Y9C5lubod0XWE3KX99Cj9xODK7Z2qqxsoRPO1Mi5Lt4Oww2DvJnLv+BXjJjw3CxtWNm OXHJZp6g+PgTSBU1OVd1NXp3VPYbNxi0YXO8Yh+hBgHdONQTbeDyIUCWLx3dZYobub8t 0Z1w7dv3ZC5DeUbWBD01yUJSkH6/WVTXTRVM3bZa4rTwDLcMkdWItC9E2YM+bSzqdwoH 4lejlt7g/jhbHsl086yjhu3F+kIx94DQZnlWDEtlbD4FSOk+Dx+qW2xpe+kmrsvuHp8m kb3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940359; x=1709545159; 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=WfqFlNeWfcRgXj7UGW4upVJVIE+P49J1N2eRNhWx+y8=; b=r96t9Vx9IgPbxDiUkd0E5BOqFwKfb7s1K1PBJ6Ww4cKdHL/XnXRgDbqbsk5sdYmsD3 7VnbsrHnlQ3Jj7azLflh9jrMGZbGfw5WX6RsP4rULmONQ1IugzXCfW87J5Rt7kDWyGe1 eVIJNDHxYq+g7MvcCND8EJV2AaoB378iLIY363SeJVbOysW9MwxTrvn5/tjviqbq6NiR 4Q6WSD4ieFwnBNIHl0uqFJCpK164g9swsRqSuH/XfUG8SVazjsKUATf/OwCqFSzkDDhl ExzsQzh/GMIidUKGhN2DbNCApOjmQvCCV2a56uRagQjH13h/HaqTi6n9jnKwMzjWsz66 MbJA== X-Forwarded-Encrypted: i=1; AJvYcCXv/BZjo8J+Ll75R98R3JExmIoTt4uCkTpgcAkwopP2TmMLRTxFtrz6QQaPuRMFzW7NpnuML7xBEi3SrdlYfDJ5GBW58BO1jut4QYC0LYum4WtwTjBz8rEE8bjVS8burg== X-Gm-Message-State: AOJu0YxtJrraB3749jh7AAy+LIa8/tCEgOryePcMK04GkfOgDhp18O5a +LB4kDUm9bjFT4+P37oCwiraYP9XZWbxQ7dLwCM4oaeqpHcOoKB/ X-Google-Smtp-Source: AGHT+IHbh6SI8T6/s0c3UOyoHhOzc5xA5DNsPoVfksWo0VGv11hLE0/hAfkwS0iY70YPjKgUhGHHIw== X-Received: by 2002:a05:6a20:9694:b0:1a0:e09d:8ed1 with SMTP id hp20-20020a056a20969400b001a0e09d8ed1mr3838940pzc.53.1708940359344; Mon, 26 Feb 2024 01:39:19 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:39:19 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 5/7] arch-run: Add a "continuous" migration option for tests Date: Mon, 26 Feb 2024 19:38:30 +1000 Message-ID: <20240226093832.1468383-6-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The cooperative migration protocol is very good to control precise pre and post conditions for a migration event. However in some cases its intrusiveness to the test program, can mask problems and make analysis more difficult. For example to stress test migration vs concurrent complicated memory access, including TLB refill, ram dirtying, etc., then the tight spin at getchar() and resumption of the workload after migration is unhelpful. This adds a continuous migration mode that directs the harness to perform migrations continually. This is added to the migration selftests, which also sees cooperative migration iterations reduced to avoid increasing test time too much. Signed-off-by: Nicholas Piggin --- common/selftest-migration.c | 16 +++++++++-- lib/migrate.c | 18 ++++++++++++ lib/migrate.h | 3 ++ scripts/arch-run.bash | 55 ++++++++++++++++++++++++++++++++----- 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/common/selftest-migration.c b/common/selftest-migration.c index 0afd8581c..9a9b61835 100644 --- a/common/selftest-migration.c +++ b/common/selftest-migration.c @@ -9,12 +9,13 @@ */ #include #include +#include -#define NR_MIGRATIONS 30 +#define NR_MIGRATIONS 15 int main(int argc, char **argv) { - report_prefix_push("migration"); + report_prefix_push("migration harness"); if (argc > 1 && !strcmp(argv[1], "skip")) { migrate_skip(); @@ -24,7 +25,16 @@ int main(int argc, char **argv) for (i = 0; i < NR_MIGRATIONS; i++) migrate_quiet(); - report(true, "simple harness stress"); + report(true, "cooperative migration"); + + migrate_begin_continuous(); + mdelay(2000); + migrate_end_continuous(); + mdelay(1000); + migrate_begin_continuous(); + mdelay(2000); + migrate_end_continuous(); + report(true, "continuous migration"); } report_prefix_pop(); diff --git a/lib/migrate.c b/lib/migrate.c index 1d22196b7..770f76d5c 100644 --- a/lib/migrate.c +++ b/lib/migrate.c @@ -60,3 +60,21 @@ void migrate_skip(void) puts("Skipped VM migration (quiet)\n"); (void)getchar(); } + +void migrate_begin_continuous(void) +{ + puts("Begin continuous migration\n"); + (void)getchar(); +} + +void migrate_end_continuous(void) +{ + /* + * Migration can split this output between source and dest QEMU + * output files, print twice and match once to always cope with + * a split. + */ + puts("End continuous migration\n"); + puts("End continuous migration (quiet)\n"); + (void)getchar(); +} diff --git a/lib/migrate.h b/lib/migrate.h index db6e0c501..35b6703a2 100644 --- a/lib/migrate.h +++ b/lib/migrate.h @@ -11,3 +11,6 @@ void migrate_quiet(void); void migrate_once(void); void migrate_skip(void); + +void migrate_begin_continuous(void); +void migrate_end_continuous(void); diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index d0f6f098f..5c7e72036 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -125,15 +125,17 @@ qmp_events () filter_quiet_msgs () { grep -v "Now migrate the VM (quiet)" | + grep -v "Begin continuous migration (quiet)" | + grep -v "End continuous migration (quiet)" | grep -v "Skipped VM migration (quiet)" } seen_migrate_msg () { if [ $skip_migration -eq 1 ]; then - grep -q -e "Now migrate the VM" < $1 + grep -q -e "Now migrate the VM" -e "Begin continuous migration" < $1 else - grep -q -e "Now migrate the VM" -e "Skipped VM migration" < $1 + grep -q -e "Now migrate the VM" -e "Begin continuous migration" -e "Skipped VM migration" < $1 fi } @@ -161,6 +163,7 @@ run_migration () src_qmpout=/dev/null dst_qmpout=/dev/null skip_migration=0 + continuous_migration=0 mkfifo ${src_outfifo} mkfifo ${dst_outfifo} @@ -186,9 +189,12 @@ run_migration () do_migration || return $? while ps -p ${live_pid} > /dev/null ; do - # Wait for test exit or further migration messages. - if ! seen_migrate_msg ${src_out} ; then + if [[ ${continuous_migration} -eq 1 ]] ; then + do_migration || return $? + elif ! seen_migrate_msg ${src_out} ; then sleep 0.1 + elif grep -q "Begin continuous migration" < ${src_out} ; then + do_migration || return $? elif grep -q "Now migrate the VM" < ${src_out} ; then do_migration || return $? elif [ $skip_migration -eq 0 ] && grep -q "Skipped VM migration" < ${src_out} ; then @@ -218,7 +224,7 @@ do_migration () # The test must prompt the user to migrate, so wait for the # "Now migrate VM" or similar console message. - while ! seen_migrate_msg ${src_out} ; do + while [[ ${continuous_migration} -eq 0 ]] && ! seen_migrate_msg ${src_out} ; do if ! ps -p ${live_pid} > /dev/null ; then echo > ${dst_infifo} qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null @@ -229,12 +235,32 @@ do_migration () sleep 0.1 done + if grep -q "Begin continuous migration" < ${src_out} ; then + if [[ ${continuous_migration} -eq 1 ]] ; then + echo > ${dst_infifo} + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null + echo "ERROR: Continuous migration already begun." >&2 + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + return 3 + fi + continuous_migration=1 + echo > ${src_infifo} + fi + # Wait until the destination has created the incoming and qmp sockets while ! [ -S ${dst_incoming} ] ; do sleep 0.1 ; done while ! [ -S ${dst_qmp} ] ; do sleep 0.1 ; done if [ $skip_migration -eq 0 ] && grep -q "Skipped VM migration" < ${src_out} ; then # May not get any migrations, exit to main loop for now... + # No migrations today, shut down dst in an orderly manner... + if [[ ${continuous_migration} -eq 1 ]] ; then + echo > ${dst_infifo} + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null + echo "ERROR: Can't skip in continuous migration." >&2 + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + return 3 + fi echo > ${dst_infifo} qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null echo > ${src_infifo} # Resume src and carry on. @@ -266,8 +292,23 @@ do_migration () qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null - # keypress to dst so getchar completes and test continues - echo > ${dst_infifo} + # Should we end continuous migration? + if grep -q "End continuous migration" < ${src_out} ; then + if [[ ${continuous_migration} -eq 0 ]] ; then + echo "ERROR: Can't end continuous migration when not started." >&2 + echo > ${dst_infifo} + qmp ${dst_qmp} '"quit"'> ${dst_qmpout} 2>/dev/null + qmp ${src_qmp} '"quit"'> ${src_qmpout} 2>/dev/null + return 3 + fi + continuous_migration=0 + echo > ${src_infifo} + fi + + if [[ ${continuous_migration} -eq 0 ]]; then + # keypress to dst so getchar completes and test continues + echo > ${dst_infifo} + fi # Ensure the incoming socket is removed, ready for next destination if [ -S ${dst_incoming} ] ; then From patchwork Mon Feb 26 09:38:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571720 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 890895E22C; Mon, 26 Feb 2024 09:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940368; cv=none; b=ZyTbChhgzIQUNmePq7L5+2uaud5GNfUFOJ3M9furE+N0/O4m4ZaWsAFmT0IIGmIAwVRbNAtPANPYvdd+doa3ki4NQj8HRc/jfhRUOOl3Sv9k/osiG2iUG/sOjkU4GGvxWOSU3is4y1KUxI+HK9CluUuy9NvIGVInq92qlV9Wf9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940368; c=relaxed/simple; bh=ch0oCFU3DPtmmV3mWi2ZGJZNHNRxTVrZGJf3WMLapsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b5Rbvlr+XDcJiwC08c3qC1n0G/aZvqRnyzk9MvewPckO1lcsef41cCSEND4MXVnsW9b4X2bN5mpcsyKKf5WlSBlkbcqqBf735OsQPfQEdZOhVpmAG9iI/F5aaSYTxispN8SDpFGIQdUaN3tZPqFTT3IW5w/P0bHy6H5CQJv1sG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TR78LaH7; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TR78LaH7" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-299b92948a6so1818779a91.3; Mon, 26 Feb 2024 01:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940366; x=1709545166; darn=vger.kernel.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=Ir8XVGfbEwUzyyUuS20ld9G5VKQJor6iBkETXZzZgso=; b=TR78LaH7kh18dzCfx3Z6J81NKwhEqpG/w+FLbdQ7DQzEiGv58RZ53YBwF/qyOipXMV KkUGQQGwij1fGhIIk4uIEQW2CZFyiLaRXQVb1iYHWxT2hlrGhFiXnsMUapTNMGmbFiZr k05/Q3aH1/iIL+mFJIoLEPMFlRFwpayttVXW03/lqIsH+F51L4ipd5tuClFwuyEoSRFl XCgpwNEZWbyTwz6yfiQj0E2V4JOcPBPrHimq8uk/4loFT3XE/aU9cC1k132mKg2fcUd5 t1xUj9Irs4vCuPrv8cJOK02JhTXgB0YXGv4L8ditRDa7HZbtAOeZTSkgccx76fvO/n4l iuyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940366; x=1709545166; 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=Ir8XVGfbEwUzyyUuS20ld9G5VKQJor6iBkETXZzZgso=; b=urnoODCe8H8jPjFgr72x4lm9cfRpQSX4kfI4vsmy80L9hmp1noaCZMOUInS0PxvXnb 4MvRHzsxllTiczwTTd145W0ufimzox0yQ4qO7Kmd5ygbO57FDf/voglUmHPASXpcMnUY uVL0qAJv/R9Y52NxQyk3orJX2paYruerXc15mT4dQN1pGnfh37VZXVJ3cMUk0KBWP6A7 KAN2YQHQpY4m1VO1T6yuosXeL47+46pWAEdlz6w5cDg1yDED1m/K78XpR45YGSJUisMI E0oH9NZDBzUUY2+g4O1Dh7Kxl+NeJkmGliaHLqPcfHhwoDCtUwJvfdsPRPiiXFzzu1yC ZN0Q== X-Forwarded-Encrypted: i=1; AJvYcCVf7zCnV/0EF9u4PYvi3vnYohTscZLNBiuNNxrIggeDyCpG1ORIS6Pg/Ro+sLY9/TpCjqH8qZmz0Q7m7R4DpFW1a3dEEopu656HbmISFCUpkzqhF+TrLcmMy1Di+73uLA== X-Gm-Message-State: AOJu0Yy9KNwErHzZUt8zhoYma/jiwcycLINxtk0ZPawr86kE262QXjRp pI0JlDX7iqqgH9GjNHuASePKJBgu6ypNRICw6cJjvZGerS6ataRaLkf2iT2Y X-Google-Smtp-Source: AGHT+IGmvHjEHV9FtxS/iLLwhsoB6LA76JI/2S+B5fHnmu7Hgj2BYmypa1uOlQi8la9CdsvyNQ+YiA== X-Received: by 2002:a17:90a:1117:b0:299:14c9:94f0 with SMTP id d23-20020a17090a111700b0029914c994f0mr4250349pja.11.1708940365783; Mon, 26 Feb 2024 01:39:25 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:39:25 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 6/7] gitlab-ci: Run migration selftest on s390x and powerpc Date: Mon, 26 Feb 2024 19:38:31 +1000 Message-ID: <20240226093832.1468383-7-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The migration harness is complicated and easy to break so CI will be helpful. Signed-off-by: Nicholas Piggin --- .gitlab-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71d986e98..61f196d5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,26 +64,28 @@ build-arm: build-ppc64be: extends: .outoftree_template script: - - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu + - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat - mkdir build - cd build - ../configure --arch=ppc64 --endian=big --cross-prefix=powerpc64-linux-gnu- - make -j2 - ACCEL=tcg ./run_tests.sh - selftest-setup spapr_hcall rtas-get-time-of-day rtas-get-time-of-day-base - rtas-set-time-of-day emulator + selftest-setup selftest-migration selftest-migration-skip spapr_hcall + rtas-get-time-of-day rtas-get-time-of-day-base rtas-set-time-of-day + emulator | tee results.txt - if grep -q FAIL results.txt ; then exit 1 ; fi build-ppc64le: extends: .intree_template script: - - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu + - dnf install -y qemu-system-ppc gcc-powerpc64-linux-gnu nmap-ncat - ./configure --arch=ppc64 --endian=little --cross-prefix=powerpc64-linux-gnu- - make -j2 - ACCEL=tcg ./run_tests.sh - selftest-setup spapr_hcall rtas-get-time-of-day rtas-get-time-of-day-base - rtas-set-time-of-day emulator + selftest-setup selftest-migration selftest-migration-skip spapr_hcall + rtas-get-time-of-day rtas-get-time-of-day-base rtas-set-time-of-day + emulator | tee results.txt - if grep -q FAIL results.txt ; then exit 1 ; fi @@ -107,7 +109,7 @@ build-riscv64: build-s390x: extends: .outoftree_template script: - - dnf install -y qemu-system-s390x gcc-s390x-linux-gnu + - dnf install -y qemu-system-s390x gcc-s390x-linux-gnu nmap-ncat - mkdir build - cd build - ../configure --arch=s390x --cross-prefix=s390x-linux-gnu- @@ -133,6 +135,8 @@ build-s390x: sclp-1g sclp-3g selftest-setup + selftest-migration + selftest-migration-skip sieve smp stsi From patchwork Mon Feb 26 09:38:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13571721 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B38EF5EE8D; Mon, 26 Feb 2024 09:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940374; cv=none; b=izFTKr9GPY7nCVjphtmZE2S9YY9Sspg3Cv5epSIUvh83LAV9RNnQDW2yrkFBsQTCrL5F6XVfqv3g4/oTZtHvwCqOQMC6OInvZ0XX0N2Kc2Yj8NhHt9RhqN3b7xAqrRyBIFUv7pgcgpIB3+F5sXooDn26GeiDKj/CoXOPLvcobUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940374; c=relaxed/simple; bh=6xXLshEGv1+dS4Oj7TAl6ErQq+s8Er+4C8JK210EwGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TI9/wWrqMFJ27wQcW1Lx/bWVL0r1miwz9LCnJE0rn4bmKOzRbyRBWoGF76ZUXagB+MfUCikJjsaYvb8pqgdnxJuaA62poYLE0UKQ5A3L/r7Lk8R2rAg9/JDjHXLEc98s3VvV3P6bODf1mZqA9NOfLRffXuoXxFRrjTDW4UGcCiw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J/7XguAy; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J/7XguAy" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-29a430c3057so1251399a91.1; Mon, 26 Feb 2024 01:39:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708940372; x=1709545172; darn=vger.kernel.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=4C3sdt0JsWbryl8xk4OG1WbSXlpSqNkR+NKIJMu9X/I=; b=J/7XguAycQkkAx7Q+ZResC0A7e/Wkwe51PvjpEXbPK/YuTIXrGDOUlkEYjjsmz3jce tChYhoN0RCphjGL/rKGwY2dWf7gjsrJuvzwIVnEgiw2gWrDo10Lscm8UkGddnkPJUYuz DbcxFlzbu3cbwAVmZ/SrztffYKqdpr9v4jaEbRcLLMkRBzAO7mNz1PzE729i0fKVLoh2 RboLii5YVy9rG3+z4kjh7yyFaWXnSgz2mQezWO9wMq9MfkF5zhtyIsTFUGRWj3MLHOcV I/o1guiEr+ZfMGIXAfuZqT+sF6BZaXkrI/e6lqqntBKtUb97SeYgaQzl9emgClXIxw3m A84A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708940372; x=1709545172; 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=4C3sdt0JsWbryl8xk4OG1WbSXlpSqNkR+NKIJMu9X/I=; b=cz0R3TwIFxaLfu3+ik2ZlK52vA++TpTbw4c9+USc+bj38kuwmGbA9vUM42ol5iUiLp 1KI6dlJszj1fRsE5FaUbixW2w5WVm4uE9pCLaVzN2eWCsiHop9ogNttkhlUqgVZBfC0T 6ulnCEPxR8GOA6yfQCd+MiLhEkSRNn5y92/QqyWzJhOuFpoGRbRgQp6qNKWFvLNo3g7G sHbvMyiWcy9KtwtGogSSGtpJVjlELRzR1K7d040btEXkYfm4y0z8dCrHXRajnTKQ3Fdq HU9CYEleFBfhpV7LHFoYvfgoCLGLXPef06KBkp7dylS0BiRkbpLa+wgXc/CkM4yYBYsa r7hQ== X-Forwarded-Encrypted: i=1; AJvYcCWQJklkgp8jqoIRVkTZgVIB34Coxo/sNISyN5GPkzGRa2I7B5O0u/ubd1rzJ0RJBcekAVZGM7WwUD3WzYAbMaT/StYHySMTOvTqrVXYMW4fNsSMuedgJdcgFRK/+VfvLw== X-Gm-Message-State: AOJu0YyMgDX9xFD6R0ZYHPMdaPk3XAuV6hz4V4Kbjpqo118Lk2vIUQc8 93d3MDhxhE7U85fyKWmgB7287XBHOGheLDXiyYCR5vwEbt/WPy9CQIbl90CG X-Google-Smtp-Source: AGHT+IFXLyYXdyP2UAckhzh+BDfRTP5s86iCzOS+vBsDRJEkc8Q8vEMkpMw7UMDXxznIh8HlHNlNaA== X-Received: by 2002:a17:90a:db03:b0:29a:59a7:951d with SMTP id g3-20020a17090adb0300b0029a59a7951dmr3903944pjv.5.1708940372072; Mon, 26 Feb 2024 01:39:32 -0800 (PST) Received: from wheely.local0.net (220-235-194-103.tpgi.com.au. [220.235.194.103]) by smtp.gmail.com with ESMTPSA id pa3-20020a17090b264300b0029929ec25fesm6036782pjb.27.2024.02.26.01.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:39:31 -0800 (PST) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , kvm@vger.kernel.org, Laurent Vivier , "Shaoqin Huang" , Andrew Jones , Nico Boehr , Paolo Bonzini , Alexandru Elisei , Eric Auger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Marc Hartmayer , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: [kvm-unit-tests PATCH 7/7] common: add memory dirtying vs migration test Date: Mon, 26 Feb 2024 19:38:32 +1000 Message-ID: <20240226093832.1468383-8-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240226093832.1468383-1-npiggin@gmail.com> References: <20240226093832.1468383-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This test stores to a bunch of pages and verifies previous stores, while being continually migrated. This can fail due to a QEMU TCG physical memory dirty bitmap bug. Signed-off-by: Nicholas Piggin --- common/memory-verify.c | 48 +++++++++++++++++++++++++++++++++++++++++ powerpc/Makefile.common | 1 + powerpc/memory-verify.c | 1 + powerpc/unittests.cfg | 7 ++++++ s390x/Makefile | 1 + s390x/memory-verify.c | 1 + s390x/unittests.cfg | 6 ++++++ 7 files changed, 65 insertions(+) create mode 100644 common/memory-verify.c create mode 120000 powerpc/memory-verify.c create mode 120000 s390x/memory-verify.c diff --git a/common/memory-verify.c b/common/memory-verify.c new file mode 100644 index 000000000..7c4ec087b --- /dev/null +++ b/common/memory-verify.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Simple memory verification test, used to exercise dirty memory migration. + * + */ +#include +#include +#include +#include +#include + +#define NR_PAGES 32 + +int main(int argc, char **argv) +{ + void *mem = malloc(NR_PAGES*PAGE_SIZE); + bool success = true; + uint64_t ms; + long i; + + report_prefix_push("memory"); + + memset(mem, 0, NR_PAGES*PAGE_SIZE); + + migrate_begin_continuous(); + ms = get_clock_ms(); + i = 0; + do { + int j; + + for (j = 0; j < NR_PAGES*PAGE_SIZE; j += PAGE_SIZE) { + if (*(volatile long *)(mem + j) != i) { + success = false; + goto out; + } + *(volatile long *)(mem + j) = i + 1; + } + i++; + } while (get_clock_ms() - ms < 5000); +out: + migrate_end_continuous(); + + report(success, "memory verification stress test"); + + report_prefix_pop(); + + return report_summary(); +} diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index da4a7bbb8..1e181da69 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -7,6 +7,7 @@ tests-common = \ $(TEST_DIR)/selftest.elf \ $(TEST_DIR)/selftest-migration.elf \ + $(TEST_DIR)/memory-verify.elf \ $(TEST_DIR)/spapr_hcall.elf \ $(TEST_DIR)/rtas.elf \ $(TEST_DIR)/emulator.elf \ diff --git a/powerpc/memory-verify.c b/powerpc/memory-verify.c new file mode 120000 index 000000000..5985c730f --- /dev/null +++ b/powerpc/memory-verify.c @@ -0,0 +1 @@ +../common/memory-verify.c \ No newline at end of file diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg index 89abf2095..fadd8dde6 100644 --- a/powerpc/unittests.cfg +++ b/powerpc/unittests.cfg @@ -46,6 +46,13 @@ machine = pseries groups = selftest migration extra_params = -append "skip" +# This fails due to a QEMU TCG bug so KVM-only until QEMU is fixed upstream +[migration-memory] +file = memory-verify.elf +accel = kvm +machine = pseries +groups = migration + [spapr_hcall] file = spapr_hcall.elf diff --git a/s390x/Makefile b/s390x/Makefile index 344d46d68..ddc0969f3 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -1,5 +1,6 @@ tests = $(TEST_DIR)/selftest.elf tests += $(TEST_DIR)/selftest-migration.elf +tests += $(TEST_DIR)/memory-verify.elf tests += $(TEST_DIR)/intercept.elf tests += $(TEST_DIR)/emulator.elf tests += $(TEST_DIR)/sieve.elf diff --git a/s390x/memory-verify.c b/s390x/memory-verify.c new file mode 120000 index 000000000..5985c730f --- /dev/null +++ b/s390x/memory-verify.c @@ -0,0 +1 @@ +../common/memory-verify.c \ No newline at end of file diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index f613602d3..a88fe9e79 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -33,6 +33,12 @@ file = selftest-migration.elf groups = selftest migration extra_params = -append "skip" +# This fails due to a QEMU TCG bug so KVM-only until QEMU is fixed upstream +[migration-memory] +file = memory-verify.elf +accel = kvm +groups = migration + [intercept] file = intercept.elf