powerpc: Allow for a custom decr value to be specified to load on decr excp
PATCH v2 1/2 powerpc: Allow for a custom decr value to be specified to load on decr excp
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.
---
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(-)
lib/powerpc/handlers.c +4 -3
@@ -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); asmvolatile ("mtdec %0" : :"r" (dec)); }
powerpc/sprs.c +3 -2
@@ -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 ); - asmvolatile ("mtdec %0" : :"r" (0x3FFFFFFF )); +handle_exception (0x900 , &dec_except_handler, &decr); + asmvolatile ("mtdec %0" : :"r" (decr));hcall (H_CEDE ); }
powerpc/tm.c +3 -1
@@ -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); + asmvolatile ("mtdec %0" : :"r" (decr));if (!start_all_cpus (halt,0 ))report_abort ("Failed to start secondary cpus" );
Signature · 1 line
2.13.6
PATCH v2 2/2 powerpc: Make h_cede_tm test run by default
This test was initially designed to test for a known bug where performing a sequence of H_CEDE hcalls while suspended would cause a vcpu to lockup in the host. The fix has been available for some time now, so to increase coverage of this test remove the no-default flag.
--- powerpc/unittests.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
powerpc/unittests.cfg +1 -1
@@ -64,7 +64,7 @@ file = emulator.elf file = tm.elf smp = 2,threads=2 extra_params = -machine cap-htm=on -append "h_cede_tm" -groups = nodefault,h_cede_tm +groups = h_cede_tm [sprs] file = sprs.elf
Signature · 1 line
2.13.6
Re: [kvm-unit-tests PATCH v2 2/2] powerpc: Make h_cede_tm test run by default
Quoted 16 lines · Suraj Jitindar Singh
This test was initially designed to test for a known bug where performing a sequence of
H_CEDEhcalls while suspended would cause a vcpu to lockup in the host. The fix has been available for some time now, so to increase coverage of this test remove the no-default flag.Signed-off-by Suraj Jitindar Singh <[email protected]>--- powerpc/unittests.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)powerpc/unittests.cfg +0
-0
powerpc/unittests.cfg file = emulator.elf · line 70
Quoted 8 lines
powerpc/unittests.cfg +1
-1@@ -64,7 +64,7 @@ file = emulator.elf file = tm.elf smp = 2,threads=2 extra_params = -machine cap-htm=on -append "h_cede_tm" -groups = nodefault,h_cede_tm +groups = h_cede_tm [sprs] file = sprs.elf
Re: [kvm-unit-tests PATCH v2 2/2] powerpc: Make h_cede_tm test run by default
In reply to Suraj Jitindar SinghQuoted 15 lines · Suraj Jitindar Singh
This test was initially designed to test for a known bug where performing a sequence of
H_CEDEhcalls while suspended would cause a vcpu to lockup in the host. The fix has been available for some time now, so to increase coverage of this test remove the no-default flag.Signed-off-by Suraj Jitindar Singh <[email protected]>--- powerpc/unittests.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)powerpc/unittests.cfg +0
-0
powerpc/unittests.cfg file = emulator.elf · line 70
Quoted 8 lines
powerpc/unittests.cfg +1
-1@@ -64,7 +64,7 @@ file = emulator.elf file = tm.elf smp = 2,threads=2 extra_params = -machine cap-htm=on -append "h_cede_tm" -groups = nodefault,h_cede_tm +groups = h_cede_tm [sprs] file = sprs.elf
Quoted 67 lines · Suraj Jitindar Singh
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_tmtest 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 theh_cede_tmtest 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_tmtest now succeeds rather than timing out.Signed-off-by Suraj Jitindar Singh <[email protected]>---
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(-)lib/powerpc/handlers.c +4
-3@@ -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); asmvolatile ("mtdec %0" : :"r" (dec)); }powerpc/sprs.c +1
-0@@ -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" )) {
powerpc/sprs.c int main(int argc, char **argv) · line 293
Quoted 7 lines
powerpc/sprs.c +2
-2@@ -288,8 +289,8 @@ int main(int argc, char **argv) (void )getchar (); }else {puts ("Sleeping...\n" ); -handle_exception (0x900 , &dec_except_handler,NULL ); - asmvolatile ("mtdec %0" : :"r" (0x3FFFFFFF )); +handle_exception (0x900 , &dec_except_handler, &decr); + asmvolatile ("mtdec %0" : :"r" (decr));
why do you replace the 0x3FFFFFFF by decr which is 0x7FFFFFFF?
Quoted 13 lines
powerpc/sprs.c +0
-0hcall (H_CEDE ); }powerpc/tm.c +1
-0@@ -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 */
powerpc/tm.c static bool enable_tm(void) · line 107
Quoted 10 lines
powerpc/tm.c +2
-1if (argc >2 )report_abort ("Unsupported argument: '%s'" , argv[2 ]); -handle_exception (0x900 , &dec_except_handler,NULL ); +handle_exception (0x900 , &dec_except_handler, &decr); + asmvolatile ("mtdec %0" : :"r" (decr));if (!start_all_cpus (halt,0 ))report_abort ("Failed to start secondary cpus" );
Thanks,
Laurent
Quoted 78 lines · Laurent Vivier
Quoted 77 lines · Suraj Jitindar Singh
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_tmtest 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 theh_cede_tmtest 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_tmtest now succeeds rather than timing out.Signed-off-by Suraj Jitindar Singh <[email protected]>---
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(-)lib/powerpc/handlers.c +1
-1@@ -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
*/
-voiddec_except_handler(struct pt_regs *regs __unused, void *data __unused)lib/powerpc/handlers.c +2
-1+void dec_except_handler(struct pt_regs *regs __unused, void *data) { -uint32_t dec =0x7FFFFFFF ; +uint64_t dec = *((uint64_t *) data); asmvolatile ("mtdec %0" : :"r" (dec)); }powerpc/sprs.c +1
-0@@ -253,6 +253,7 @@ int main(int argc, char **argv)0x1234567890ABCDEFULL ,0xFEDCBA0987654321ULL , -1ULL, }; +static uint64_t decr =0x7FFFFFFF ;/* Max value */
Quoted 14 lines
powerpc/sprs.c int main(int argc, char **argv) · line 295
Quoted 12 lines
powerpc/sprs.c +2
-2for (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); - asmvolatile ("mtdec %0" : :"r" (0x3FFFFFFF )); +handle_exception (0x900 , &dec_except_handler, &decr); + asmvolatile ("mtdec %0" : :"r" (decr));why do you replace the
0x3FFFFFFFby decr which is0x7FFFFFFF?
Oh yeah, my mistake. I mis-read and thought they were the same. Is there any reason it was 0x3FFFFFFF? Can this be fixed up when applying or should I resend?
Quoted 28 lines
Quoted 23 lines
powerpc/sprs.c +0
-0hcall (H_CEDE );powerpc/sprs.c +0
-0}powerpc/tm.c +3
-1@@ -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); + asmvolatile ("mtdec %0" : :"r" (decr));if (!start_all_cpus (halt,0 ))Quoted 2 lines
report_abort("Failed to start secondary cpus");Thanks,
Laurent
Thomas Huth
Reviewed-byQuoted 94 lines · Suraj Jitindar Singh
Quoted 78 lines · Laurent Vivier
Quoted 77 lines · Suraj Jitindar Singh
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_tmtest 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 theh_cede_tmtest 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_tmtest now succeeds rather than timing out.Signed-off-by Suraj Jitindar Singh <[email protected]>---
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(-)lib/powerpc/handlers.c +1
-1@@ -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
*/
-voiddec_except_handler(struct pt_regs *regs __unused, void *data __unused)lib/powerpc/handlers.c +2
-1+void dec_except_handler(struct pt_regs *regs __unused, void *data) { -uint32_t dec =0x7FFFFFFF ; +uint64_t dec = *((uint64_t *) data); asmvolatile ("mtdec %0" : :"r" (dec)); }powerpc/sprs.c +1
-0@@ -253,6 +253,7 @@ int main(int argc, char **argv)0x1234567890ABCDEFULL ,0xFEDCBA0987654321ULL , -1ULL, }; +static uint64_t decr =0x7FFFFFFF ;/* Max value */ Quoted 14 lines
powerpc/sprs.c int main(int argc, char **argv) · line 295
Quoted 12 lines
powerpc/sprs.c +2
-2for (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); - asmvolatile ("mtdec %0" : :"r" (0x3FFFFFFF )); +handle_exception (0x900 , &dec_except_handler, &decr); + asmvolatile ("mtdec %0" : :"r" (decr));why do you replace the
0x3FFFFFFFby decr which is0x7FFFFFFF?
Quoted 3 lines
Oh yeah, my mistake. I mis-read and thought they were the same. Is there any reason it was
0x3FFFFFFF? Can this be fixed up when applying or should I resend?
Should be fine to fix this when the patch gets picked up. With the value fixed: