selftests: clarify common error when running gup_test
Subsystems (2)
PATCH 1/1 selftests: clarify common error when running gup_test
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.
--- tools/testing/selftests/vm/gup_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/vm/gup_test.c +5 -1
@@ -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 ); }
Signature · 1 line
2.27.0
Andrew Morton
maintainerQuoted 23 lines · On Mon, 2 May 2022 18:49:42 -0400 Joel Savitz <[email protected]> wrote:
The
gup_testbinary will fail showing only the output ofperror("open")in the case that/sys/kernel/debug/gup_testis not found. This will almost always be due toCONFIG_GUP_TESTnot 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.
tools/testing/selftests/vm/gup_test.c +2
-0@@ -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 ;
tools/testing/selftests/vm/gup_test.c int main(int argc, char **argv) · line 216
Quoted 10 lines
tools/testing/selftests/vm/gup_test.c +3
-1- 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/[email protected]
(Which is now in mm-stable atgit://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm)
Although in retroreview, it should have printed that to stderr rather than to stdout.