[kvm-unit-tests PATCH 7/7] common: add memory dirtying vs migration test

Thomas Huth thuth at redhat.com
Mon Mar 4 17:22:18 AEDT 2024


On 26/02/2024 10.38, Nicholas Piggin wrote:
> 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.

> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
> ---
>   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 <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);

Maybe add a parameter so that the user can use different values for the 
runtime than always doing 5 seconds?

  Thomas

> +out:
> +	migrate_end_continuous();
> +
> +	report(success, "memory verification stress test");
> +
> +	report_prefix_pop();
> +
> +	return report_summary();
> +}



More information about the Linuxppc-dev mailing list