public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] misc: tst-poll: Proper synchronize with child before sending the signal
@ 2024-01-26 11:23 Adhemerval Zanella
  2024-01-26 12:02 ` Florian Weimer
  2024-02-09 17:54 ` Aurelien Jarno
  0 siblings, 2 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2024-01-26 11:23 UTC (permalink / raw)
  To: libc-alpha; +Cc: Aurelien Jarno

When running the testsuite in parallel, for instance running make -j
$(nproc) check, occasionally tst-epoll fails with a timeout.  It happens
because it sometimes takes a bit more than 10ms for the process to get
cloned and blocked by the syscall.  In that case the signal is
sent to early, and the test fails with a timeout.

Checked on x86_64-linux-gnu.
---
 sysdeps/unix/sysv/linux/tst-epoll.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/tst-epoll.c b/sysdeps/unix/sysv/linux/tst-epoll.c
index 3b38beae6e..545f506faa 100644
--- a/sysdeps/unix/sysv/linux/tst-epoll.c
+++ b/sysdeps/unix/sysv/linux/tst-epoll.c
@@ -22,7 +22,7 @@
 #include <support/support.h>
 #include <support/xsignal.h>
 #include <support/xunistd.h>
-#include <support/xtime.h>
+#include <support/process_state.h>
 #include <stdlib.h>
 #include <sys/epoll.h>
 
@@ -97,8 +97,8 @@ test_epoll_basic (epoll_wait_check_t epoll_wait_check)
   xclose (fds[0][0]);
   xclose (fds[1][1]);
 
-  /* Wait some time so child is blocked on the syscall.  */
-  nanosleep (&(struct timespec) {0, 10000000}, NULL);
+  /* Wait until child is blocked on epoll_wait.  */
+  support_process_state_wait (p, support_process_state_sleeping);
   TEST_COMPARE (kill (p, SIGUSR1), 0);
 
   int e = epoll_wait_check (efd, &event, 1, 500000000, &ss);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] misc: tst-poll: Proper synchronize with child before sending the signal
  2024-01-26 11:23 [PATCH] misc: tst-poll: Proper synchronize with child before sending the signal Adhemerval Zanella
@ 2024-01-26 12:02 ` Florian Weimer
  2024-02-09 17:54 ` Aurelien Jarno
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2024-01-26 12:02 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Aurelien Jarno

* Adhemerval Zanella:

> When running the testsuite in parallel, for instance running make -j
> $(nproc) check, occasionally tst-epoll fails with a timeout.  It happens
> because it sometimes takes a bit more than 10ms for the process to get
> cloned and blocked by the syscall.  In that case the signal is
> sent to early, and the test fails with a timeout.
>
> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/unix/sysv/linux/tst-epoll.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/tst-epoll.c b/sysdeps/unix/sysv/linux/tst-epoll.c
> index 3b38beae6e..545f506faa 100644
> --- a/sysdeps/unix/sysv/linux/tst-epoll.c
> +++ b/sysdeps/unix/sysv/linux/tst-epoll.c
> @@ -22,7 +22,7 @@
>  #include <support/support.h>
>  #include <support/xsignal.h>
>  #include <support/xunistd.h>
> -#include <support/xtime.h>
> +#include <support/process_state.h>
>  #include <stdlib.h>
>  #include <sys/epoll.h>
>  
> @@ -97,8 +97,8 @@ test_epoll_basic (epoll_wait_check_t epoll_wait_check)
>    xclose (fds[0][0]);
>    xclose (fds[1][1]);
>  
> -  /* Wait some time so child is blocked on the syscall.  */
> -  nanosleep (&(struct timespec) {0, 10000000}, NULL);
> +  /* Wait until child is blocked on epoll_wait.  */
> +  support_process_state_wait (p, support_process_state_sleeping);
>    TEST_COMPARE (kill (p, SIGUSR1), 0);
>  
>    int e = epoll_wait_check (efd, &event, 1, 500000000, &ss);

Looks okay.  I don't see any blocking system calls between the fork and
the epoll_wait call.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] misc: tst-poll: Proper synchronize with child before sending the signal
  2024-01-26 11:23 [PATCH] misc: tst-poll: Proper synchronize with child before sending the signal Adhemerval Zanella
  2024-01-26 12:02 ` Florian Weimer
@ 2024-02-09 17:54 ` Aurelien Jarno
  1 sibling, 0 replies; 3+ messages in thread
From: Aurelien Jarno @ 2024-02-09 17:54 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On 2024-01-26 08:23, Adhemerval Zanella wrote:
> When running the testsuite in parallel, for instance running make -j
> $(nproc) check, occasionally tst-epoll fails with a timeout.  It happens
> because it sometimes takes a bit more than 10ms for the process to get
> cloned and blocked by the syscall.  In that case the signal is
> sent to early, and the test fails with a timeout.
> 
> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/unix/sysv/linux/tst-epoll.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/tst-epoll.c b/sysdeps/unix/sysv/linux/tst-epoll.c
> index 3b38beae6e..545f506faa 100644
> --- a/sysdeps/unix/sysv/linux/tst-epoll.c
> +++ b/sysdeps/unix/sysv/linux/tst-epoll.c
> @@ -22,7 +22,7 @@
>  #include <support/support.h>
>  #include <support/xsignal.h>
>  #include <support/xunistd.h>
> -#include <support/xtime.h>
> +#include <support/process_state.h>
>  #include <stdlib.h>
>  #include <sys/epoll.h>
>  
> @@ -97,8 +97,8 @@ test_epoll_basic (epoll_wait_check_t epoll_wait_check)
>    xclose (fds[0][0]);
>    xclose (fds[1][1]);
>  
> -  /* Wait some time so child is blocked on the syscall.  */
> -  nanosleep (&(struct timespec) {0, 10000000}, NULL);
> +  /* Wait until child is blocked on epoll_wait.  */
> +  support_process_state_wait (p, support_process_state_sleeping);
>    TEST_COMPARE (kill (p, SIGUSR1), 0);
>  
>    int e = epoll_wait_check (efd, &event, 1, 500000000, &ss);

Thanks for working on the patch and sorry for taking so long to test
it. There is a minor typo on the subject (poll -> epoll), but otherwise
works as expected, so:

Tested-by: Aurelien Jarno <aurelien@aurel32.net> 

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-09 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 11:23 [PATCH] misc: tst-poll: Proper synchronize with child before sending the signal Adhemerval Zanella
2024-01-26 12:02 ` Florian Weimer
2024-02-09 17:54 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).