lib/igt_aux: make igt_wait_for_pm_status() resist the signal helper
PATCH 1/1 lib/igt_aux: make igt_wait_for_pm_status() resist the signal helper
From: Paulo Zanoni <[email protected]>
If the signal helper is active, the usleep() calls return earlier, and we may end up returning false way before the 10s timeout, failing the subtests. This currently happens on the kms_flip RPM interruptible subtests.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893
--- lib/igt_aux.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
lib/igt_aux.c +12 -5
@@ -42,6 +42,7 @@#include <stdlib.h> #include <unistd.h> #include <sys/wait.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/syscall.h> #include <sys/utsname.h>
@@ -502,21 +503,27 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void)* Waits until for the driver to switch to into the desired runtime PM status, * with a 10 second timeout. * +* Some subtests call this function while the signal helper is active, so we +* can't assume each usleep() call will sleep for 100ms. +* * Returns: * True if the desired runtime PM status was attained, false if the operation * timed out. */ bool igt_wait_for_pm_status (enum igt_runtime_pm_status status) { -int i; -int hundred_ms =100 *1000 , ten_s =10 *1000 *1000 ; +struct timeval start, end, diff; -for (i =0 ; i < ten_s; i += hundred_ms) { +igt_assert (gettimeofday (&start,NULL ) ==0 ); +do {if (igt_get_runtime_pm_status () == status)return true; -usleep (hundred_ms); - } +usleep (100 *1000 ); + +igt_assert (gettimeofday (&end,NULL ) ==0 ); +timersub (&end, &start, &diff); + }while (diff.tv_sec <10 );return false; }
Signature · 1 line
1.9.1
Quoted 44 lines · Paulo Zanoni
From: Paulo Zanoni <[email protected]>
If the signal helper is active, the
usleep()calls return earlier, and we may end up returning false way before the 10s timeout, failing the subtests. This currently happens on thekms_flipRPM interruptible subtests.Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893
Signed-off-by Paulo Zanoni <[email protected]>--- lib/igt_aux.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)lib/igt_aux.c +6
-3@@ -42,6 +42,7 @@#include <stdlib.h> #include <unistd.h> #include <sys/wait.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/syscall.h> #include <sys/utsname.h> @@ -502,21 +503,27 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void)* Waits until for the driver to switch to into the desired runtime PM status, * with a 10 second timeout. * +* Some subtests call this function while the signal helper is active, so we +* can't assume each usleep() call will sleep for 100ms. +* * Returns: * True if the desired runtime PM status was attained, false if the operation * timed out. */ bool igt_wait_for_pm_status (enum igt_runtime_pm_status status) { -int i; -int hundred_ms =100 *1000 , ten_s =10 *1000 *1000 ; +struct timeval start, end, diff; -for (i =0 ; i < ten_s; i += hundred_ms) { +igt_assert (gettimeofday (&start,NULL ) ==0 );
lib/igt_aux.c enum igt_runtime_pm_status igt_get_runtime_pm_status(void) · line 525
Quoted 10 lines
lib/igt_aux.c +5
-2+ do { if (igt_get_runtime_pm_status() == status) return true; -usleep (hundred_ms); - } + usleep(100 * 1000); + + igt_assert(gettimeofday(&end, NULL) == 0); + timersub(&end, &start, &diff);
Should we have a generic igt_usleep helper which is signal-robust? Just a quick idea since there's probably more like these.
-Daniel
Quoted 11 lines
lib/igt_aux.c +1
-0+ }while (diff.tv_sec <10 );return false; }Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
2014-10-21 13:18 GMT-02:00 Daniel Vetter <[email protected]>:
Quoted 49 lines · Paulo Zanoni
Quoted 48 lines
From: Paulo Zanoni <[email protected]>
If the signal helper is active, the
usleep()calls return earlier, and we may end up returning false way before the 10s timeout, failing the subtests. This currently happens on thekms_flipRPM interruptible subtests.Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893
Signed-off-by Paulo Zanoni <[email protected]>--- lib/igt_aux.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)lib/igt_aux.c +7
-3@@ -42,6 +42,7 @@#include <stdlib.h> #include <unistd.h> #include <sys/wait.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/syscall.h> #include <sys/utsname.h> @@ -502,21 +503,27 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void)* Waits until for the driver to switch to into the desired runtime PM status, * with a 10 second timeout. * +* Some subtests call this function while the signal helper is active, so we +* can't assume each usleep() call will sleep for 100ms. +* * Returns: * True if the desired runtime PM status was attained, false if the operation * timed out. */ bool igt_wait_for_pm_status (enum igt_runtime_pm_status status) { -int i; -int hundred_ms =100 *1000 , ten_s =10 *1000 *1000 ; +struct timeval start, end, diff; -for (i =0 ; i < ten_s; i += hundred_ms) { +igt_assert (gettimeofday (&start,NULL ) ==0 ); + do { if (igt_get_runtime_pm_status() == status) return true;
Quoted 9 lines
lib/igt_aux.c enum igt_runtime_pm_status igt_get_runtime_pm_status(void) · line 525
Quoted 6 lines
lib/igt_aux.c +4
-2-usleep (hundred_ms); - } +usleep (100 *1000 ); + +igt_assert (gettimeofday (&end,NULL ) ==0 ); +timersub (&end, &start, &diff);Should we have a generic
igt_usleephelper which is signal-robust? Just a quick idea since there's probably more like these.
If we think we could use it in many places, it makes sense. I'm not aware yet of where we could use it.
Quoted 18 lines
-Daniel
Quoted 11 lines
lib/igt_aux.c +1
-1+ }while (diff.tv_sec <10 );return false; } --1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Paulo Zanoni
Quoted 60 lines · Paulo Zanoni
2014-10-21 13:18 GMT-02:00 Daniel Vetter <[email protected]>:
Quoted 49 lines · Paulo Zanoni
Quoted 48 lines
From: Paulo Zanoni <[email protected]>
If the signal helper is active, the
usleep()calls return earlier, and we may end up returning false way before the 10s timeout, failing the subtests. This currently happens on thekms_flipRPM interruptible subtests.Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78893
Signed-off-by Paulo Zanoni <[email protected]>--- lib/igt_aux.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)lib/igt_aux.c +7
-3@@ -42,6 +42,7 @@#include <stdlib.h> #include <unistd.h> #include <sys/wait.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/syscall.h> #include <sys/utsname.h> @@ -502,21 +503,27 @@ enum igt_runtime_pm_status igt_get_runtime_pm_status(void)* Waits until for the driver to switch to into the desired runtime PM status, * with a 10 second timeout. * +* Some subtests call this function while the signal helper is active, so we +* can't assume each usleep() call will sleep for 100ms. +* * Returns: * True if the desired runtime PM status was attained, false if the operation * timed out. */ bool igt_wait_for_pm_status (enum igt_runtime_pm_status status) { -int i; -int hundred_ms =100 *1000 , ten_s =10 *1000 *1000 ; +struct timeval start, end, diff; -for (i =0 ; i < ten_s; i += hundred_ms) { +igt_assert (gettimeofday (&start,NULL ) ==0 ); + do { if (igt_get_runtime_pm_status() == status) return true;Quoted 9 lines
lib/igt_aux.c enum igt_runtime_pm_status igt_get_runtime_pm_status(void) · line 525
Quoted 6 lines
lib/igt_aux.c +4
-2-usleep (hundred_ms); - } +usleep (100 *1000 ); + +igt_assert (gettimeofday (&end,NULL ) ==0 ); +timersub (&end, &start, &diff);Should we have a generic
igt_usleephelper which is signal-robust? Just a quick idea since there's probably more like these.
Quoted 2 lines
If we think we could use it in many places, it makes sense. I'm not aware yet of where we could use it.
Do a cocci patch to replace all the existing usleep with igt_usleep extracted from here. Run it on tests/*.c.
We already have a cocci spatch in lib/igt.cocci with lots of default refactorings like that to replace C functions with igt helpers where it makes sense. Signed up? And even if it's just to learn a bit how coccinelle works, that alone is awesome ;-)
-Daniel
Quoted 24 lines
Quoted 19 lines
-Daniel
Quoted 11 lines
lib/igt_aux.c +1
-1+ }while (diff.tv_sec <10 );return false; } --1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.chSignature · 1 line
Paulo Zanoni
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch