diff mbox series

[kvm-unit-tests,v5,07/29] powerpc: Add a migration stress tester

Message ID 20231216134257.1743345-8-npiggin@gmail.com (mailing list archive)
State New, archived
Headers show
Series powerpc: updates, P10, PNV support | expand

Commit Message

Nicholas Piggin Dec. 16, 2023, 1:42 p.m. UTC
This performs 1000 migrations a tight loop to flush out simple issues
in the multiple-migration code.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 powerpc/Makefile.common |  1 +
 powerpc/migrate.c       | 64 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 powerpc/migrate.c

Comments

Thomas Huth Dec. 19, 2023, 5:58 a.m. UTC | #1
On 16/12/2023 14.42, Nicholas Piggin wrote:
> This performs 1000 migrations a tight loop to flush out simple issues
> in the multiple-migration code.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>   powerpc/Makefile.common |  1 +
>   powerpc/migrate.c       | 64 +++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 65 insertions(+)
>   create mode 100644 powerpc/migrate.c

You should likely add an entry to powerpc/unittests.cfg ...
also, wouldn't it be better to extend the sprs.elf test for this, so that it 
e.g. changes some stuff for each migration?

  Thomas
Nicholas Piggin Dec. 22, 2023, 10:32 a.m. UTC | #2
On Tue Dec 19, 2023 at 3:58 PM AEST, Thomas Huth wrote:
> On 16/12/2023 14.42, Nicholas Piggin wrote:
> > This performs 1000 migrations a tight loop to flush out simple issues
> > in the multiple-migration code.
> > 
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >   powerpc/Makefile.common |  1 +
> >   powerpc/migrate.c       | 64 +++++++++++++++++++++++++++++++++++++++++
> >   2 files changed, 65 insertions(+)
> >   create mode 100644 powerpc/migrate.c
>
> You should likely add an entry to powerpc/unittests.cfg ...
> also, wouldn't it be better to extend the sprs.elf test for this, so that it 
> e.g. changes some stuff for each migration?

It was supposed to be kind of a dumb stress tester for the harness
that just runs as quickly as possible for a long time :) I'll see if
it can be massaged into something more useful.

sprs (and others) probably should get better migration stressing
when multi-migration support lands in the harness, but I was
thinking that could be follow up patches.

Thanks,
Nick
diff mbox series

Patch

diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index f8f47490..a7af225b 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -5,6 +5,7 @@ 
 #
 
 tests-common = \
+	$(TEST_DIR)/migrate.elf \
 	$(TEST_DIR)/selftest.elf \
 	$(TEST_DIR)/spapr_hcall.elf \
 	$(TEST_DIR)/rtas.elf \
diff --git a/powerpc/migrate.c b/powerpc/migrate.c
new file mode 100644
index 00000000..a9f98c9f
--- /dev/null
+++ b/powerpc/migrate.c
@@ -0,0 +1,64 @@ 
+/*
+ * Stress Test Migration
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+#include <libcflat.h>
+#include <util.h>
+#include <migrate.h>
+#include <alloc.h>
+#include <asm/handlers.h>
+#include <devicetree.h>
+#include <asm/hcall.h>
+#include <asm/processor.h>
+#include <asm/barrier.h>
+
+static bool do_migrate = false;
+
+static void test_migration(int argc, char **argv)
+{
+	int i;
+
+	for (i = 0; i < 1000; i++) {
+		if (do_migrate)
+			migrate();
+	}
+}
+
+struct {
+	const char *name;
+	void (*func)(int argc, char **argv);
+} hctests[] = {
+	{ "migration", test_migration },
+	{ NULL, NULL }
+};
+
+int main(int argc, char **argv)
+{
+	bool all;
+	int i;
+
+	all = argc == 1 || !strcmp(argv[1], "all");
+
+	for (i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "-w")) {
+			do_migrate = true;
+			if (!all && argc == 2)
+				all = true;
+		}
+	}
+
+	report_prefix_push("migration");
+
+	for (i = 0; hctests[i].name != NULL; i++) {
+		if (all || strcmp(argv[1], hctests[i].name) == 0) {
+			report_prefix_push(hctests[i].name);
+			hctests[i].func(argc, argv);
+			report_prefix_pop();
+		}
+	}
+
+	report_prefix_pop();
+
+	return report_summary();
+}