selftests/uffd: Allow EINTR/EAGAIN
Subsystems (2)
PATCH 1/1 selftests/uffd: Allow EINTR/EAGAIN
This allow test to continue with interruptions like gdb.
Signed-off-by Peter Xu <[email protected]>
--- tools/testing/selftests/vm/userfaultfd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/vm/userfaultfd.c +5 -2
@@ -644,7 +644,7 @@ static int uffd_read_msg(int ufd, struct uffd_msg *msg)if (ret !=sizeof (*msg)) {if (ret <0 ) { -if (errno ==EAGAIN ) +if (errno ==EAGAIN || errno ==EINTR )return 1 ;err ("blocking read error" ); }else {
@@ -720,8 +720,11 @@ static void *uffd_poll_thread(void *arg)for (;;) { ret =poll (pollfd,2 ,-1 ); -if (ret <=0 ) +if (ret <=0 ) { +if (errno ==EINTR || errno ==EAGAIN ) +continue ;err ("poll error: %d" , ret); + }if (pollfd[1 ].revents &POLLIN ) {if (read (pollfd[1 ].fd, &tmp_chr,1 ) !=1 )err ("read pipefd error" );
Signature · 1 line
2.32.0
Looks correct to me!
Reviewed-by Axel Rasmussen <[email protected]>
Quoted 37 lines · Peter Xu
This allow test to continue with interruptions like gdb.
Signed-off-by Peter Xu <[email protected]>--- tools/testing/selftests/vm/userfaultfd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)tools/testing/selftests/vm/userfaultfd.c +5
-3@@ -644,7 +644,7 @@ static int uffd_read_msg(int ufd, struct uffd_msg *msg)if (ret !=sizeof (*msg)) {if (ret <0 ) { -if (errno ==EAGAIN ) +if (errno ==EAGAIN || errno ==EINTR )return 1 ;err ("blocking read error" ); }else {@@ -720,8 +720,11 @@ static void *uffd_poll_thread(void *arg)for (;;) { ret =poll (pollfd,2 ,-1 ); -if (ret <=0 ) +if (ret <=0 ) { +if (errno ==EINTR || errno ==EAGAIN ) +continue ;err ("poll error: %d" , ret); + }if (pollfd[1 ].revents &POLLIN ) {if (read (pollfd[1 ].fd, &tmp_chr,1 ) !=1 )err ("read pipefd error" ); --2.32.0