<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 29, 2022 at 1:40 PM Yang Xu <<a href="mailto:xuyang2018.jy@fujitsu.com">xuyang2018.jy@fujitsu.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Like namespaces_constants.h, kernel doesn't have<br>
clone.h header. We can also move it into here.<br>
<br>
Signed-off-by: Yang Xu <<a href="mailto:xuyang2018.jy@fujitsu.com" target="_blank">xuyang2018.jy@fujitsu.com</a>><br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
This patch has been verified on my ltp fork[1].<br>
[1]<a href="https://github.com/xuyang0410/ltp/actions/runs/3571298308/jobs/6003048080" rel="noreferrer" target="_blank">https://github.com/xuyang0410/ltp/actions/runs/3571298308/jobs/6003048080</a><br>
 include/lapi/clone.h                          | 56 -------------------<br>
 include/lapi/sched.h                          | 31 ++++++++++<br>
 lib/tst_clone.c                               |  2 +-<br>
 testcases/kernel/containers/pidns/pidns13.c   |  2 +-<br>
 testcases/kernel/containers/userns/userns08.c |  2 +-<br>
 testcases/kernel/syscalls/clone3/clone301.c   |  2 +-<br>
 testcases/kernel/syscalls/clone3/clone302.c   |  2 +-<br>
 .../syscalls/close_range/close_range01.c      |  2 +-<br>
 .../syscalls/close_range/close_range02.c      |  2 +-<br>
 9 files changed, 38 insertions(+), 63 deletions(-)<br>
 delete mode 100644 include/lapi/clone.h<br>
<br>
diff --git a/include/lapi/clone.h b/include/lapi/clone.h<br>
deleted file mode 100644<br>
index 437d1376f..000000000<br>
--- a/include/lapi/clone.h<br>
+++ /dev/null<br>
@@ -1,56 +0,0 @@<br>
-// SPDX-License-Identifier: GPL-2.0-or-later<br>
-/*<br>
- * Copyright (c) 2020 Linaro Limited. All rights reserved.<br>
- * Author: Viresh Kumar <<a href="mailto:viresh.kumar@linaro.org" target="_blank">viresh.kumar@linaro.org</a>><br>
- */<br>
-<br>
-#ifndef LAPI_CLONE_H__<br>
-#define LAPI_CLONE_H__<br>
-<br>
-#include <sys/syscall.h><br>
-#include <linux/types.h><br>
-#include <sched.h><br>
-#include <stdint.h><br>
-<br>
-#include "config.h"<br>
-#include "lapi/syscalls.h"<br>
-<br>
-#ifndef HAVE_CLONE3<br>
-struct clone_args {<br>
-       uint64_t __attribute__((aligned(8))) flags;<br>
-       uint64_t __attribute__((aligned(8))) pidfd;<br>
-       uint64_t __attribute__((aligned(8))) child_tid;<br>
-       uint64_t __attribute__((aligned(8))) parent_tid;<br>
-       uint64_t __attribute__((aligned(8))) exit_signal;<br>
-       uint64_t __attribute__((aligned(8))) stack;<br>
-       uint64_t __attribute__((aligned(8))) stack_size;<br>
-       uint64_t __attribute__((aligned(8))) tls;<br>
-};<br>
-<br>
-static inline int clone3(struct clone_args *args, size_t size)<br>
-{<br>
-       return tst_syscall(__NR_clone3, args, size);<br>
-}<br>
-#endif<br>
-<br>
-#ifndef CLONE_PIDFD<br>
-#define CLONE_PIDFD    0x00001000      /* set if a pidfd should be placed in parent */<br>
-#endif<br>
-<br>
-#ifndef CLONE_NEWUSER<br>
-# define CLONE_NEWUSER 0x10000000<br>
-#endif<br>
-<br>
-static inline void clone3_supported_by_kernel(void)<br>
-{<br>
-       long ret;<br>
-<br>
-       if ((tst_kvercmp(5, 3, 0)) < 0) {<br>
-               /* Check if the syscall is backported on an older kernel */<br>
-               ret = syscall(__NR_clone3, NULL, 0);<br>
-               if (ret == -1 && errno == ENOSYS)<br>
-                       tst_brk(TCONF, "Test not supported on kernel version < v5.3");<br>
-       }<br>
-}<br>
-<br>
-#endif /* LAPI_CLONE_H__ */<br>
diff --git a/include/lapi/sched.h b/include/lapi/sched.h<br>
index 3b0b4be31..1d22a9d7e 100644<br>
--- a/include/lapi/sched.h<br>
+++ b/include/lapi/sched.h<br>
@@ -11,6 +11,7 @@<br>
 #include <unistd.h><br>
 #include <stdint.h><br>
 #include <inttypes.h><br>
+#include "config.h"<br>
 #include "lapi/syscalls.h"<br>
<br>
 struct sched_attr {<br>
@@ -43,6 +44,32 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,<br>
        return syscall(__NR_sched_getattr, pid, attr, size, flags);<br>
 }<br>
