clone3: Add clone3's clone_args cgroup
PATCH 1/1 clone3: Add clone3's clone_args cgroup
--- include/lapi/sched.h | 3 +++ include/tst_clone.h | 1 + lib/tst_clone.c | 1 + 3 files changed, 5 insertions(+)
include/lapi/sched.h +3 -0
@@ -54,6 +54,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Do you plan to use this somewhere? Otherwise I don't see the point to just add it.
Kind regards,
Petr
Quoted 45 lines
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 3 +++ include/tst_clone.h | 1 + lib/tst_clone.c | 1 + 3 files changed, 5 insertions(+)include/lapi/sched.h +3
-0@@ -54,6 +54,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it lib/tst_clone.c +1
-0@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Petr Vorel
Hi Wei,
Do you plan to use this somewhere? Otherwise I don't see the point to just add it.
Sorry i need add another commit above this and start using new added args, will create test case later, maybe you can put ChangRequest firstly, thanks.
Quoted 49 lines
Kind regards,
PetrQuoted 45 lines
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 3 +++ include/tst_clone.h | 1 + lib/tst_clone.c | 1 + 3 files changed, 5 insertions(+)include/lapi/sched.h +3
-0@@ -54,6 +54,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it lib/tst_clone.c +1
-0@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 7 lines · Petr Vorel
Quoted 4 lines
Hi Wei,
Do you plan to use this somewhere? Otherwise I don't see the point to just add it.
Sorry i need add another commit above this and start using new added args, will create test case later, maybe you can put ChangRequest firstly, thanks.
I'd prefer to merge them once they are actually needed. But Richie might have a different opinion.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Petr Vorel
Hi Wei,
Quoted 2 lines · Petr Vorel
Quoted 1 line
Hi Wei,
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Do you plan to use this somewhere? Otherwise I don't see the point to just add it.
Sorry i need add another commit above this and start using new added args, will create test case later, maybe you can put ChangRequest firstly, thanks.
I'd prefer to merge them once they are actually needed. But Richie might have a different opinion.
@Petr So i need continue add case or not?
@Richie what's your plan?
Quoted 2 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 7 lines · Petr Vorel
Quoted 6 lines
Hi Wei,
Quoted 5 lines · Petr Vorel
Quoted 4 lines
Hi Wei,
Do you plan to use this somewhere? Otherwise I don't see the point to just add it.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Sorry i need add another commit above this and start using new added args, will create test case later, maybe you can put ChangRequest firstly, thanks.
I'd prefer to merge them once they are actually needed. But Richie might have a different opinion.
@Petr So i need continue add case or not?
That's up to you. I'm just saying I would not merge code which is not use.
Kind regards,
Petr
Quoted 3 lines
@Richie what's your plan?
Quoted 2 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 clone3: Add clone3's clone_args cgroup
In reply to Wei Gao via ltp--- include/lapi/sched.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 1 + lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 98 +++++++++++++++++++++ 7 files changed, 107 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.c
include/lapi/sched.h +4 -0
@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_cgroup.c +1 -0
@@ -166,6 +166,7 @@ static const struct cgroup_file cgroup_ctrl_files[] = { { "cgroup.controllers", NULL, 0 }, { "cgroup.subtree_control", NULL, 0 }, { "cgroup.clone_children", "cgroup.clone_children", 0 }, + { "cgroup.kill", NULL, 0 }, { } };
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
runtest/syscalls +1 -0
@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02
testcases/kernel/syscalls/clone3/.gitignore +1 -0
@@ -1,2 +1,3 @@ clone301 clone302 +clone303
testcases/kernel/syscalls/clone3/clone303.c new file +98 -0
98 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 16 lines
testcases/kernel/syscalls/clone3/clone303.c new file +13
-0@@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 SUSE LLC <[email protected]> +*/ + +/*\ +* [Description] +* +* This test case check clone3 CLONE_INTO_CGROUP flag +* +*/ + +#define _GNU_SOURCE
testcases/kernel/syscalls/clone3/clone303.c line 23
Quoted 10 lines
testcases/kernel/syscalls/clone3/clone303.c new file +10
-0+#include <stdio.h> +#include <stdlib.h> +#include <sys/wait.h> + +#include "tst_test.h" +#include "lapi/sched.h" +#include "lapi/pidfd.h" + +#define BUF_LEN 20 +#define CLONE_INTO_CGROUP 0x200000000ULL
This should be added as a fallback definition into lapi/sched.h
Quoted 17 lines
testcases/kernel/syscalls/clone3/clone303.c new file +17
-0+static struct tst_cg_group *cg_child_test_simple; +static struct clone_args *args; + +static pid_t clone_into_cgroup (int cgroup_fd) +{ +pid_t pid; + + args->flags =CLONE_INTO_CGROUP ; + args->exit_signal =SIGCHLD ; + args->cgroup = cgroup_fd; + + pid =clone3 (args,sizeof (*args)); + +if (pid <0 ) +tst_res (TFAIL |TTERRNO ,"clone3() failed !" ); + +return pid;
testcases/kernel/syscalls/clone3/clone303.c line 51
Quoted 10 lines
testcases/kernel/syscalls/clone3/clone303.c new file +10
-0+} + +static void run (void ) +{ +char path[100 ]; +int fd; +pid_t pid; + + cg_child_test_simple =tst_cg_group_mk (tst_cg,"cg_test_simple" ); +sprintf (path,"/sys/fs/cgroup/ltp/%s/%s" ,tst_cg_group_name (tst_cg),tst_cg_group_name (cg_child_test_simple));
There is no guarantee that the cgroup is mounted in this hardcoded path and that the top level directory for LTP tests is called ltp.
Moreover we already do have a file descriptor pointing to the directory for cgroup v2 opened in the cgroup library. All we need is a function in the library that would find the take the tst_cg_group and find the right cgroup_dir in the dirs[] array.
testcases/kernel/syscalls/clone3/clone303.c line 58
Quoted 7 lines
testcases/kernel/syscalls/clone3/clone303.c new file +7
-0+tst_res (TINFO ,"cgroup path is %s" , path); + fd =SAFE_OPEN (path,O_DIRECTORY |O_CLOEXEC |O_NOFOLLOW |O_PATH ); + + pid =clone_into_cgroup (fd); + +if (!pid) { +TST_CHECKPOINT_WAIT (0 );
Just add reutrn; here and drop the else below.
testcases/kernel/syscalls/clone3/clone303.c line 63
Quoted 5 lines
testcases/kernel/syscalls/clone3/clone303.c new file +5
-0+ }else { + +char buf[BUF_LEN ]; + +SAFE_CG_READ (cg_child_test_simple,"cgroup.procs" , buf,BUF_LEN );
^ sizeof(buf);
Quoted 41 lines
testcases/kernel/syscalls/clone3/clone303.c new file +35
-0+ +int x =atoi (buf); + +if (x == pid) +tst_res (TPASS ,"clone3 case pass!" ); +else +tst_brk (TFAIL |TTERRNO ,"clone3() failed !" ); + +TST_CHECKPOINT_WAKE (0 ); + +SAFE_WAITPID (pid,NULL ,0 ); + + cg_child_test_simple =tst_cg_group_rm (cg_child_test_simple); + } +} + +static void setup (void ) +{ +clone3_supported_by_kernel (); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .forks_child =1 , + .max_runtime =20 , + .needs_cgroup_ctrls = (const char *const []){"memory" ,NULL }, + .needs_cgroup_ver =TST_CG_V2 , + .needs_checkpoints =1 , + .min_kver ="5.7" , + .bufs = (struct tst_buffers []) { + {&args, .size =sizeof (*args)}, + {}, + } +};Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 clone3: Add clone3's clone_args cgroup
In reply to Wei Gao via ltp--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 3 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 6 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 94 +++++++++++++++++++++ 8 files changed, 115 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.c
include/lapi/sched.h +8 -0
@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
@@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL +#endif +#endif /* LAPI_SCHED_H__ */
include/tst_cgroup.h +3 -0
@@ -157,6 +157,9 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +int tst_cg_group_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_cgroup.c +6 -0
@@ -166,6 +166,7 @@ static const struct cgroup_file cgroup_ctrl_files[] = { { "cgroup.controllers", NULL, 0 }, { "cgroup.subtree_control", NULL, 0 }, { "cgroup.clone_children", "cgroup.clone_children", 0 }, + { "cgroup.kill", NULL, 0 }, { } };
@@ -1093,6 +1094,11 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_dir_fd (const struct tst_cg_group *const cg) +{ +return cg->dirs[0 ]->dir_fd; +} +struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg) {struct cgroup_dir **dir;
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
runtest/syscalls +1 -0
@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02
testcases/kernel/syscalls/clone3/.gitignore +1 -0
@@ -1,2 +1,3 @@ clone301 clone302 +clone303
testcases/kernel/syscalls/clone3/clone303.c new file +94 -0
94 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 31 lines
include/tst_cgroup.h +3
-0@@ -157,6 +157,9 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +int tst_cg_group_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it lib/tst_cgroup.c +0
-0
lib/tst_cgroup.c static const struct cgroup_file cgroup_ctrl_files[] = { · line 171
Quoted 6 lines
lib/tst_cgroup.c +1
-0@@ -166,6 +166,7 @@ static const struct cgroup_file cgroup_ctrl_files[] = { { "cgroup.controllers", NULL, 0 }, { "cgroup.subtree_control", NULL, 0 }, { "cgroup.clone_children", "cgroup.clone_children", 0 }, + { "cgroup.kill", NULL, 0 }, { } };
This seems to be unrelated change.
lib/tst_cgroup.c const char *tst_cg_group_name(const struct tst_cg_group *const cg) · line 1099
Quoted 7 lines
lib/tst_cgroup.c +3
-0@@ -1093,6 +1094,11 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_dir_fd (const struct tst_cg_group *const cg) +{ +return cg->dirs[0 ]->dir_fd;
Does this actually work in the case of mixed cgroup v1 and v2 setup? Even if so I would just make sure that this call returns a fd pointing to a v2 directory. Also the function should include "unified" in the name so that it's clear that it returns fd to the v2 "unified" hierarchy. I guess that tst_cg_group_unified_dir_fd() would be fitting name.
To implement that we have to loop over dirs[] array and check which one of them is v2, which should be reachable via the root pointer in the dir.
Quoted 82 lines
lib/tst_cgroup.c +2
-0+} +struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg) {struct cgroup_dir **dir;lib/tst_clone.c +1
-0@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;runtest/syscalls +1
-0@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02testcases/kernel/syscalls/clone3/.gitignore +1
-0@@ -1,2 +1,3 @@ clone301 clone302 +clone303testcases/kernel/syscalls/clone3/clone303.c new file +39
-0@@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2023 SUSE LLC <[email protected]> +*/ + +/*\ +* [Description] +* +* This test case check clone3 CLONE_INTO_CGROUP flag +* +*/ + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <sys/wait.h> + +#include "tst_test.h" +#include "lapi/sched.h" +#include "lapi/pidfd.h" + +#define BUF_LEN 20 + +static struct tst_cg_group *cg_child_test_simple; +static struct clone_args *args; + +static pid_t clone_into_cgroup (int cgroup_fd) +{ +pid_t pid; + + args->flags =CLONE_INTO_CGROUP ; + args->exit_signal =SIGCHLD ; + args->cgroup = cgroup_fd; + + pid =clone3 (args,sizeof (*args)); + +if (pid <0 ) +tst_res (TFAIL |TTERRNO ,"clone3() failed !" ); +
testcases/kernel/syscalls/clone3/clone303.c line 49
Quoted 10 lines
testcases/kernel/syscalls/clone3/clone303.c new file +10
-0+return pid; +} + +static void run (void ) +{ +int fd; +pid_t pid; + + cg_child_test_simple =tst_cg_group_mk (tst_cg,"cg_test_simple" ); + fd =tst_cg_group_dir_fd (cg_child_test_simple);
I suppoose that this can be done once in the test setup.
Quoted 13 lines
testcases/kernel/syscalls/clone3/clone303.c new file +13
-0+ pid =clone_into_cgroup (fd); + +if (!pid) { +TST_CHECKPOINT_WAIT (0 ); +return ; + } + +char buf[BUF_LEN ]; + +SAFE_CG_READ (cg_child_test_simple,"cgroup.procs" , buf,BUF_LEN ); + +int x =atoi (buf); +
testcases/kernel/syscalls/clone3/clone303.c line 73
Quoted 10 lines
testcases/kernel/syscalls/clone3/clone303.c new file +10
-0+if (x == pid) +tst_res (TPASS ,"clone3 case pass!" ); +else +tst_brk (TFAIL |TTERRNO ,"clone3() failed !" ); + +TST_CHECKPOINT_WAKE (0 ); + +SAFE_WAITPID (pid,NULL ,0 ); + + cg_child_test_simple =tst_cg_group_rm (cg_child_test_simple);
And this could be done in the test cleanup.
Quoted 27 lines
testcases/kernel/syscalls/clone3/clone303.c new file +21
-0+} + +static void setup (void ) +{ +clone3_supported_by_kernel (); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .forks_child =1 , + .max_runtime =20 , + .needs_cgroup_ctrls = (const char *const []){"memory" ,NULL }, + .needs_cgroup_ver =TST_CG_V2 , + .needs_checkpoints =1 , + .min_kver ="5.7" , + .bufs = (struct tst_buffers []) { + {&args, .size =sizeof (*args)}, + {}, + } +};Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/1 clone3: Add clone3's clone_args cgroup
In reply to Wei Gao via ltp--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 3 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 9 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 103 ++++++++++++++++++++ 8 files changed, 127 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.c
include/lapi/sched.h +8 -0
@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
@@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL +#endif +#endif /* LAPI_SCHED_H__ */
include/tst_cgroup.h +3 -0
@@ -157,6 +157,9 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_cgroup.c +9 -0
@@ -1112,6 +1112,15 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +for (int i =0 ; cg->dirs[i]; i++) { +if (cg->dirs[i]->dir_root->ver ==TST_CG_V2 ) +return cg->dirs[i]->dir_fd; + } +return -1 ; +} +struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg) {struct cgroup_dir **dir;
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
runtest/syscalls +1 -0
@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02
testcases/kernel/syscalls/clone3/.gitignore +1 -0
@@ -1,2 +1,3 @@ clone301 clone302 +clone303
testcases/kernel/syscalls/clone3/clone303.c new file +103 -0
103 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
...
include/tst_cgroup.h const char * · line 158
Quoted 4 lines
+++
b/include/tst_cgroup.hinclude/tst_cgroup.h +0
-0@@ -157,6 +157,9 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result));
Maybe to add a comment to describe the function? (other functions have a description).
Quoted 16 lines
include/tst_cgroup.h +3
-0+int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };
...
Quoted 1 line
+++
b/testcases/kernel/syscalls/clone3/clone303.c
...
Quoted 9 lines
include/tst_clone.h +9
-0+ +static void run (void ) +{ +pid_t pid; + + pid =clone_into_cgroup (fd); + +if (!pid) { +TST_CHECKPOINT_WAIT (0 );
include/tst_clone.h
Quoted 10 lines
include/tst_clone.h +10
-0+return ; + } + +char buf[BUF_LEN ]; + +SAFE_CG_READ (cg_child_test_simple,"cgroup.procs" , buf,BUF_LEN ); + +int x =atoi (buf); + +if (x == pid)
x is using only here. Why not just:
if (atoi(buf) == pid)
Quoted 10 lines
include/tst_clone.h +10
-0+tst_res (TPASS ,"clone3 case pass!" ); + else + tst_brk(TFAIL | TTERRNO, "clone3() failed !"); + +TST_CHECKPOINT_WAKE (0 ); + +SAFE_WAITPID (pid,NULL ,0 ); + +} +
include/tst_clone.h
Quoted 10 lines
include/tst_clone.h +10
-0+static void setup (void ) +{ +clone3_supported_by_kernel (); + + cg_child_test_simple =tst_cg_group_mk (tst_cg,"cg_test_simple" ); + + fd =tst_cg_group_unified_dir_fd (cg_child_test_simple); + +if (fd <0 ) +tst_res (TFAIL |TTERRNO ,"get dir fd failed !" );
Wouldn't be better to use here
tst_brk(TBROK | TTERRNO, "get dir fd failed!");
Or even just
tst_brk(TBROK, "get dir fd failed!");
Because tst_cg_group_unified_dir_fd() does not do any real operation which would set errno.
I mean does make sense to continue testing if fd is invalid?
Quoted 1 line
+}
...
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/1 clone3: Add clone3's clone_args cgroup
In reply to Wei Gao via ltp--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 9 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 101 ++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.c
include/lapi/sched.h +8 -0
@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
@@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL +#endif +#endif /* LAPI_SCHED_H__ */
include/tst_cgroup.h +4 -0
@@ -157,6 +157,10 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +/* This call returns a fd pointing to a v2 directory */ +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_cgroup.c +9 -0
@@ -1112,6 +1112,15 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +for (int i =0 ; cg->dirs[i]; i++) { +if (cg->dirs[i]->dir_root->ver ==TST_CG_V2 ) +return cg->dirs[i]->dir_fd; + } +return -1 ; +} +struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg) {struct cgroup_dir **dir;
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
runtest/syscalls +1 -0
@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02
testcases/kernel/syscalls/clone3/.gitignore +1 -0
@@ -1,2 +1,3 @@ clone301 clone302 +clone303
testcases/kernel/syscalls/clone3/clone303.c new file +101 -0
101 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 64 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 9 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 101 ++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.cinclude/lapi/sched.h +8
-0@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)@@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL +#endif +#endif /* LAPI_SCHED_H__ */ include/tst_cgroup.h +4
-0@@ -157,6 +157,10 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +/* This call returns a fd pointing to a v2 directory */ +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)include/tst_clone.h +0
-0
include/tst_clone.h line 14
Quoted 4 lines
include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup;
This is not used in the test being added so I will not merge it because I don't want to do any more work than necessary (I would still merge the rest of the test, but there is another issue below). The reason is because it may cause some test which does use tst_clone_args to fail because it increases the struct size. If some other test does not initialise the members correctly we may start sending uninitialised data to the kernel.
In general I don't want to add anything which isn't immediately necessary without having to think about any potential problems it could cause.
Quoted 8 lines
include/tst_clone.h +0
-0};/* clone3 with fallbacks to clone when possible. Be aware that it lib/tst_cgroup.c +0
-0
lib/tst_cgroup.c const char *tst_cg_group_name(const struct tst_cg_group *const cg) · line 1119
Quoted 8 lines
lib/tst_cgroup.c +5
-0@@ -1112,6 +1112,15 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +for (int i =0 ; cg->dirs[i]; i++) { +if (cg->dirs[i]->dir_root->ver ==TST_CG_V2 ) +return cg->dirs[i]->dir_fd;
The loop is unecessary; cg->dirs_by_ctrl[0] is always the V2 directory if it exists.
Otherwise the test LGTM. I'll set to changes requested in patchwork.
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Richard
Thanks for your review. I flag my comments in former email start with [GW].
Thanks.
Regards
Gao Wei
-----Original Message-----
From: Richard Palethorpe <[email protected]>
Sent: Friday, August 25, 2023 6:36 PM
To: Wei Gao <[email protected]>
Cc: [email protected]
Subject: Re: [LTP] [PATCH v5] clone3: Add clone3's clone_args cgroup
Hello,
Quoted 64 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 9 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 101 ++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.cinclude/lapi/sched.h index renamed from include/lapi/sched.h +0
-0
1065665d1..ac766efc5100644include/lapi/sched.h +7
-1@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;@@ -54,6 +55,9 @@ 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; }; static inline int clone3(struct clone_args *args, size_t size) @@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL #endif +#endif /* LAPI_SCHED_H__ */ include/tst_cgroup.h index renamed from include/tst_cgroup.h +0
-0
2826ddad1..be14d07c6100644include/tst_cgroup.h +4
-0@@ -157,6 +157,10 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +/* This call returns a fd pointing to a v2 directory */ int +tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group * tst_cg_group_rm(struct tst_cg_group *const cg) diff --git
a/include/tst_clone.hb/include/tst_clone.hindex9ffdc68d1..7b278dfa7100644
include/tst_clone.h line 14
Quoted 4 lines
include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup;
This is not used in the test being added so I will not merge it because I don't want to do any more work than necessary (I would still merge the rest of the test, but there is another issue below). The reason is because it may cause some test which does use tst_clone_args to fail because it increases the struct size. If some other test does not initialise the members correctly we may start sending uninitialised data to the kernel.
In general I don't want to add anything which isn't immediately necessary without having to think about any potential problems it could cause.
[GW]: The point of this case is test cgroup parameter, if you remove this then following error will happen:
tst_clone.c:18:21: error: 'const struct tst_clone_args' has no member named 'cgroup'
.cgroup = tst_args->cgroup,
Quoted 8 lines
include/tst_clone.h +0
-0};/* clone3 with fallbacks to clone when possible. Be aware that it lib/tst_cgroup.c index renamed from lib/tst_cgroup.c +0
-0
274c73fea..43055e8cf100644
lib/tst_cgroup.c const char *tst_cg_group_name(const struct tst_cg_group *const cg) · line 1119
Quoted 8 lines
lib/tst_cgroup.c +5
-0@@ -1112,6 +1112,15 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +for (int i =0 ; cg->dirs[i]; i++) { +if (cg->dirs[i]->dir_root->ver ==TST_CG_V2 ) +return cg->dirs[i]->dir_fd;
The loop is unecessary; cg->dirs_by_ctrl[0] is always the V2 directory if it exists.
[GW]: I have updated and sent new Patch
Otherwise the test LGTM. I'll set to changes requested in patchwork.
--
Thank you,
Richard.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 91 lines · Wei Gao
Hi Richard
Thanks for your review. I flag my comments in former email start with [GW].
Thanks.
Regards
Gao Wei-----Original Message-----
From: Richard Palethorpe <[email protected]>
Sent: Friday, August 25, 2023 6:36 PM
To: Wei Gao <[email protected]>
Cc: [email protected]
Subject: Re: [LTP] [PATCH v5] clone3: Add clone3'sclone_argscgroupHello,
Quoted 64 lines · Wei Gao via ltp
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 9 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 101 ++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.cinclude/lapi/sched.h index renamed from include/lapi/sched.h +0
-0
1065665d1..ac766efc5100644include/lapi/sched.h +7
-1@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;@@ -54,6 +55,9 @@ 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; }; static inline int clone3(struct clone_args *args, size_t size) @@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL #endif +#endif /* LAPI_SCHED_H__ */ include/tst_cgroup.h index renamed from include/tst_cgroup.h +0
-0
2826ddad1..be14d07c6100644include/tst_cgroup.h +4
-0@@ -157,6 +157,10 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +/* This call returns a fd pointing to a v2 directory */ int +tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group * tst_cg_group_rm(struct tst_cg_group *const cg) diff --git
a/include/tst_clone.hb/include/tst_clone.hindex9ffdc68d1..7b278dfa7100644include/tst_clone.h line 14
Quoted 4 lines
include/tst_clone.h +1
-0@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup;This is not used in the test being added so I will not merge it because I don't want to do any more work than necessary (I would still merge the rest of the test, but there is another issue below). The reason is because it may cause some test which does use
tst_clone_argsto fail because it increases the struct size. If some other test does not initialise the members correctly we may start sending uninitialised data to the kernel.
Quoted 5 lines
In general I don't want to add anything which isn't immediately necessary without having to think about any potential problems it could cause.
[GW]: The point of this case is test cgroup parameter, if you remove this then following error will happen:
tst_clone.c:18:21: error: 'const structtst_clone_args' has no member named 'cgroup'
.cgroup =tst_args->cgroup,
But you use clone3 directly, I don't understand where tst_clone is being used in the test?
Quoted 24 lines
Quoted 10 lines
include/tst_clone.h +0
-0};/* clone3 with fallbacks to clone when possible. Be aware that it lib/tst_cgroup.c index renamed from lib/tst_cgroup.c +0
-0
274c73fea..43055e8cf100644lib/tst_cgroup.c const char *tst_cg_group_name(const struct tst_cg_group *const cg) · line 1119
Quoted 8 lines
lib/tst_cgroup.c +5
-0@@ -1112,6 +1112,15 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +for (int i =0 ; cg->dirs[i]; i++) { +if (cg->dirs[i]->dir_root->ver ==TST_CG_V2 ) +return cg->dirs[i]->dir_fd;The loop is unecessary; cg->dirs_by_ctrl[0] is always the V2 directory if it exists.
[GW]: I have updated and sent new Patch
Otherwise the test LGTM. I'll set to changes requested in patchwork.
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 1/1 clone3: Add clone3's clone_args cgroup
In reply to Wei Gao via ltp--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 8 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 101 ++++++++++++++++++++ 8 files changed, 125 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.c
include/lapi/sched.h +8 -0
@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
@@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL +#endif +#endif /* LAPI_SCHED_H__ */
include/tst_cgroup.h +4 -0
@@ -157,6 +157,10 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +/* This call returns a fd pointing to a v2 directory */ +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_cgroup.c +8 -0
@@ -1112,6 +1112,14 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +if (cg->dirs_by_ctrl[0 ]) +return cg->dirs_by_ctrl[0 ]->dir_fd; + +return -1 ; +} +struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg) {struct cgroup_dir **dir;
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
runtest/syscalls +1 -0
@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02
testcases/kernel/syscalls/clone3/.gitignore +1 -0
@@ -1,2 +1,3 @@ clone301 clone302 +clone303
testcases/kernel/syscalls/clone3/clone303.c new file +101 -0
101 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v7 1/1 clone3: Add clone3's clone_args cgroup
--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 8 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 95 +++++++++++++++++++++ 8 files changed, 119 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.c
include/lapi/sched.h +8 -0
@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
@@ -54,6 +55,9 @@ 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; };static inline int clone3 (struct clone_args *args,size_t size)
@@ -133,4 +137,8 @@ static inline int getcpu(unsigned *cpu, unsigned *node)# define CLONE_NEWTIME 0x00000080#endif +#ifndef CLONE_INTO_CGROUP +# define CLONE_INTO_CGROUP 0x200000000ULL +#endif +#endif /* LAPI_SCHED_H__ */
include/tst_cgroup.h +4 -0
@@ -157,6 +157,10 @@ const char * tst_cg_group_name(const struct tst_cg_group *const cg) __attribute__ ((nonnull, warn_unused_result)); +/* This call returns a fd pointing to a v2 directory */ +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); +/* Remove a descendant CGroup */ struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg)
include/tst_clone.h +1 -0
@@ -11,6 +11,7 @@struct tst_clone_args {uint64_t flags;uint64_t exit_signal; +uint64_t cgroup; };/* clone3 with fallbacks to clone when possible. Be aware that it
lib/tst_cgroup.c +8 -0
@@ -1112,6 +1112,14 @@ const char *tst_cg_group_name(const struct tst_cg_group *const cg)return cg->group_name; } +int tst_cg_group_unified_dir_fd (const struct tst_cg_group *const cg) +{ +if (cg->dirs_by_ctrl[0 ]) +return cg->dirs_by_ctrl[0 ]->dir_fd; + +return -1 ; +} +struct tst_cg_group *tst_cg_group_rm (struct tst_cg_group *const cg) {struct cgroup_dir **dir;
lib/tst_clone.c +1 -0
@@ -15,6 +15,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)struct clone_args args = { .flags = tst_args->flags, .exit_signal = tst_args->exit_signal, + .cgroup = tst_args->cgroup, };int flags;pid_t pid =-1 ;
runtest/syscalls +1 -0
@@ -117,6 +117,7 @@ clone09 clone09 clone301 clone301 clone302 clone302 +clone303 clone303 close01 close01 close02 close02
testcases/kernel/syscalls/clone3/.gitignore +1 -0
@@ -1,2 +1,3 @@ clone301 clone302 +clone303
testcases/kernel/syscalls/clone3/clone303.c new file +95 -0
95 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
testcases/kernel/syscalls/clone3/clone303.c line 86
Quoted 7 lines · Wei Gao via ltp
testcases/kernel/syscalls/clone3/clone303.c new file +7
-0+ +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .forks_child =1 , + .max_runtime =20 ,
I removed this and merged!
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei, Richie,
Quoted 4 lines
Hello,
Wei Gao via ltp <[email protected]> writes:
Quoted 9 lines
testcases/kernel/syscalls/clone3/clone303.c line 86
Quoted 7 lines
testcases/kernel/syscalls/clone3/clone303.c new file +7
-0+ +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .forks_child =1 , + .max_runtime =20 ,I removed this and merged!
This change, merged as 45f6916ba ("clone3: Add clone3's clone_args cgroup") caused failing clone302:
tst_buffers.c:56: TINFO: Test is using guarded buffers tst_test.c:1559: TINFO: Timeout per run is 0h 00m 30s
clone302.c:101: TPASS: invalid args: clone3() failed as expected: EFAULT (14) clone302.c:101: TPASS: zero size: clone3() failed as expected: EINVAL (22) clone302.c:91: TFAIL: short size: clone3() passed unexpectedly clone302.c:101: TPASS: extra size: clone3() failed as expected: EFAULT (14) clone302.c:101: TPASS: sighand-no-VM: clone3() failed as expected: EINVAL (22) clone302.c:101: TPASS: thread-no-sighand: clone3() failed as expected: EINVAL (22) clone302.c:101: TPASS: fs-newns: clone3() failed as expected: EINVAL (22) clone302.c:101: TPASS: invalid pidfd: clone3() failed as expected: EFAULT (14) clone302.c:101: TPASS: invalid signal: clone3() failed as expected: EINVAL (22) clone302.c:101: TPASS: zero-stack-size: clone3() failed as expected: EINVAL (22) clone302.c:101: TPASS: invalid-stack: clone3() failed as expected: EINVAL (22)
Summary:
passed 10 failed 1 broken 0 skipped 0
warnings 0
### TEST clone302 COMPLETE >>> 1.
Could you please have look and fix it?
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 19 lines
Hi Wei, Richie,
Quoted 4 lines
Hello,
Wei Gao via ltp <[email protected]> writes:
Quoted 9 lines
testcases/kernel/syscalls/clone3/clone303.c line 86
Quoted 7 lines
testcases/kernel/syscalls/clone3/clone303.c new file +7
-0+ +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .forks_child =1 , + .max_runtime =20 ,I removed this and merged!
This change, merged as
45f6916ba("clone3: Add clone3'sclone_argscgroup") caused failing clone302:
Quoted 13 lines
tst_buffers.c:56: TINFO: Test is using guarded buffers tst_test.c:1559: TINFO: Timeout per run is 0h 00m 30s
clone302.c:101: TPASS: invalid args:clone3()failed as expected: EFAULT (14) clone302.c:101: TPASS: zero size:clone3()failed as expected: EINVAL (22) clone302.c:91: TFAIL: short size:clone3()passed unexpectedly clone302.c:101: TPASS: extra size:clone3()failed as expected: EFAULT (14) clone302.c:101: TPASS: sighand-no-VM:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: thread-no-sighand:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: fs-newns:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: invalid pidfd:clone3()failed as expected: EFAULT (14) clone302.c:101: TPASS: invalid signal:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: zero-stack-size:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: invalid-stack:clone3()failed as expected: EINVAL (22)
FYI include/lapi/sched.h change caused the regression.
Kind regards,
Petr
Quoted 12 lines
Summary:
passed 10 failed 1 broken 0 skipped 0warnings 0
### TEST clone302 COMPLETE >>> 1.Could you please have look and fix it?
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 34 lines · Petr Vorel
Hi Wei, Richie,
Quoted 4 lines
Hello,
Wei Gao via ltp <[email protected]> writes:
Quoted 9 lines
testcases/kernel/syscalls/clone3/clone303.c line 86
Quoted 7 lines
testcases/kernel/syscalls/clone3/clone303.c new file +7
-0+ +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .forks_child =1 , + .max_runtime =20 ,I removed this and merged!
This change, merged as
45f6916ba("clone3: Add clone3'sclone_argscgroup") caused failing clone302:tst_buffers.c:56: TINFO: Test is using guarded buffers tst_test.c:1559: TINFO: Timeout per run is 0h 00m 30s
clone302.c:101: TPASS: invalid args:clone3()failed as expected: EFAULT (14) clone302.c:101: TPASS: zero size:clone3()failed as expected: EINVAL (22) clone302.c:91: TFAIL: short size:clone3()passed unexpectedly clone302.c:101: TPASS: extra size:clone3()failed as expected: EFAULT (14) clone302.c:101: TPASS: sighand-no-VM:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: thread-no-sighand:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: fs-newns:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: invalid pidfd:clone3()failed as expected: EFAULT (14) clone302.c:101: TPASS: invalid signal:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: zero-stack-size:clone3()failed as expected: EINVAL (22) clone302.c:101: TPASS: invalid-stack:clone3()failed as expected: EINVAL (22)Summary:
Quoted 8 lines
passed 10 failed 1 broken 0 skipped 0warnings 0
### TEST clone302 COMPLETE >>> 1.Could you please have look and fix it?
No problem, i will check this.
Quoted 3 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 10 lines
Signed-off-by Wei Gao <[email protected]>--- include/lapi/sched.h | 8 ++ include/tst_cgroup.h | 4 + include/tst_clone.h | 1 + lib/tst_cgroup.c | 8 ++ lib/tst_clone.c | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/clone3/.gitignore | 1 + testcases/kernel/syscalls/clone3/clone303.c | 95 +++++++++++++++++++++
Note lib changes should have been separated from adding new test clone303.c (commit would be readable).
Quoted 16 lines
8 files changed, 119 insertions(+) create mode 100644 testcases/kernel/syscalls/clone3/clone303.cinclude/lapi/sched.h +1
-0@@ -13,6 +13,7 @@#include <inttypes.h> #include "config.h" #include "lapi/syscalls.h" +#include "lapi/sched.h" struct sched_attr {uint32_t size;
include/lapi/sched.h struct clone_args { · line 60
Quoted 6 lines
include/lapi/sched.h +3
-0@@ -54,6 +55,9 @@ 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;
Adding new members introduced warnings like this:
tst_ns_exec.c: In function ‘main’:
tst_ns_exec.c:70:16: warning: missing initializer for field ‘cgroup’ of ‘struct tst_clone_args’ [-Wmissing-field-initializers]
70 | struct tst_clone_args args = { 0, SIGCHLD };
| ^~~~~~~~~~~~~~
In file included from ../../include/tst_test.h:113,
from tst_ns_exec.c:20:
../../include/tst_clone.h:14:18: note: ‘cgroup’ declared here
14 | uint64_t cgroup;
| ^~~~~~I'm going to fix it.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp