Update clone3 wrapper signature
PATCH 1/1 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.
--- 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(-)
include/lapi/sched.h +20 -7
@@ -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 )
testcases/kernel/syscalls/clone3/clone301.c +1 -1
@@ -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 ;
testcases/kernel/syscalls/clone3/clone302.c +1 -1
@@ -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 );
Signature · 5 lines
2.53.0.959.g497ff81fa9-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 3 lines · Chris Wailes via ltp
This CL adds the
ltp_clone3_rawwrapper for direct testing of the syscall, conditionally definesclone_args_minimal, and adds altp_clone3wrapper for libc implementations that provideclone3.
When you signed off patch better to use 'git commit -sm "xxx"' otherwise patch has no signature:
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
Quoted 21 lines
--- 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(-)include/lapi/sched.h +1
-2@@ -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;
include/lapi/sched.h struct clone_args { · line 63
Quoted 10 lines
include/lapi/sched.h +1
-4@@ -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
Quoted 11 lines
include/lapi/sched.h +4
-0+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;
include/lapi/sched.h struct clone_args_minimal { · line 84
Quoted 10 lines
include/lapi/sched.h +4
-1}; +#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.
testcases/kernel/syscalls/clone3/clone302.c
Quoted 30 lines
include/lapi/sched.h +10
-0+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 )testcases/kernel/syscalls/clone3/clone301.c +1
-1@@ -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 ;testcases/kernel/syscalls/clone3/clone302.c +0
-0
We need to modify it in clone304.c as well.
The rest part looks good.
Quoted 16 lines
testcases/kernel/syscalls/clone3/clone302.c +1
-1@@ -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 );Signature · 5 lines
2.53.0.959.g497ff81fa9-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 6 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp