Re: [kvm-unit-tests PATCH 7/7] common: add memory dirtying vs migration test
From: "Nicholas Piggin" <npiggin@gmail.com>
Date: 2024-03-05 02:51:11
Also in:
kvm, linux-s390
On Mon Mar 4, 2024 at 4:22 PM AEST, Thomas Huth wrote:
On 26/02/2024 10.38, Nicholas Piggin wrote:quoted
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.
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
Signed-off-by: Nicholas Piggin <npiggin@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.cdiff --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?
Sure. Thanks, Nick