On Thu,  2 Apr 2026 09:45:37 +0800 Chunyu Hu <[email protected]> wrote:

> There are several tests requires transprarent hugepages, when run on thp
> disabled kernel such as realtime kernel, there will be false negative.
> Mark those tests as skip when thp is not available.

Thanks, I updated mm.git's mm-unstable branch to this version.

> Changes in v8:
>   - removed the patch 4 in v7 (make ksft_exit_fail_perror variable length)
>     as no clean way to do it at the moment and ksft_exit_fail_msg could
>     do by printing an extra strerror param.
>   - patch 4 use ksft_exit_fail_msg instead of ksft_exit_fail_perror  

Below is how v8 altered mm.git:


 tools/testing/selftests/kselftest.h  |   21 +++------------------
 tools/testing/selftests/mm/vm_util.c |    6 +++---
 2 files changed, 6 insertions(+), 21 deletions(-)

--- a/tools/testing/selftests/kselftest.h~b
+++ a/tools/testing/selftests/kselftest.h
@@ -43,7 +43,7 @@
  * the program is aborting before finishing all tests):
  *
  *    ksft_exit_fail_msg(fmt, ...);
- *    ksft_exit_fail_perror(fmt, ...);
+ *    ksft_exit_fail_perror(msg);
  *
  */
 #ifndef __KSELFTEST_H
@@ -417,24 +417,9 @@ static inline __noreturn __printf(1, 2)
        exit(KSFT_FAIL);
 }
 
-static inline __noreturn __printf(1, 2) void ksft_exit_fail_perror(const char 
*msg, ...)
+static inline __noreturn void ksft_exit_fail_perror(const char *msg)
 {
-       va_list args;
-       char *buf = NULL;
-       int saved_errno = errno;
-
-       va_start(args, msg);
-       if (vasprintf(&buf, msg, args) == -1) {
-               va_end(args);
-               ksft_exit_fail_msg("vasprintf failed: %s (%d)\n", 
strerror(saved_errno),
-                               saved_errno);
-       }
-       va_end(args);
-
-       errno = saved_errno;
-       ksft_exit_fail_msg("%s: %s (%d)\n", buf, strerror(errno), errno);
-
-       free(buf);
+       ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
 }
 
 static inline __noreturn void ksft_exit_xfail(void)
--- a/tools/testing/selftests/mm/vm_util.c~b
+++ a/tools/testing/selftests/mm/vm_util.c
@@ -775,15 +775,15 @@ void write_file(const char *path, const
 
        fd = open(path, O_WRONLY);
        if (fd == -1)
-               ksft_exit_fail_perror("%s open failed", path);
+               ksft_exit_fail_msg("%s open failed: %s\n", path, 
strerror(errno));
 
        numwritten = write(fd, buf, buflen - 1);
        saved_errno = errno;
        close(fd);
        errno = saved_errno;
        if (numwritten < 0)
-               ksft_exit_fail_perror("%s write(%.*s) failed", path, 
(int)(buflen - 1),
-                               buf);
+               ksft_exit_fail_msg("%s write(%.*s) failed: %s\n", path, 
(int)(buflen - 1),
+                               buf, strerror(errno));
        if (numwritten != buflen - 1)
                ksft_exit_fail_msg("%s write(%.*s) is truncated, expected %zu 
bytes, got %zd bytes\n",
                                path, (int)(buflen - 1), buf, buflen - 1, 
numwritten);
_


Reply via email to