<br>
+#ifndef HAVE_CLONE3<br>
+struct clone_args {<br>
+       uint64_t __attribute__((aligned(8))) flags;<br>
+       uint64_t __attribute__((aligned(8))) pidfd;<br>
+       uint64_t __attribute__((aligned(8))) child_tid;<br>
+       uint64_t __attribute__((aligned(8))) parent_tid;<br>
+       uint64_t __attribute__((aligned(8))) exit_signal;<br>
+       uint64_t __attribute__((aligned(8))) stack;<br>
+       uint64_t __attribute__((aligned(8))) stack_size;<br>
+       uint64_t __attribute__((aligned(8))) tls;<br>
+};<br>
+<br>
+static inline int clone3(struct clone_args *args, size_t size)<br>
+{<br>
+       return tst_syscall(__NR_clone3, args, size);<br>
+}<br>
+#endif<br>
+<br>
+static inline void clone3_supported_by_kernel(void)<br>
+{<br>
+       if ((tst_kvercmp(5, 3, 0)) < 0) {<br>
+               /* Check if the syscall is backported on an older kernel */<br>
+               tst_syscall(__NR_clone3, NULL, 0);<br>
+       }<br>
+}<br>
+<br>
 #ifndef SCHED_DEADLINE<br>
 # define SCHED_DEADLINE        6<br>
 #endif<br>
@@ -55,6 +82,10 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,<br>
 # define CLONE_FS      0x00000200<br>
 #endif<br>
<br>
+#ifndef CLONE_PIDFD<br>
+# define CLONE_PIDFD   0x00001000<br>
+#endif<br>
+<br>
 #ifndef CLONE_NEWNS<br>
 # define CLONE_NEWNS   0x00020000<br>
 #endif<br>
diff --git a/lib/tst_clone.c b/lib/tst_clone.c<br>
index 07e7f0767..ecc84408c 100644<br>
--- a/lib/tst_clone.c<br>
+++ b/lib/tst_clone.c<br>
@@ -8,7 +8,7 @@<br>
 #include <stddef.h><br>
<br>
 #include "tst_test.h"<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
<br>
 pid_t tst_clone(const struct tst_clone_args *tst_args)<br>
 {<br>
diff --git a/testcases/kernel/containers/pidns/pidns13.c b/testcases/kernel/containers/pidns/pidns13.c<br>
index 39fd6df7f..6a155027c 100644<br>
--- a/testcases/kernel/containers/pidns/pidns13.c<br>
+++ b/testcases/kernel/containers/pidns/pidns13.c<br>
@@ -31,7 +31,7 @@<br>
<br>
 #include "tst_test.h"<br>
 #include "tst_clone.h"<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
<br>
 static int pipe_fd[2];<br>
<br>
diff --git a/testcases/kernel/containers/userns/userns08.c b/testcases/kernel/containers/userns/userns08.c<br>
index afdad6cad..2697d874b 100644<br>
--- a/testcases/kernel/containers/userns/userns08.c<br>
+++ b/testcases/kernel/containers/userns/userns08.c<br>
@@ -25,7 +25,7 @@<br>
<br>
 #include "tst_test.h"<br>
 #include "tst_clone.h"<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
 #include "tst_safe_file_at.h"<br>
<br>
 static pid_t clone_newuser(void)<br>
diff --git a/testcases/kernel/syscalls/clone3/clone301.c b/testcases/kernel/syscalls/clone3/clone301.c<br>
index f7ef0b2d7..d0fadbc5d 100644<br>
--- a/testcases/kernel/syscalls/clone3/clone301.c<br>
+++ b/testcases/kernel/syscalls/clone3/clone301.c<br>
@@ -15,7 +15,7 @@<br>
 #include <sys/wait.h><br>
<br>
 #include "tst_test.h"<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
 #include "lapi/pidfd.h"<br>
<br>
 #define CHILD_SIGNAL   SIGUSR1<br>
diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c<br>
index 08d6417ce..b1b4ccebb 100644<br>
--- a/testcases/kernel/syscalls/clone3/clone302.c<br>
+++ b/testcases/kernel/syscalls/clone3/clone302.c<br>
@@ -14,7 +14,7 @@<br>
 #include <stdlib.h><br>
<br>
 #include "tst_test.h"<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
<br>
 static struct clone_args *valid_args, *invalid_args;<br>
 unsigned long stack;<br>
diff --git a/testcases/kernel/syscalls/close_range/close_range01.c b/testcases/kernel/syscalls/close_range/close_range01.c<br>
index 5e2de4d1e..30bb600b6 100644<br>
--- a/testcases/kernel/syscalls/close_range/close_range01.c<br>
+++ b/testcases/kernel/syscalls/close_range/close_range01.c<br>
@@ -28,7 +28,7 @@<br>
 #include "tst_test.h"<br>
 #include "tst_clone.h"<br>
<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
 #include "lapi/close_range.h"<br>
<br>
 static int fd[3];<br>
diff --git a/testcases/kernel/syscalls/close_range/close_range02.c b/testcases/kernel/syscalls/close_range/close_range02.c<br>
index bd46936bb..aec899261 100644<br>
--- a/testcases/kernel/syscalls/close_range/close_range02.c<br>
+++ b/testcases/kernel/syscalls/close_range/close_range02.c<br>
@@ -18,7 +18,7 @@<br>
 #include "tst_clone.h"<br>
 #include "lapi/fcntl.h"<br>
 #include "lapi/close_range.h"<br>
-#include "lapi/clone.h"<br>
+#include "lapi/sched.h"<br>
<br>
 static int try_close_range(int fd, int flags)<br>
 {<br>
-- <br>
2.23.0<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>