linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] userfaultfd: selftests: Small fixes
@ 2020-12-08  2:47 Peter Xu
  2020-12-08  2:47 ` [PATCH 1/3] userfaultfd/selftests: Always dump something in modes Peter Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Xu @ 2020-12-08  2:47 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Andrea Arcangeli, Andrew Morton, peterx, Mike Rapoport

There're some very trivial fixes that I kept locally to userfaultfd selftest
program.  Please have a look, thanks.

Peter Xu (3):
  userfaultfd/selftests: Always dump something in modes
  userfaultfd/selftests: Fix retval check for userfaultfd_open()
  userfaultfd/selftests: Hint the test runner on required privilege

 tools/testing/selftests/vm/userfaultfd.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

-- 
2.26.2




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

* [PATCH 1/3] userfaultfd/selftests: Always dump something in modes
  2020-12-08  2:47 [PATCH 0/3] userfaultfd: selftests: Small fixes Peter Xu
@ 2020-12-08  2:47 ` Peter Xu
  2020-12-08  2:47 ` [PATCH 2/3] userfaultfd/selftests: Fix retval check for userfaultfd_open() Peter Xu
  2020-12-08  2:47 ` [PATCH 3/3] userfaultfd/selftests: Hint the test runner on required privilege Peter Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2020-12-08  2:47 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Andrea Arcangeli, Andrew Morton, peterx, Mike Rapoport

BOUNCE_POLL is a special bit that if cleared it means "READ" instead.  Dump
that too otherwise we'll see tests with empty modes.

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

diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index 61e5cfeb1350..31f470d12d0b 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -1230,6 +1230,8 @@ static int userfaultfd_stress(void)
 			printf(" ver");
 		if (bounces & BOUNCE_POLL)
 			printf(" poll");
+		else
+			printf(" read");
 		printf(", ");
 		fflush(stdout);
 
-- 
2.26.2



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

* [PATCH 2/3] userfaultfd/selftests: Fix retval check for userfaultfd_open()
  2020-12-08  2:47 [PATCH 0/3] userfaultfd: selftests: Small fixes Peter Xu
  2020-12-08  2:47 ` [PATCH 1/3] userfaultfd/selftests: Always dump something in modes Peter Xu
@ 2020-12-08  2:47 ` Peter Xu
  2020-12-08  2:47 ` [PATCH 3/3] userfaultfd/selftests: Hint the test runner on required privilege Peter Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2020-12-08  2:47 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Andrea Arcangeli, Andrew Morton, peterx, Mike Rapoport

userfaultfd_open() returns 1 for errors rather than negatives.  Fix it on all
the callers so when UFFDIO_API failed the test will bail out.

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

diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index 31f470d12d0b..f0647bfda366 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -993,7 +993,7 @@ static int userfaultfd_zeropage_test(void)
 	if (uffd_test_ops->release_pages(area_dst))
 		return 1;
 
-	if (userfaultfd_open(0) < 0)
+	if (userfaultfd_open(0))
 		return 1;
 	uffdio_register.range.start = (unsigned long) area_dst;
 	uffdio_register.range.len = nr_pages * page_size;
@@ -1038,7 +1038,7 @@ static int userfaultfd_events_test(void)
 
 	features = UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_EVENT_REMAP |
 		UFFD_FEATURE_EVENT_REMOVE;
-	if (userfaultfd_open(features) < 0)
+	if (userfaultfd_open(features))
 		return 1;
 	fcntl(uffd, F_SETFL, uffd_flags | O_NONBLOCK);
 
@@ -1101,7 +1101,7 @@ static int userfaultfd_sig_test(void)
 		return 1;
 
 	features = UFFD_FEATURE_EVENT_FORK|UFFD_FEATURE_SIGBUS;
-	if (userfaultfd_open(features) < 0)
+	if (userfaultfd_open(features))
 		return 1;
 	fcntl(uffd, F_SETFL, uffd_flags | O_NONBLOCK);
 
@@ -1170,7 +1170,7 @@ static int userfaultfd_stress(void)
 	if (!area_dst)
 		return 1;
 
-	if (userfaultfd_open(0) < 0)
+	if (userfaultfd_open(0))
 		return 1;
 
 	count_verify = malloc(nr_pages * sizeof(unsigned long long));
-- 
2.26.2



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

* [PATCH 3/3] userfaultfd/selftests: Hint the test runner on required privilege
  2020-12-08  2:47 [PATCH 0/3] userfaultfd: selftests: Small fixes Peter Xu
  2020-12-08  2:47 ` [PATCH 1/3] userfaultfd/selftests: Always dump something in modes Peter Xu
  2020-12-08  2:47 ` [PATCH 2/3] userfaultfd/selftests: Fix retval check for userfaultfd_open() Peter Xu
@ 2020-12-08  2:47 ` Peter Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2020-12-08  2:47 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Andrea Arcangeli, Andrew Morton, peterx, Mike Rapoport

Now userfaultfd test program requires either root or ptrace privilege due to
the signal/event tests.  When UFFDIO_API failed, hint the test runner about
this fact verbosely.

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

diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index f0647bfda366..27a1709099d0 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -755,7 +755,8 @@ static int userfaultfd_open(int features)
 	uffdio_api.api = UFFD_API;
 	uffdio_api.features = features;
 	if (ioctl(uffd, UFFDIO_API, &uffdio_api)) {
-		fprintf(stderr, "UFFDIO_API\n");
+		fprintf(stderr, "UFFDIO_API failed.\nPlease make sure to "
+			"run with either root or ptrace capability.\n");
 		return 1;
 	}
 	if (uffdio_api.api != UFFD_API) {
-- 
2.26.2



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

end of thread, other threads:[~2020-12-08  2:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08  2:47 [PATCH 0/3] userfaultfd: selftests: Small fixes Peter Xu
2020-12-08  2:47 ` [PATCH 1/3] userfaultfd/selftests: Always dump something in modes Peter Xu
2020-12-08  2:47 ` [PATCH 2/3] userfaultfd/selftests: Fix retval check for userfaultfd_open() Peter Xu
2020-12-08  2:47 ` [PATCH 3/3] userfaultfd/selftests: Hint the test runner on required privilege Peter Xu

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 NNTP newsgroup(s).