[LTP] [PATCH] Update clone3 wrapper signature
Li Wang
liwang@redhat.com
Fri Mar 20 04:13:36 CET 2026
On Thu, Mar 19, 2026 at 11:54:55AM -0700, Chris Wailes via ltp wrote:
> This CL adds the `ltp_clone3_raw` wrapper for direct testing of the
> syscall, conditionally defines `clone_args_minimal`, and adds a
> `ltp_clone3` wrapper for libc implementations that provide `clone3`.
When you signed off patch better to use 'git commit -sm "xxx"'
otherwise patch has no signature:
Signed-off-by: Chris Wailes <chriswailes@google.com>
Also, the next patch version better to have "v2" keywords:
git format-patch --subject-prefix="PATCH v2" -1
add notes like "v2: blablabla..." via:
git notes add
> ---
> include/lapi/sched.h | 27 +++++++++++++++------
> testcases/kernel/syscalls/clone3/clone301.c | 2 +-
> testcases/kernel/syscalls/clone3/clone302.c | 2 +-
> 3 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/include/lapi/sched.h b/include/lapi/sched.h
> index 36f1ecad9..fc367f772 100644
> --- a/include/lapi/sched.h
> +++ b/include/lapi/sched.h
> @@ -49,8 +49,7 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
> # define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
> #endif
>
> -#ifndef HAVE_CLONE3
> -struct clone_args {
> +struct clone_args_minimal {
> uint64_t __attribute__((aligned(8))) flags;
> uint64_t __attribute__((aligned(8))) pidfd;
> uint64_t __attribute__((aligned(8))) child_tid;
> @@ -59,12 +58,10 @@ struct clone_args {
> uint64_t __attribute__((aligned(8))) stack;
> uint64_t __attribute__((aligned(8))) stack_size;
> uint64_t __attribute__((aligned(8))) tls;
> - uint64_t __attribute__((aligned(8))) set_tid;
> - uint64_t __attribute__((aligned(8))) set_tid_size;
> - uint64_t __attribute__((aligned(8))) cgroup;
> };
>
> -struct clone_args_minimal {
> +#ifndef HAVE_CLONE_ARGS
In LTP, these HAVE_* macros are typically generated by the configure
script (autoconf). The configure script checks for the existence of
types, functions, and headers in the system, and defines corresponding
macros in config.h.
But here you use a non_exist HAVE_CLONE_ARGS, I think we should to
use HAVE_CLONE3 or add struct clone_args check there(then we can
use HAVE_STRUCT_CLONE_ARGS).
See: ltp/configure.ac
> +struct clone_args {
> uint64_t __attribute__((aligned(8))) flags;
> uint64_t __attribute__((aligned(8))) pidfd;
> uint64_t __attribute__((aligned(8))) child_tid;
> @@ -73,12 +70,28 @@ struct clone_args_minimal {
> uint64_t __attribute__((aligned(8))) stack;
> uint64_t __attribute__((aligned(8))) stack_size;
> uint64_t __attribute__((aligned(8))) tls;
> + uint64_t __attribute__((aligned(8))) set_tid;
> + uint64_t __attribute__((aligned(8))) set_tid_size;
> + uint64_t __attribute__((aligned(8))) cgroup;
> };
> +#endif
>
> -static inline int clone3(struct clone_args *args, size_t size)
> +static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
> {
> return tst_syscall(__NR_clone3, args, size);
> }
> +
> +#ifdef HAVE_CLONE3_WRAPPER
Here as well.
You can check with:
grep -r "HAVE_CLONE3_WRAPPER" configure.ac m4/ include/config.h.in
before using unsure macros.
> +static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
> + int (*fn)(void *), void *arg) {
> + return clone3(cl_args, size, fn, arg);
> +}
> +#else
> +static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
> + int (*fn)(void *), void *arg)
> +{
> + return -1;
> +}
> #endif
>
> static inline void clone3_supported_by_kernel(void)
> diff --git a/testcases/kernel/syscalls/clone3/clone301.c b/testcases/kernel/syscalls/clone3/clone301.c
> index deed30b9f..58fc1702e 100644
> --- a/testcases/kernel/syscalls/clone3/clone301.c
> +++ b/testcases/kernel/syscalls/clone3/clone301.c
> @@ -123,7 +123,7 @@ static void run(unsigned int n)
> parent_received_signal = 0;
> SAFE_SIGACTION(tc->exit_signal, &psig_action, NULL);
>
> - TEST(pid = clone3(args, sizeof(*args)));
> + TEST(pid = ltp_clone3_raw(args, sizeof(*args)));
> if (pid < 0) {
> tst_res(TFAIL | TTERRNO, "clone3() failed (%d)", n);
> return;
> diff --git a/testcases/kernel/syscalls/clone3/clone302.c b/testcases/kernel/syscalls/clone3/clone302.c
> index 9e98f1954..883112183 100644
> --- a/testcases/kernel/syscalls/clone3/clone302.c
> +++ b/testcases/kernel/syscalls/clone3/clone302.c
We need to modify it in clone304.c as well.
The rest part looks good.
> @@ -83,7 +83,7 @@ static void run(unsigned int n)
> args->tls = tc->tls;
> }
>
> - TEST(clone3(args, tc->size));
> + TEST(ltp_clone3_raw(args, tc->size));
>
> if (!TST_RET)
> exit(EXIT_SUCCESS);
> --
> 2.53.0.959.g497ff81fa9-goog
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
--
Regards,
Li Wang
More information about the ltp
mailing list