linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: clarify common error when running gup_test
@ 2022-05-02 22:49 Joel Savitz
  2022-05-07 21:26 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Savitz @ 2022-05-02 22:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Savitz, Andrew Morton, Shuah Khan, Nico Pache, linux-mm,
	linux-kselftest


The gup_test binary will fail showing only the output of perror("open") in
the case that /sys/kernel/debug/gup_test is not found. This will almost
always be due to CONFIG_GUP_TEST not being set, which enables
compilation of a kernel that provides this file.

Add a short error message to clarify this failure and point the user to
the solution.

Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
 tools/testing/selftests/vm/gup_test.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/gup_test.c b/tools/testing/selftests/vm/gup_test.c
index cda837a14736..ac4e804d47f0 100644
--- a/tools/testing/selftests/vm/gup_test.c
+++ b/tools/testing/selftests/vm/gup_test.c
@@ -18,6 +18,8 @@
 #define FOLL_WRITE	0x01	/* check pte is writable */
 #define FOLL_TOUCH	0x02	/* mark page accessed */
 
+#define GUP_TEST_FILE "/sys/kernel/debug/gup_test"
+
 static unsigned long cmd = GUP_FAST_BENCHMARK;
 static int gup_fd, repeats = 1;
 static unsigned long size = 128 * MB;
@@ -204,9 +206,11 @@ int main(int argc, char **argv)
 	if (write)
 		gup.gup_flags |= FOLL_WRITE;
 
-	gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
+	gup_fd = open(GUP_TEST_FILE, O_RDWR);
 	if (gup_fd == -1) {
 		perror("open");
+		fprintf(stderr, "Unable to open %s: check that CONFIG_GUP_TEST=y\n",
+				GUP_TEST_FILE);
 		exit(1);
 	}
 
-- 
2.27.0


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

* Re: [PATCH] selftests: clarify common error when running gup_test
  2022-05-02 22:49 [PATCH] selftests: clarify common error when running gup_test Joel Savitz
@ 2022-05-07 21:26 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2022-05-07 21:26 UTC (permalink / raw)
  To: Joel Savitz
  Cc: linux-kernel, Shuah Khan, Nico Pache, linux-mm, linux-kselftest,
	Sidhartha Kumar

On Mon,  2 May 2022 18:49:42 -0400 Joel Savitz <jsavitz@redhat.com> wrote:

> 
> The gup_test binary will fail showing only the output of perror("open") in
> the case that /sys/kernel/debug/gup_test is not found. This will almost
> always be due to CONFIG_GUP_TEST not being set, which enables
> compilation of a kernel that provides this file.
> 
> Add a short error message to clarify this failure and point the user to
> the solution.
> 
> --- a/tools/testing/selftests/vm/gup_test.c
> +++ b/tools/testing/selftests/vm/gup_test.c
> @@ -18,6 +18,8 @@
>  #define FOLL_WRITE	0x01	/* check pte is writable */
>  #define FOLL_TOUCH	0x02	/* mark page accessed */
>  
> +#define GUP_TEST_FILE "/sys/kernel/debug/gup_test"
> +
>  static unsigned long cmd = GUP_FAST_BENCHMARK;
>  static int gup_fd, repeats = 1;
>  static unsigned long size = 128 * MB;
> @@ -204,9 +206,11 @@ int main(int argc, char **argv)
>  	if (write)
>  		gup.gup_flags |= FOLL_WRITE;
>  
> -	gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
> +	gup_fd = open(GUP_TEST_FILE, O_RDWR);
>  	if (gup_fd == -1) {
>  		perror("open");
> +		fprintf(stderr, "Unable to open %s: check that CONFIG_GUP_TEST=y\n",
> +				GUP_TEST_FILE);
>  		exit(1);
>  	}
>  

Sidhartha did a similar thing:
https://lkml.kernel.org/r/20220405214809.3351223-1-sidhartha.kumar@oracle.com

(Which is now in mm-stable at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm)

Although in retroreview, it should have printed that to stderr rather
than to stdout.


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

end of thread, other threads:[~2022-05-07 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 22:49 [PATCH] selftests: clarify common error when running gup_test Joel Savitz
2022-05-07 21:26 ` Andrew Morton

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).