* [LTP] [PATCH] Update clone3 wrapper signature
@ 2025-11-14 19:52 Chris Wailes via ltp
2025-12-16 12:40 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2025-11-14 19:52 UTC (permalink / raw)
To: ltp
From a932e9d3ee093933a5bd58edecec42a61df2b6c0 Mon Sep 17 00:00:00 2001
From: Chris Wailes <chriswailes@google.com>
Date: Fri, 14 Nov 2025 10:42:21 -0800
Subject: [PATCH] Update clone3 wrapper signature
This CL updates the clone3 wrapper and tests to match the function
signatures used by glibc (internally) and BIONIC (publicly).
Signed-off-by: Chris Wailes <chriswailes@google.com>
---
include/lapi/sched.h | 2 +-
testcases/kernel/syscalls/clone3/clone301.c | 2 +-
testcases/kernel/syscalls/clone3/clone302.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 36f1ecad9..2fec8e397 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -75,7 +75,7 @@ struct clone_args_minimal {
uint64_t __attribute__((aligned(8))) tls;
};
-static inline int clone3(struct clone_args *args, size_t size)
+static inline int clone3(struct clone_args *args, size_t size, int
(*)(void*), void*)
{
return tst_syscall(__NR_clone3, args, size);
}
diff --git a/testcases/kernel/syscalls/clone3/clone301.c
b/testcases/kernel/syscalls/clone3/clone301.c
index deed30b9f..ecd791389 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 = clone3(args, sizeof(*args), NULL, NULL));
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..e241be7cd 100644
--- a/testcases/kernel/syscalls/clone3/clone302.c
+++ b/testcases/kernel/syscalls/clone3/clone302.c
@@ -83,7 +83,7 @@ static void run(unsigned int n)
args->tls = tc->tls;
}
- TEST(clone3(args, tc->size));
+ TEST(clone3(args, tc->size, NULL, NULL));
if (!TST_RET)
exit(EXIT_SUCCESS);
--
2.52.0.rc1.455.g30608eb744-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2025-11-14 19:52 [LTP] [PATCH] Update clone3 wrapper signature Chris Wailes via ltp
@ 2025-12-16 12:40 ` Andrea Cervesato via ltp
2025-12-16 17:50 ` Chris Wailes via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Andrea Cervesato via ltp @ 2025-12-16 12:40 UTC (permalink / raw)
To: Chris Wailes, ltp
Hi Chris,
First of all, sorry for the late reply. Unfortunately, I couldn't
find any C lib code reference that is justifying the clone3() wrapper
inside this patch.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2025-12-16 12:40 ` Andrea Cervesato via ltp
@ 2025-12-16 17:50 ` Chris Wailes via ltp
2025-12-17 7:58 ` Anrea Cervesato via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2025-12-16 17:50 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Andrea,
Thanks for reviewing the change. We're currently adding a `clone3` wrapper
to Android's BIONIC libc implementation. Additionally, this is the
signature used for `glibc`'s `__clone3`
<https://github.com/bminor/glibc/blob/ded9c1e525f2d69a81e61c34c29077fed7df658c/include/clone_internal.h>
.
- Chris
On Tue, Dec 16, 2025 at 4:40 AM Andrea Cervesato <andrea.cervesato@suse.com>
wrote:
> Hi Chris,
>
> First of all, sorry for the late reply. Unfortunately, I couldn't
> find any C lib code reference that is justifying the clone3() wrapper
> inside this patch.
>
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2025-12-16 17:50 ` Chris Wailes via ltp
@ 2025-12-17 7:58 ` Anrea Cervesato via ltp
2025-12-17 9:43 ` Li Wang via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Anrea Cervesato via ltp @ 2025-12-17 7:58 UTC (permalink / raw)
To: Chris Wailes; +Cc: chrubis, ltp
Hi Chris,
On 12/16/25 6:50 PM, Chris Wailes wrote:
> Andrea,
>
> Thanks for reviewing the change. We're currently adding a `clone3`
> wrapper to Android's BIONIC libc implementation. Additionally, this is
> the signature used for `glibc`'s `__clone3`
> <https://github.com/bminor/glibc/blob/ded9c1e525f2d69a81e61c34c29077fed7df658c/include/clone_internal.h>.
>
> - Chris
At this point, I think we should just adopt tst_clone() instead of
clone3() fallback.
@Cyril WDYT?
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2025-12-17 7:58 ` Anrea Cervesato via ltp
@ 2025-12-17 9:43 ` Li Wang via ltp
2026-03-04 21:33 ` Chris Wailes via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Li Wang via ltp @ 2025-12-17 9:43 UTC (permalink / raw)
To: Anrea Cervesato; +Cc: chrubis, ltp
On Wed, Dec 17, 2025 at 3:58 PM Anrea Cervesato via ltp <ltp@lists.linux.it>
wrote:
> Hi Chris,
>
> On 12/16/25 6:50 PM, Chris Wailes wrote:
> > Andrea,
> >
> > Thanks for reviewing the change. We're currently adding a `clone3`
> > wrapper to Android's BIONIC libc implementation. Additionally, this is
> > the signature used for `glibc`'s `__clone3`
> > <
> https://github.com/bminor/glibc/blob/ded9c1e525f2d69a81e61c34c29077fed7df658c/include/clone_internal.h
> >.
> >
> > - Chris
>
> At this point, I think we should just adopt tst_clone() instead of
> clone3() fallback.
>
Perhaps a simple approach is to define a raw system call for clone3
and use it in all existing tests, and then add new tests if we plan to
test the libc-like clone3 wrapper (with four args).
Otherwise the new added 'NULL, NULL' arguments for current hacked
clone3 makes no sense.
static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
{
return tst_syscall(__NR_clone3, args, size);
}
#ifdef HAVE_CLONE3_WRAPPER
int ltp_clone3(struct clone_args *cl_args, size_t size,
int (*fn)(void *), void *arg);
#else
static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
int (*fn)(void *), void *arg)
{
return -1;
}
#endif
Btw, the above changes should be put in lapi/sched.h if we decide go this.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2025-12-17 9:43 ` Li Wang via ltp
@ 2026-03-04 21:33 ` Chris Wailes via ltp
2026-03-18 18:29 ` Chris Wailes via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2026-03-04 21:33 UTC (permalink / raw)
To: Li Wang; +Cc: chrubis, ltp
Apologies for the delayed response. Please find my updated patch below.
---
From 50564557a72df12d500997dd145cc5376edd8063 Mon Sep 17 00:00:00 2001
From: Chris Wailes <chriswailes@google.com>
Date: Fri, 14 Nov 2025 13:56:39 -0800
Subject: [PATCH] Update clone3 wrapper signature
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`.
Signed-off-by: Chris Wailes <chriswailes@google.com>
---
include/lapi/sched.h | 32 +++++++++++++++------
testcases/kernel/syscalls/clone3/clone301.c | 2 +-
testcases/kernel/syscalls/clone3/clone302.c | 2 +-
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 0ffe44641..c0fa8dd47 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -49,9 +49,13 @@ 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
-#ifndef HAVE_STRUCT_CLONE_ARGS
-struct clone_args {
+static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
+{
+ return tst_syscall(__NR_clone3, args, size);
+}
+
+#ifndef HAVE_STRUCT_CLONE_ARGS_MINIMAL
+struct clone_args_minimal {
uint64_t __attribute__((aligned(8))) flags;
uint64_t __attribute__((aligned(8))) pidfd;
uint64_t __attribute__((aligned(8))) child_tid;
@@ -60,13 +64,12 @@ 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;
};
#endif
-struct clone_args_minimal {
+#ifndef HAVE_CLONE3
+#ifndef HAVE_STRUCT_CLONE_ARGS
+struct clone_args {
uint64_t __attribute__((aligned(8))) flags;
uint64_t __attribute__((aligned(8))) pidfd;
uint64_t __attribute__((aligned(8))) child_tid;
@@ -75,11 +78,22 @@ 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)
+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 tst_syscall(__NR_clone3, args, size);
+ return -1;
}
#endif
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
@@ -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.473.g4a7958ca14-goog
On Wed, Dec 17, 2025 at 1:43 AM Li Wang <liwang@redhat.com> wrote:
>
>
> On Wed, Dec 17, 2025 at 3:58 PM Anrea Cervesato via ltp <
> ltp@lists.linux.it> wrote:
>
>> Hi Chris,
>>
>> On 12/16/25 6:50 PM, Chris Wailes wrote:
>> > Andrea,
>> >
>> > Thanks for reviewing the change. We're currently adding a `clone3`
>> > wrapper to Android's BIONIC libc implementation. Additionally, this is
>> > the signature used for `glibc`'s `__clone3`
>> > <
>> https://github.com/bminor/glibc/blob/ded9c1e525f2d69a81e61c34c29077fed7df658c/include/clone_internal.h
>> >.
>> >
>> > - Chris
>>
>> At this point, I think we should just adopt tst_clone() instead of
>> clone3() fallback.
>>
>
> Perhaps a simple approach is to define a raw system call for clone3
> and use it in all existing tests, and then add new tests if we plan to
> test the libc-like clone3 wrapper (with four args).
>
> Otherwise the new added 'NULL, NULL' arguments for current hacked
> clone3 makes no sense.
>
> static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
> {
> return tst_syscall(__NR_clone3, args, size);
> }
>
> #ifdef HAVE_CLONE3_WRAPPER
> int ltp_clone3(struct clone_args *cl_args, size_t size,
> int (*fn)(void *), void *arg);
> #else
> static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
> int (*fn)(void *), void *arg)
> {
> return -1;
> }
> #endif
>
> Btw, the above changes should be put in lapi/sched.h if we decide go this.
>
>
> --
> Regards,
> Li Wang
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2026-03-04 21:33 ` Chris Wailes via ltp
@ 2026-03-18 18:29 ` Chris Wailes via ltp
2026-03-19 3:54 ` Li Wang via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2026-03-18 18:29 UTC (permalink / raw)
To: Li Wang; +Cc: chrubis, ltp
Would it be better/easier for me to submit this through GitHub?
- Chris
On Wed, Mar 4, 2026 at 1:33 PM Chris Wailes <chriswailes@google.com> wrote:
> Apologies for the delayed response. Please find my updated patch below.
>
> ---
>
> From 50564557a72df12d500997dd145cc5376edd8063 Mon Sep 17 00:00:00 2001
> From: Chris Wailes <chriswailes@google.com>
> Date: Fri, 14 Nov 2025 13:56:39 -0800
> Subject: [PATCH] Update clone3 wrapper signature
>
> 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`.
>
> Signed-off-by: Chris Wailes <chriswailes@google.com>
> ---
> include/lapi/sched.h | 32 +++++++++++++++------
> testcases/kernel/syscalls/clone3/clone301.c | 2 +-
> testcases/kernel/syscalls/clone3/clone302.c | 2 +-
> 3 files changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/include/lapi/sched.h b/include/lapi/sched.h
> index 0ffe44641..c0fa8dd47 100644
> --- a/include/lapi/sched.h
> +++ b/include/lapi/sched.h
> @@ -49,9 +49,13 @@ 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
> -#ifndef HAVE_STRUCT_CLONE_ARGS
> -struct clone_args {
> +static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
> +{
> + return tst_syscall(__NR_clone3, args, size);
> +}
> +
> +#ifndef HAVE_STRUCT_CLONE_ARGS_MINIMAL
> +struct clone_args_minimal {
> uint64_t __attribute__((aligned(8))) flags;
> uint64_t __attribute__((aligned(8))) pidfd;
> uint64_t __attribute__((aligned(8))) child_tid;
> @@ -60,13 +64,12 @@ 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;
> };
> #endif
>
> -struct clone_args_minimal {
> +#ifndef HAVE_CLONE3
> +#ifndef HAVE_STRUCT_CLONE_ARGS
> +struct clone_args {
> uint64_t __attribute__((aligned(8))) flags;
> uint64_t __attribute__((aligned(8))) pidfd;
> uint64_t __attribute__((aligned(8))) child_tid;
> @@ -75,11 +78,22 @@ 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)
> +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 tst_syscall(__NR_clone3, args, size);
> + return -1;
> }
> #endif
>
> 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
> @@ -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.473.g4a7958ca14-goog
>
> On Wed, Dec 17, 2025 at 1:43 AM Li Wang <liwang@redhat.com> wrote:
>
>>
>>
>> On Wed, Dec 17, 2025 at 3:58 PM Anrea Cervesato via ltp <
>> ltp@lists.linux.it> wrote:
>>
>>> Hi Chris,
>>>
>>> On 12/16/25 6:50 PM, Chris Wailes wrote:
>>> > Andrea,
>>> >
>>> > Thanks for reviewing the change. We're currently adding a `clone3`
>>> > wrapper to Android's BIONIC libc implementation. Additionally, this is
>>> > the signature used for `glibc`'s `__clone3`
>>> > <
>>> https://github.com/bminor/glibc/blob/ded9c1e525f2d69a81e61c34c29077fed7df658c/include/clone_internal.h
>>> >.
>>> >
>>> > - Chris
>>>
>>> At this point, I think we should just adopt tst_clone() instead of
>>> clone3() fallback.
>>>
>>
>> Perhaps a simple approach is to define a raw system call for clone3
>> and use it in all existing tests, and then add new tests if we plan to
>> test the libc-like clone3 wrapper (with four args).
>>
>> Otherwise the new added 'NULL, NULL' arguments for current hacked
>> clone3 makes no sense.
>>
>> static inline int ltp_clone3_raw(struct clone_args *args, size_t size)
>> {
>> return tst_syscall(__NR_clone3, args, size);
>> }
>>
>> #ifdef HAVE_CLONE3_WRAPPER
>> int ltp_clone3(struct clone_args *cl_args, size_t size,
>> int (*fn)(void *), void *arg);
>> #else
>> static inline int ltp_clone3(struct clone_args *cl_args, size_t size,
>> int (*fn)(void *), void *arg)
>> {
>> return -1;
>> }
>> #endif
>>
>> Btw, the above changes should be put in lapi/sched.h if we decide go this.
>>
>>
>> --
>> Regards,
>> Li Wang
>>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2026-03-18 18:29 ` Chris Wailes via ltp
@ 2026-03-19 3:54 ` Li Wang via ltp
2026-03-19 18:55 ` Chris Wailes via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Li Wang via ltp @ 2026-03-19 3:54 UTC (permalink / raw)
To: Chris Wailes; +Cc: chrubis, ltp
> Would it be better/easier for me to submit this through GitHub?
The patch generally looks good.
We prefer to review patch in mailing list. Could you try to resend
it via the following commands?
# sudo dnf install git-email
... do some local configure ...
# git format-patch -1
# git send-email 0001-xx --to ltp@lists.linux.it
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* [LTP] [PATCH] Update clone3 wrapper signature
@ 2026-03-19 18:54 Chris Wailes via ltp
2026-03-20 3:13 ` Li Wang via ltp
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wailes via ltp @ 2026-03-19 18:54 UTC (permalink / raw)
To: ltp
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`.
---
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
+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
+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
@@ -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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2026-03-19 3:54 ` Li Wang via ltp
@ 2026-03-19 18:55 ` Chris Wailes via ltp
0 siblings, 0 replies; 11+ messages in thread
From: Chris Wailes via ltp @ 2026-03-19 18:55 UTC (permalink / raw)
To: Li Wang; +Cc: chrubis, ltp
Done. Thanks for the guidance.
- Chris
On Wed, Mar 18, 2026 at 8:54 PM Li Wang <liwang@redhat.com> wrote:
> > Would it be better/easier for me to submit this through GitHub?
>
> The patch generally looks good.
>
> We prefer to review patch in mailing list. Could you try to resend
> it via the following commands?
>
> # sudo dnf install git-email
>
> ... do some local configure ...
>
> # git format-patch -1
> # git send-email 0001-xx --to ltp@lists.linux.it
>
> --
> Regards,
> Li Wang
>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH] Update clone3 wrapper signature
2026-03-19 18:54 Chris Wailes via ltp
@ 2026-03-20 3:13 ` Li Wang via ltp
0 siblings, 0 replies; 11+ messages in thread
From: Li Wang via ltp @ 2026-03-20 3:13 UTC (permalink / raw)
To: Chris Wailes; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-03-20 3:14 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 19:52 [LTP] [PATCH] Update clone3 wrapper signature Chris Wailes via ltp
2025-12-16 12:40 ` Andrea Cervesato via ltp
2025-12-16 17:50 ` Chris Wailes via ltp
2025-12-17 7:58 ` Anrea Cervesato via ltp
2025-12-17 9:43 ` Li Wang via ltp
2026-03-04 21:33 ` Chris Wailes via ltp
2026-03-18 18:29 ` Chris Wailes via ltp
2026-03-19 3:54 ` Li Wang via ltp
2026-03-19 18:55 ` Chris Wailes via ltp
-- strict thread matches above, loose matches on Subject: below --
2026-03-19 18:54 Chris Wailes via ltp
2026-03-20 3:13 ` Li Wang via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox