All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/uffd: Allow EINTR/EAGAIN
@ 2021-11-15 13:52 Peter Xu
  2021-11-15 17:30 ` Axel Rasmussen
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Xu @ 2021-11-15 13:52 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Andrea Arcangeli, peterx, Nadav Amit, Andrew Morton, Axel Rasmussen

This allow test to continue with interruptions like gdb.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 tools/testing/selftests/vm/userfaultfd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index 8a09057d2f22..64845be3971d 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -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


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

* Re: [PATCH] selftests/uffd: Allow EINTR/EAGAIN
  2021-11-15 13:52 [PATCH] selftests/uffd: Allow EINTR/EAGAIN Peter Xu
@ 2021-11-15 17:30 ` Axel Rasmussen
  0 siblings, 0 replies; 2+ messages in thread
From: Axel Rasmussen @ 2021-11-15 17:30 UTC (permalink / raw)
  To: Peter Xu
  Cc: linux-mm, linux-kernel, Andrea Arcangeli, Nadav Amit, Andrew Morton

Looks correct to me!

Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>

On Mon, Nov 15, 2021 at 5:52 AM Peter Xu <peterx@redhat.com> wrote:
>
> This allow test to continue with interruptions like gdb.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  tools/testing/selftests/vm/userfaultfd.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
> index 8a09057d2f22..64845be3971d 100644
> --- a/tools/testing/selftests/vm/userfaultfd.c
> +++ b/tools/testing/selftests/vm/userfaultfd.c
> @@ -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
>

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

end of thread, other threads:[~2021-11-15 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 13:52 [PATCH] selftests/uffd: Allow EINTR/EAGAIN Peter Xu
2021-11-15 17:30 ` Axel Rasmussen

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.