All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
To: kvm@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org, lvivier@redhat.com, thuth@redhat.com,
	dgibson@redhat.com,
	Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Subject: [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on decr excp
Date: Wed, 15 May 2019 10:28:00 +1000	[thread overview]
Message-ID: <20190515002801.20517-1-sjitindarsingh@gmail.com> (raw)

Currently the handler for a decrementer exception will simply reload the
maximum value (0x7FFFFFFF), which will take ~4 seconds to expire again.
This means that if a vcpu cedes, it will be ~4 seconds between wakeups.

The h_cede_tm test is testing a known breakage when a guest cedes while
suspended. To be sure we cede 500 times to check for the bug. However
since it takes ~4 seconds to be woken up once we've ceded, we only get
through ~20 iterations before we reach the 90 seconds timeout and the
test appears to fail.

Add an option when registering the decrementer handler to specify the
value which should be reloaded by the handler, allowing the timeout to be
chosen.

Modify the spr test to use the max timeout to preserve existing
behaviour.
Modify the h_cede_tm test to use a 10ms timeout to ensure we can perform
500 iterations before hitting the 90 second time limit for a test.

This means the h_cede_tm test now succeeds rather than timing out.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>

---

V1 -> V2:
- Make decr variables static
- Load intial decr value in tm test to ensure known value present
---
 lib/powerpc/handlers.c | 7 ++++---
 powerpc/sprs.c         | 5 +++--
 powerpc/tm.c           | 4 +++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/powerpc/handlers.c b/lib/powerpc/handlers.c
index be8226a..c8721e0 100644
--- a/lib/powerpc/handlers.c
+++ b/lib/powerpc/handlers.c
@@ -12,11 +12,12 @@
 
 /*
  * Generic handler for decrementer exceptions (0x900)
- * Just reset the decrementer back to its maximum value (0x7FFFFFFF)
+ * Just reset the decrementer back to the value specified when registering the
+ * handler
  */
-void dec_except_handler(struct pt_regs *regs __unused, void *data __unused)
+void dec_except_handler(struct pt_regs *regs __unused, void *data)
 {
-	uint32_t dec = 0x7FFFFFFF;
+	uint64_t dec = *((uint64_t *) data);
 
 	asm volatile ("mtdec %0" : : "r" (dec));
 }
diff --git a/powerpc/sprs.c b/powerpc/sprs.c
index 6744bd8..0e2e1c9 100644
--- a/powerpc/sprs.c
+++ b/powerpc/sprs.c
@@ -253,6 +253,7 @@ int main(int argc, char **argv)
 		0x1234567890ABCDEFULL, 0xFEDCBA0987654321ULL,
 		-1ULL,
 	};
+	static uint64_t decr = 0x7FFFFFFF; /* Max value */
 
 	for (i = 1; i < argc; i++) {
 		if (!strcmp(argv[i], "-w")) {
@@ -288,8 +289,8 @@ int main(int argc, char **argv)
 		(void) getchar();
 	} else {
 		puts("Sleeping...\n");
-		handle_exception(0x900, &dec_except_handler, NULL);
-		asm volatile ("mtdec %0" : : "r" (0x3FFFFFFF));
+		handle_exception(0x900, &dec_except_handler, &decr);
+		asm volatile ("mtdec %0" : : "r" (decr));
 		hcall(H_CEDE);
 	}
 
diff --git a/powerpc/tm.c b/powerpc/tm.c
index bd56baa..c588985 100644
--- a/powerpc/tm.c
+++ b/powerpc/tm.c
@@ -95,11 +95,13 @@ static bool enable_tm(void)
 static void test_h_cede_tm(int argc, char **argv)
 {
 	int i;
+	static uint64_t decr = 0x3FFFFF; /* ~10ms */
 
 	if (argc > 2)
 		report_abort("Unsupported argument: '%s'", argv[2]);
 
-	handle_exception(0x900, &dec_except_handler, NULL);
+	handle_exception(0x900, &dec_except_handler, &decr);
+	asm volatile ("mtdec %0" : : "r" (decr));
 
 	if (!start_all_cpus(halt, 0))
 		report_abort("Failed to start secondary cpus");
-- 
2.13.6


WARNING: multiple messages have this Message-ID (diff)
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
To: kvm@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org, lvivier@redhat.com, thuth@redhat.com,
	dgibson@redhat.com,
	Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Subject: [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on decr
Date: Wed, 15 May 2019 00:28:00 +0000	[thread overview]
Message-ID: <20190515002801.20517-1-sjitindarsingh@gmail.com> (raw)
In-Reply-To: <1456506526-10803-2-git-send-email-lvivier@redhat.com>

Currently the handler for a decrementer exception will simply reload the
maximum value (0x7FFFFFFF), which will take ~4 seconds to expire again.
This means that if a vcpu cedes, it will be ~4 seconds between wakeups.

The h_cede_tm test is testing a known breakage when a guest cedes while
suspended. To be sure we cede 500 times to check for the bug. However
since it takes ~4 seconds to be woken up once we've ceded, we only get
through ~20 iterations before we reach the 90 seconds timeout and the
test appears to fail.

Add an option when registering the decrementer handler to specify the
value which should be reloaded by the handler, allowing the timeout to be
chosen.

Modify the spr test to use the max timeout to preserve existing
behaviour.
Modify the h_cede_tm test to use a 10ms timeout to ensure we can perform
500 iterations before hitting the 90 second time limit for a test.

This means the h_cede_tm test now succeeds rather than timing out.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>

---

V1 -> V2:
- Make decr variables static
- Load intial decr value in tm test to ensure known value present
---
 lib/powerpc/handlers.c | 7 ++++---
 powerpc/sprs.c         | 5 +++--
 powerpc/tm.c           | 4 +++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/powerpc/handlers.c b/lib/powerpc/handlers.c
index be8226a..c8721e0 100644
--- a/lib/powerpc/handlers.c
+++ b/lib/powerpc/handlers.c
@@ -12,11 +12,12 @@
 
 /*
  * Generic handler for decrementer exceptions (0x900)
- * Just reset the decrementer back to its maximum value (0x7FFFFFFF)
+ * Just reset the decrementer back to the value specified when registering the
+ * handler
  */
-void dec_except_handler(struct pt_regs *regs __unused, void *data __unused)
+void dec_except_handler(struct pt_regs *regs __unused, void *data)
 {
-	uint32_t dec = 0x7FFFFFFF;
+	uint64_t dec = *((uint64_t *) data);
 
 	asm volatile ("mtdec %0" : : "r" (dec));
 }
diff --git a/powerpc/sprs.c b/powerpc/sprs.c
index 6744bd8..0e2e1c9 100644
--- a/powerpc/sprs.c
+++ b/powerpc/sprs.c
@@ -253,6 +253,7 @@ int main(int argc, char **argv)
 		0x1234567890ABCDEFULL, 0xFEDCBA0987654321ULL,
 		-1ULL,
 	};
+	static uint64_t decr = 0x7FFFFFFF; /* Max value */
 
 	for (i = 1; i < argc; i++) {
 		if (!strcmp(argv[i], "-w")) {
@@ -288,8 +289,8 @@ int main(int argc, char **argv)
 		(void) getchar();
 	} else {
 		puts("Sleeping...\n");
-		handle_exception(0x900, &dec_except_handler, NULL);
-		asm volatile ("mtdec %0" : : "r" (0x3FFFFFFF));
+		handle_exception(0x900, &dec_except_handler, &decr);
+		asm volatile ("mtdec %0" : : "r" (decr));
 		hcall(H_CEDE);
 	}
 
diff --git a/powerpc/tm.c b/powerpc/tm.c
index bd56baa..c588985 100644
--- a/powerpc/tm.c
+++ b/powerpc/tm.c
@@ -95,11 +95,13 @@ static bool enable_tm(void)
 static void test_h_cede_tm(int argc, char **argv)
 {
 	int i;
+	static uint64_t decr = 0x3FFFFF; /* ~10ms */
 
 	if (argc > 2)
 		report_abort("Unsupported argument: '%s'", argv[2]);
 
-	handle_exception(0x900, &dec_except_handler, NULL);
+	handle_exception(0x900, &dec_except_handler, &decr);
+	asm volatile ("mtdec %0" : : "r" (decr));
 
 	if (!start_all_cpus(halt, 0))
 		report_abort("Failed to start secondary cpus");
-- 
2.13.6

             reply	other threads:[~2019-05-15  0:28 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15  0:28 Suraj Jitindar Singh [this message]
2019-05-15  0:28 ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on decr Suraj Jitindar Singh
2019-05-15  0:28 ` [kvm-unit-tests PATCH v2 2/2] powerpc: Make h_cede_tm test run by default Suraj Jitindar Singh
2019-05-15  0:28   ` Suraj Jitindar Singh
2019-05-15 16:25   ` Laurent Vivier
2019-05-15 16:25     ` Laurent Vivier
2019-05-17 10:13   ` Thomas Huth
2019-05-17 10:13     ` Thomas Huth
2019-05-15 16:22 ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on decr excp Laurent Vivier
2019-05-15 16:22   ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on Laurent Vivier
2019-05-15 23:27   ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on decr excp Suraj Jitindar Singh
2019-05-15 23:27     ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on Suraj Jitindar Singh
2019-05-17 10:20     ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on decr excp Thomas Huth
2019-05-17 10:20       ` [kvm-unit-tests PATCH v2 1/2] powerpc: Allow for a custom decr value to be specified to load on Thomas Huth
  -- strict thread matches above, loose matches on Subject: below --
2016-02-26 17:08 [kvm-unit-tests PATCH v2 0/2] powerpc: add little-endian support Laurent Vivier
2016-02-26 17:08 ` Laurent Vivier
2016-02-26 17:08 ` [kvm-unit-tests PATCH v2 1/2] powerpc: allow to build big-endian binaries on little-endian host Laurent Vivier
2016-02-26 17:08   ` Laurent Vivier
2016-02-26 17:41   ` Andrew Jones
2016-02-26 17:41     ` Andrew Jones
2016-02-26 17:42   ` Andrew Jones
2016-02-26 17:42     ` Andrew Jones
2016-02-26 17:08 ` [kvm-unit-tests PATCH v2 2/2] powerpc: select endianness Laurent Vivier
2016-02-26 17:08   ` Laurent Vivier
2016-02-26 18:45   ` Andrew Jones
2016-02-26 18:45     ` Andrew Jones
2016-02-29 13:24     ` Laurent Vivier
2016-02-29 13:24       ` Laurent Vivier
2016-02-29 16:06     ` Paolo Bonzini
2016-02-29 16:06       ` Paolo Bonzini
2016-02-29 16:44       ` Laurent Vivier
2016-02-29 16:44         ` Laurent Vivier
2016-02-29 17:53     ` Laurent Vivier
2016-02-29 17:53       ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190515002801.20517-1-sjitindarsingh@gmail.com \
    --to=sjitindarsingh@gmail.com \
    --cc=dgibson@redhat.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.