more migration enhancements and tests
Subsystems (3)
cover more migration enhancements and tests
This series applies on top of the multi-migration patches and just has assorted things I've been collecting.
- New migrate_skip() command that tidies up the wart of using migrate_once() to skip migration.
- New "continuous migration" mode where the harness just migrates the test contually while it is running.
- Put some migration tests in gitlab CI for powerpc and s390.
- Add a test case that can reproduce the QEMU TCG dirty bitmap migration bug.
Nicholas Piggin (7):
arch-run: Keep infifo open
migration: Add a migrate_skip command
(arm|s390): Use migrate_skip in test cases
powerpc: add asm/time.h header with delay and get_clock_us/ms
arch-run: Add a "continuous" migration option for tests
gitlab-ci: Run migration selftest on s390x and powerpc
common: add memory dirtying vs migration test
.gitlab-ci.yml | 18 ++++--- arm/gic.c | 21 ++++---- common/memory-verify.c | 48 +++++++++++++++++ common/selftest-migration.c | 26 ++++++--- lib/migrate.c | 37 ++++++++++++- lib/migrate.h | 5 ++ 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/Makefile.common | 1 + powerpc/memory-verify.c | 1 + powerpc/spapr_vpa.c | 1 + powerpc/sprs.c | 1 + powerpc/tm.c | 1 + powerpc/unittests.cfg | 13 +++++ s390x/Makefile | 1 + s390x/memory-verify.c | 1 + s390x/migration-cmm.c | 8 +-- s390x/migration-skey.c | 4 +- s390x/migration.c | 1 + s390x/unittests.cfg | 11 ++++ scripts/arch-run.bash | 104 +++++++++++++++++++++++++++++------- 24 files changed, 299 insertions(+), 68 deletions(-) create mode 100644 common/memory-verify.c create mode 100644 lib/powerpc/asm/time.h create mode 100644 lib/ppc64/asm/time.h create mode 120000 powerpc/memory-verify.c create mode 120000 s390x/memory-verify.c
Signature · 1 line
2.42.0
PATCH 1/7 arch-run: Keep infifo open
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.
--- scripts/arch-run.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/arch-run.bash +6 -6
@@ -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
Signature · 1 line
2.42.0
PATCH 2/7 migration: Add a migrate_skip command
In reply to Nicholas PigginTests 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.
--- 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(-)
common/selftest-migration.c +9 -5
@@ -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 ();
lib/migrate.c +18 -1
@@ -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 (); +}
lib/migrate.h +2 -0
@@ -9,3 +9,5 @@void migrate (void );void migrate_quiet (void );void migrate_once (void ); + +void migrate_skip (void );
powerpc/unittests.cfg +6 -0
@@ -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
s390x/unittests.cfg +5 -0
@@ -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
scripts/arch-run.bash +33 -8
103 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH 3/7 (arm|s390): Use migrate_skip in test cases
In reply to Nicholas PigginHave 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.
--- 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(-)
arm/gic.c +12 -9
@@ -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 ]);
s390x/migration-cmm.c +4 -4
@@ -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 ();
s390x/migration-skey.c +3 -1
@@ -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 (); }
s390x/migration.c +1 -0
@@ -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; }
Signature · 1 line
2.42.0
PATCH 4/7 powerpc: add asm/time.h header with delay and get_clock_us/ms
In reply to Nicholas PigginThis matches s390x clock and delay APIs, so common test code can start using time facilities.
--- 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
lib/powerpc/asm/processor.h +0 -21
@@ -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_ */
lib/powerpc/asm/time.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef _ASMPOWERPC_TIME_H_ +#define _ASMPOWERPC_TIME_H_ + +#include <libcflat.h> +#include <asm/processor.h> + +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_ */
lib/powerpc/processor.c +11 -0
@@ -7,6 +7,7 @@#include <libcflat.h> #include <asm/processor.h> +#include <asm/time.h> #include <asm/ptrace.h> #include <asm/setup.h> #include <asm/barrier.h>
@@ -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 ();
lib/powerpc/smp.c +1 -0
@@ -7,6 +7,7 @@*/ #include <devicetree.h> +#include <asm/time.h> #include <asm/setup.h> #include <asm/rtas.h> #include <asm/smp.h>
lib/ppc64/asm/time.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../powerpc/asm/time.h"
powerpc/spapr_vpa.c +1 -0
@@ -10,6 +10,7 @@#include <util.h> #include <alloc.h> #include <asm/processor.h> +#include <asm/time.h> #include <asm/setup.h> #include <asm/hcall.h> #include <asm/vpa.h>
powerpc/sprs.c +1 -0
@@ -26,6 +26,7 @@#include <asm/handlers.h> #include <asm/hcall.h> #include <asm/processor.h> +#include <asm/time.h> #include <asm/barrier.h> uint64_t before[1024 ], after[1024 ];
powerpc/tm.c +1 -0
@@ -8,6 +8,7 @@#include <libcflat.h> #include <asm/hcall.h> #include <asm/processor.h> +#include <asm/time.h> #include <asm/handlers.h> #include <asm/smp.h> #include <asm/setup.h>
Signature · 1 line
2.42.0
PATCH 5/7 arch-run: Add a "continuous" migration option for tests
In reply to Nicholas PigginThe 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.
--- 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(-)
common/selftest-migration.c +13 -3
@@ -9,12 +9,13 @@*/ #include <libcflat.h> #include <migrate.h> +#include <asm/time.h> -#define NR_MIGRATIONS 30 +#define NR_MIGRATIONS 15int 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 ();
lib/migrate.c +18 -0
@@ -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 (); +}
lib/migrate.h +3 -0
@@ -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 );
scripts/arch-run.bash +48 -7
105 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH 6/7 gitlab-ci: Run migration selftest on s390x and powerpc
In reply to Nicholas PigginThe migration harness is complicated and easy to break so CI will be helpful.
--- .gitlab-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
.gitlab-ci.yml +11 -7
@@ -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
Signature · 1 line
2.42.0
PATCH 7/7 common: add memory dirtying vs migration test
In reply to Nicholas PigginThis 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.
--- 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
common/memory-verify.c new file +48 -0
@@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Simple memory verification test, used to exercise dirty memory migration. +* +*/ +#include <libcflat.h> +#include <migrate.h> +#include <alloc.h> +#include <asm/page.h> +#include <asm/time.h> + +#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 (); +}
powerpc/Makefile.common +1 -0
@@ -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 \
powerpc/memory-verify.c new file +1 -0
@@ -0,0 +1 @@ +../common/memory-verify.c
powerpc/unittests.cfg +7 -0
@@ -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
s390x/Makefile +1 -0
@@ -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
s390x/memory-verify.c new file +1 -0
@@ -0,0 +1 @@ +../common/memory-verify.c
s390x/unittests.cfg +6 -0
@@ -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
Signature · 1 line
2.42.0
Re: [kvm-unit-tests PATCH 1/7] arch-run: Keep infifo open
In reply to Nicholas PigginQuoted 7 lines · Nicholas Piggin
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.
LOL, we rather let the cat out of the subshell now, but I like the play on words :-)
Quoted 38 lines
Signed-off-by Nicholas Piggin <[email protected]>--- scripts/arch-run.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)scripts/arch-run.bash +6
-5@@ -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 &
scripts/arch-run.bash do_migration () · line 248
Quoted 4 lines
scripts/arch-run.bash +0
-1@@ -245,7 +246,6 @@ do_migration () # keypress to dst so getchar completes and test continues echo > ${dst_infifo} - rm ${dst_infifo}
I assume it will not get deleted by the trap handler? ... sounds fine to me, so I dare to say:
Re: [kvm-unit-tests PATCH 3/7] (arm|s390): Use migrate_skip in test cases
In reply to Nicholas PigginQuoted 6 lines · Nicholas Piggin
Have tests use the new
migrate_skipcommand in skip paths, rather than callingmigrate_onceto prevent harness reporting an error.
s390x/migration.cadds a new command that looks like it was missing previously.
Quoted 7 lines
Signed-off-by Nicholas Piggin <[email protected]>--- 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(-)
Re: [kvm-unit-tests PATCH 4/7] powerpc: add asm/time.h header with delay and get_clock_us/ms
In reply to Nicholas PigginQuoted 14 lines · Nicholas Piggin
This matches s390x clock and delay APIs, so common test code can start using time facilities.
Signed-off-by Nicholas Piggin <[email protected]>--- 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(-)
Quoted 2 lines
create mode 100644
lib/powerpc/asm/time.h
create mode 100644lib/ppc64/asm/time.h
Re: [kvm-unit-tests PATCH 6/7] gitlab-ci: Run migration selftest on s390x and powerpc
In reply to Nicholas PigginQuoted 57 lines · Nicholas Piggin
The migration harness is complicated and easy to break so CI will be helpful.
Signed-off-by Nicholas Piggin <[email protected]>--- .gitlab-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-).gitlab-ci.yml +9
-7@@ -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-
.gitlab-ci.yml build-s390x: · line 142
Quoted 8 lines
.gitlab-ci.yml +2
-0@@ -133,6 +135,8 @@ build-s390x: sclp-1g sclp-3g selftest-setup + selftest-migration + selftest-migration-skip sieve smp stsi
While I can update the qemu binary for the s390x-kvm job, the build-* jobs run in a container with a normal QEMU from the corresponding distros, so I think this has to wait 'til we get distros that contain your QEMU TCG migration fix.
Thomas
Re: [kvm-unit-tests PATCH 2/7] migration: Add a migrate_skip command
In reply to Nicholas PigginQuoted 7 lines · Nicholas Piggin
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 <[email protected]>
Quoted 8 lines
--- 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(-)
Re: [kvm-unit-tests PATCH 5/7] arch-run: Add a "continuous" migration option for tests
In reply to Nicholas PigginQuoted 131 lines · Nicholas Piggin
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 <[email protected]>--- 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(-)common/selftest-migration.c +13
-3@@ -9,12 +9,13 @@*/ #include <libcflat.h> #include <migrate.h> +#include <asm/time.h> -#define NR_MIGRATIONS 30 +#define NR_MIGRATIONS 15int 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 ();lib/migrate.c +18
-0@@ -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 (); +}lib/migrate.h +3
-0@@ -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 );scripts/arch-run.bash +5
-2@@ -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}
scripts/arch-run.bash run_migration () · line 192
Quoted 6 lines
scripts/arch-run.bash +1
-2@@ -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
Here you're using "[[" for testing ...
scripts/arch-run.bash run_migration () · line 200
Quoted 8 lines
scripts/arch-run.bash +4
-0+ 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
... while the other code seems to use "[" for testing values. Can we try to stick to one style, please (unless it's really required to use "[[" somewhere)?
Thanks,
Thomas
Re: [kvm-unit-tests PATCH 7/7] common: add memory dirtying vs migration test
In reply to Nicholas PigginQuoted 3 lines · Nicholas Piggin
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.
Good idea, but could we then please drop "continuous" test from selftest-migration.c again? ... having two common tests to exercise the continuous migration that take quite a bunch of seconds to finish sounds like a waste of time in the long run to me.
Quoted 49 lines
Signed-off-by Nicholas Piggin <[email protected]>--- 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 120000powerpc/memory-verify.c
create mode 120000s390x/memory-verify.ccommon/memory-verify.c new file +29
-0@@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Simple memory verification test, used to exercise dirty memory migration. +* +*/ +#include <libcflat.h> +#include <migrate.h> +#include <alloc.h> +#include <asm/page.h> +#include <asm/time.h> + +#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;
common/memory-verify.c line 39
Quoted 10 lines
common/memory-verify.c new file +10
-0+ +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 );
Maybe add a parameter so that the user can use different values for the runtime than always doing 5 seconds?
Thomas
Quoted 9 lines
common/memory-verify.c new file +9
-0+out: +migrate_end_continuous (); + +report (success,"memory verification stress test" ); + +report_prefix_pop (); + +return report_summary (); +}
Re: [kvm-unit-tests PATCH 5/7] arch-run: Add a "continuous" migration option for tests
In reply to Thomas HuthQuoted 131 lines · Thomas Huth
Quoted 122 lines · Nicholas Piggin
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 <[email protected]>--- 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(-)common/selftest-migration.c +13
-3@@ -9,12 +9,13 @@*/ #include <libcflat.h> #include <migrate.h> +#include <asm/time.h> -#define NR_MIGRATIONS 30 +#define NR_MIGRATIONS 15int 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 ();lib/migrate.c +18
-0@@ -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 (); +}lib/migrate.h +3
-0@@ -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 );scripts/arch-run.bash +5
-2@@ -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}scripts/arch-run.bash run_migration () · line 191
Quoted 5 lines
scripts/arch-run.bash +1
-2@@ -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 ]] ; thenHere you're using "[[" for testing ...
Quoted 13 lines
scripts/arch-run.bash run_migration () · line 200
Quoted 8 lines
scripts/arch-run.bash +4
-0+ 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... while the other code seems to use "[" for testing values. Can we try to stick to one style, please (unless it's really required to use "[[" somewhere)?
We should decide on a Bash coding style and on preferences like [[ and then write a document for it, as well as create a set of shellcheck includes/excludes to test it. Then, using shellcheck we'd change all our current Bash code and also require shellcheck to pass on all new code before merge. Any volunteers for that effort? For the style selection we can take inspiration from other projects or even just adopt their style guides. Google has some guidance[1][2] and googling for Bash style pops up other hits.
[1] https://google.github.io/styleguide/shellguide.html
[2] https://chromium.googlesource.com/chromiumos/docs/+/master/styleguide/shell.md
Thanks,
drew
Re: [kvm-unit-tests PATCH 1/7] arch-run: Keep infifo open
In reply to Thomas HuthQuoted 11 lines · Thomas Huth
Quoted 7 lines · Nicholas Piggin
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.
LOL, we rather let the cat out of the subshell now, but I like the play on words :-)
It was a bit of a stretch, but I'm glad you liked it :) I may incorporate your suggestion to improve it.
Quoted 38 lines
Quoted 38 lines
Signed-off-by Nicholas Piggin <[email protected]>--- scripts/arch-run.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)scripts/arch-run.bash +6
-5@@ -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 &
Quoted 8 lines
scripts/arch-run.bash do_migration () · line 248
Quoted 5 lines
scripts/arch-run.bash +0
-1@@ -245,7 +246,6 @@ do_migration () # keypress to dst so getchar completes and test continues echo > ${dst_infifo} - rm ${dst_infifo}I assume it will not get deleted by the trap handler? ... sounds fine to me, so I dare to say:
Yep, deleted by trap handler.
Quoted 2 lines
Reviewed-by Thomas Huth <[email protected]>
Thanks,
Nick
Re: [kvm-unit-tests PATCH 6/7] gitlab-ci: Run migration selftest on s390x and powerpc
In reply to Thomas HuthQuoted 63 lines · Thomas Huth
Quoted 62 lines · Nicholas Piggin
The migration harness is complicated and easy to break so CI will be helpful.
Signed-off-by Nicholas Piggin <[email protected]>--- .gitlab-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-).gitlab-ci.yml +11
-7@@ -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
Quoted 8 lines
.gitlab-ci.yml build-s390x: · line 142
Quoted 3 lines
.gitlab-ci.yml +0
-0sieve smp stsiWhile I can update the qemu binary for the s390x-kvm job, the build-* jobs run in a container with a normal QEMU from the corresponding distros, so I think this has to wait 'til we get distros that contain your QEMU TCG migration fix.
Okay. powerpc *could* run into the TCG bug too, in practice it has not. We could try enable it there to get migration into CI, and revert it if it starts showing random failures?
Thanks,
Nick
Re: [kvm-unit-tests PATCH 5/7] arch-run: Add a "continuous" migration option for tests
In reply to Thomas HuthQuoted 141 lines · Thomas Huth
Quoted 131 lines · Nicholas Piggin
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 <[email protected]>--- 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(-)common/selftest-migration.c +13
-3@@ -9,12 +9,13 @@*/ #include <libcflat.h> #include <migrate.h> +#include <asm/time.h> -#define NR_MIGRATIONS 30 +#define NR_MIGRATIONS 15int 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 ();lib/migrate.c +18
-0@@ -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 (); +}lib/migrate.h +3
-0@@ -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 );scripts/arch-run.bash +5
-2@@ -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}scripts/arch-run.bash run_migration () · line 192
Quoted 6 lines
scripts/arch-run.bash +1
-2@@ -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 ]] ; thenHere you're using "[[" for testing ...
Quoted 11 lines
scripts/arch-run.bash run_migration () · line 200
Quoted 8 lines
scripts/arch-run.bash +4
-0+ 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... while the other code seems to use "[" for testing values. Can we try to stick to one style, please (unless it's really required to use "[[" somewhere)?
Good point. Will do.
Thanks,
Nick
Re: [kvm-unit-tests PATCH 7/7] common: add memory dirtying vs migration test
In reply to Thomas HuthQuoted 9 lines · Thomas Huth
Quoted 3 lines · Nicholas Piggin
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.
Good idea, but could we then please drop "continuous" test from
selftest-migration.cagain? ... having two common tests to exercise the continuous migration that take quite a bunch of seconds to finish sounds like a waste of time in the long run to me.
Yeah if you like. I could shorten them up a bit. I did want to have the selftests for just purely testing the harness with as little "test" code as possible.
Quoted 55 lines
Quoted 55 lines
Signed-off-by Nicholas Piggin <[email protected]>--- 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 120000powerpc/memory-verify.c
create mode 120000s390x/memory-verify.ccommon/memory-verify.c new file +34
-0@@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Simple memory verification test, used to exercise dirty memory migration. +* +*/ +#include <libcflat.h> +#include <migrate.h> +#include <alloc.h> +#include <asm/page.h> +#include <asm/time.h> + +#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;
Quoted 8 lines
common/memory-verify.c line 39
Quoted 5 lines
common/memory-verify.c new file +5
-0+ } + *(volatile long *)(mem + j) = i +1 ; + } + i++; + }while (get_clock_ms () - ms <5000 );Maybe add a parameter so that the user can use different values for the runtime than always doing 5 seconds?
Sure.
Thanks,
Nick
Re: [kvm-unit-tests PATCH 5/7] arch-run: Add a "continuous" migration option for tests
In reply to Andrew JonesQuoted 146 lines · Andrew Jones
Quoted 131 lines · Thomas Huth
Quoted 122 lines · Nicholas Piggin
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 <[email protected]>--- 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(-)common/selftest-migration.c +13
-3@@ -9,12 +9,13 @@*/ #include <libcflat.h> #include <migrate.h> +#include <asm/time.h> -#define NR_MIGRATIONS 30 +#define NR_MIGRATIONS 15int 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 ();lib/migrate.c +18
-0@@ -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 (); +}lib/migrate.h +3
-0@@ -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 );scripts/arch-run.bash +5
-2@@ -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}scripts/arch-run.bash run_migration () · line 191
Quoted 5 lines
scripts/arch-run.bash +1
-2@@ -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 ]] ; thenHere you're using "[[" for testing ...
Quoted 13 lines
scripts/arch-run.bash run_migration () · line 200
Quoted 8 lines
scripts/arch-run.bash +4
-0+ 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... while the other code seems to use "[" for testing values. Can we try to stick to one style, please (unless it's really required to use "[[" somewhere)?
Quoted 5 lines
We should decide on a Bash coding style and on preferences like [[ and then write a document for it, as well as create a set of shellcheck includes/excludes to test it. Then, using shellcheck we'd change all our current Bash code and also require shellcheck to pass on all new code before merge.
Seems like a good idea.
Quoted 7 lines
Any volunteers for that effort? For the style selection
we can take inspiration from other projects or even just adopt their style guides. Google has some guidance[1][2] and googling for Bash style pops up other hits.[1] https://google.github.io/styleguide/shellguide.html
[2] https://chromium.googlesource.com/chromiumos/docs/+/master/styleguide/shell.md
My bash skills consit of mashing the keyboard until the errors quieten down, so I may not be the best to decide on this stuff. I could take a look at getting the checker running in make and post an RFC though. No promises if it turns out to be harder than it looks...
Thanks,
Nick
Re: [kvm-unit-tests PATCH 6/7] gitlab-ci: Run migration selftest on s390x and powerpc
In reply to Nicholas PigginQuoted 73 lines · Nicholas Piggin
Quoted 63 lines · Thomas Huth
Quoted 62 lines · Nicholas Piggin
The migration harness is complicated and easy to break so CI will be helpful.
Signed-off-by Nicholas Piggin <[email protected]>--- .gitlab-ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-).gitlab-ci.yml +11
-7@@ -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-skipQuoted 8 lines
.gitlab-ci.yml build-s390x: · line 142
Quoted 3 lines
.gitlab-ci.yml +0
-0sieve smp stsiWhile I can update the qemu binary for the s390x-kvm job, the build-* jobs run in a container with a normal QEMU from the corresponding distros, so I think this has to wait 'til we get distros that contain your QEMU TCG migration fix.
Quoted 3 lines
Okay. powerpc *could* run into the TCG bug too, in practice it has not. We could try enable it there to get migration into CI, and revert it if it starts showing random failures?
Fine for me.
Thomas
Re: [kvm-unit-tests PATCH 7/7] common: add memory dirtying vs migration test
In reply to Nicholas PigginQuoted 6 lines · Nicholas Piggin
Quoted 5 lines · Thomas Huth
Quoted 3 lines · Nicholas Piggin
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.
Quoted 8 lines
Quoted 4 lines
Good idea, but could we then please drop "continuous" test from
selftest-migration.cagain? ... having two common tests to exercise the continuous migration that take quite a bunch of seconds to finish sounds like a waste of time in the long run to me.Yeah if you like. I could shorten them up a bit. I did want to have the selftests for just purely testing the harness with as little "test" code as possible.
Ok, but then please shorten the selftest to ~ 2 seconds if possible, please.
Thomas