sched_rr_get_interval01.c: Put test process into absolute root cgroup (0::/)
Subsystems (2)
PATCH 1/1 sched_rr_get_interval01.c: Put test process into absolute root cgroup (0::/)
When the CONFIG_RT_GROUP_SCHED=y config is set, test cases like sched_rr_get_interval01 will failed since limitation of RT processes with cgroup v2 cpu controller. The limitation is RT processes have to be in the root cgroup before enabling cpu controller. By default the shell will not running in root cgroup "0::/" since systemd will put shell into 0::/user.slice/user-xx.slice/session-xx.scope, so ltp case run within shell will failed. We can use this patch to workaround above limitation. If we agree on this patch, i will continue do same patch to following cases:sched_rr_get_interval02sched_rr_get_interval03sched_setparam02sched_getscheduler01
--- .../sched_rr_get_interval/sched_rr_get_interval01.c | 6 ++++++ 1 file changed, 6 insertions(+)
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +6 -0
@@ -43,6 +43,12 @@ static void setup(void) tp.type = tv->ts_type; +if (access ("/sys/fs/cgroup/cgroup.controllers" ,F_OK ) ==0 ) { +int pid =getpid (); + +SAFE_FILE_PRINTF ("/sys/fs/cgroup/cgroup.procs" ,"%d" , pid); + } +if ((sys_sched_setscheduler (0 ,SCHED_RR , &p)) ==-1 )tst_res (TFAIL |TERRNO ,"sched_setscheduler() failed" );
Signature · 5 lines
2.49.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei, all,
Quoted 11 lines
When the
CONFIG_RT_GROUP_SCHED=yconfig is set, test cases likesched_rr_get_interval01will failed since limitation of RT processes with cgroup v2 cpu controller. The limitation is RT processes have to be in the root cgroup before enabling cpu controller. By default the shell will not running in root cgroup "0::/" since systemd will put shell into 0::/user.slice/user-xx.slice/session-xx.scope, so ltp case run within shell will failed. We can use this patch to workaround above limitation. If we agree on this patch, i will continue do same patch to following cases:sched_rr_get_interval02sched_rr_get_interval03sched_setparam02sched_getscheduler01
LGTM.
@Michal @Li WDYT?
Kind regards,
Petr
Quoted 22 lines
Signed-off-by Wei Gao <[email protected]>--- .../sched_rr_get_interval/sched_rr_get_interval01.c | 6 ++++++ 1 file changed, 6 insertions(+)testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +6
-0@@ -43,6 +43,12 @@ static void setup(void) tp.type = tv->ts_type; +if (access ("/sys/fs/cgroup/cgroup.controllers" ,F_OK ) ==0 ) { +int pid =getpid (); + +SAFE_FILE_PRINTF ("/sys/fs/cgroup/cgroup.procs" ,"%d" , pid); + } +if ((sys_sched_setscheduler (0 ,SCHED_RR , &p)) ==-1 )tst_res (TFAIL |TERRNO ,"sched_setscheduler() failed" );
Andrea Cervesato
AppliedMerged, thanks.
- Andrea
Michal Koutný
maintainerQuoted 1 line · Petr Vorel
@Michal @Li WDYT?
RT_GROUP scheduling is v1 feature as of now.
Testing cgroup v2 makes only sense with CONFIG_RT_GROUP_SCHED=y and CONFIG_RT_GROUP_SCHED_DEFAULT_DISABLED=y (this combination is equivalent to CONFIG_RT_GROUP_SCHED=n on v2).
HTH,
Michal
@Michal Koutný <[email protected]> So we should skip test cgroupv2 withCONFIG_RT_GROUP_SCHED=yes, correct? Like following change?
diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c index 55516ec89..b12bd7857 100644
---a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
+++b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c @@ -43,10 +43,9 @@ static void setup(void)
tp.type = tv->ts_type;
+ static const char * const kconf[] = {"CONFIG_RT_GROUP_SCHED=y",
NULL};
+ if ((access("/sys/fs/cgroup/cgroup.controllers", F_OK) == 0) &&
!tst_kconfig_check(kconf_strict)) {
+ tst_brk(TCONF, "CONFIG_RT_GROUP_SCHED not support on
cgroupv2");
+ }
if ((sys_sched_setscheduler(0, SCHED_RR, &p)) == -1)
Quoted 13 lines · Michal Koutný
Quoted 1 line · Petr Vorel
@Michal @Li WDYT?
RT_GROUPscheduling is v1 feature as of now.Testing cgroup v2 makes only sense with
CONFIG_RT_GROUP_SCHED=yandCONFIG_RT_GROUP_SCHED_DEFAULT_DISABLED=y(this combination is equivalent toCONFIG_RT_GROUP_SCHED=non v2).HTH,
Michal
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 8 lines · Michal Koutný
Quoted 1 line · Petr Vorel
@Michal @Li WDYT?
RT_GROUPscheduling is v1 feature as of now.Testing cgroup v2 makes only sense with
CONFIG_RT_GROUP_SCHED=yandCONFIG_RT_GROUP_SCHED_DEFAULT_DISABLED=y(this combination is equivalent toCONFIG_RT_GROUP_SCHED=non v2).
@Michal Koutný So we should skip test cgroupv2 with CONFIG_RT_GROUP_SCHED=yes, correct? Like following change?
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +4 -0
@@ -43,10 +43,9 @@ static void setup(void) tp.type = tv->ts_type; +static const char *const kconf[] = {"CONFIG_RT_GROUP_SCHED=y" ,NULL }; +if ((access ("/sys/fs/cgroup/cgroup.controllers" ,F_OK ) ==0 ) && !tst_kconfig_check (kconf_strict)) { +tst_brk (TCONF ,"CONFIG_RT_GROUP_SCHED not support on cgroupv2" ); + }
Quoted 3 lines
HTH,
Michal
Michal Koutný
maintainerQuoted 1 line · Wei Gao
@Michal Koutný So we should skip test cgroupv2 with
CONFIG_RT_GROUP_SCHED=yes, correct?
Ideally, no one should run v2 with CONFIG_RT_GROUP_SCHED=y, so this would never fail :-p
Quoted 1 line
Like following change?
But if there are such poor souls, that skip should make the test not obstruct the rest of LTP.
Thanks,
Michal
Hi all,
Quoted 5 lines · Wei Gao
Quoted 1 line
@Michal Koutný So we should skip test cgroupv2 with
CONFIG_RT_GROUP_SCHED=yes, correct?Ideally, no one should run v2 with
CONFIG_RT_GROUP_SCHED=y, so this would never fail :-p
@Michal thanks for a clarification. It's default n and Documentation/scheduler/sched-rt-group.rst which mentions CONFIG_RT_GROUP_SCHED also mentions Documentation/admin-guide/cgroup-v1/cgroups.rst, that should be a good hint for people changing the defaults :).
Also, there are 3 old mips and sh boards which set CONFIG_RT_GROUP_SCHED=y. Probably nobody cares much nowadays, but maybe it should be deleted.
Quoted 4 lines
Quoted 1 line
Like following change?
But if there are such poor souls, that skip should make the test not obstruct the rest of LTP.
@Andrea, you claimed it's merged, but maybe you reply to a wrong thread because it's not merged.
https://lore.kernel.org/ltp/[email protected]/
I agree with Cyril to have a custom function in lib/tst_cgroup.c, which would be called by affected tests.
Kind regards,
Petr
Quoted 2 lines
Thanks,
Michal
Hi!
Quoted 5 lines
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +0
-0
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c static void setup(void) · line 51
Quoted 9 lines
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +6
-0@@ -43,6 +43,12 @@ static void setup(void) tp.type = tv->ts_type; +if (access ("/sys/fs/cgroup/cgroup.controllers" ,F_OK ) ==0 ) { +int pid =getpid (); + +SAFE_FILE_PRINTF ("/sys/fs/cgroup/cgroup.procs" ,"%d" , pid); + } +
If we are going to fix more than one test it would make sense to put this code somewhere in a common header in the top level include/.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 tst_cgroup.c: Skip cases which testing cgroup v2 with CONFIG_RT_GROUP_SCHED=y
In reply to Wei Gao via ltpRT_GROUP scheduling is cgroup v1 feature as of now. So we need skip test cases for cgroup v2 with CONFIG_RT_GROUP_SCHED=y.
Skip cases list:sched_rr_get_interval01sched_rr_get_interval02sched_rr_get_interval03sched_setparam02sched_getscheduler01
--- include/tst_cgroup.h | 2 ++ lib/tst_cgroup.c | 11 +++++++++++ .../sched_getscheduler/sched_getscheduler01.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval01.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval02.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval03.c | 2 ++ .../kernel/syscalls/sched_setparam/sched_setparam02.c | 2 ++ 7 files changed, 23 insertions(+)
include/tst_cgroup.h +2 -0
@@ -256,4 +256,6 @@ int safe_cg_occursin(const char *file, const int lineno,int tst_cg_memory_recursiveprot (struct tst_cg_group *cg); +void tst_check_rt_group_sched_support (void ); +#endif /* TST_CGROUP_H */
lib/tst_cgroup.c +11 -0
@@ -16,6 +16,7 @@#include "lapi/fcntl.h" #include "lapi/mount.h" #include "tst_safe_file_at.h" +#include "tst_kconfig.h" struct cgroup_root ;
@@ -1531,3 +1532,13 @@ int tst_cg_memory_recursiveprot(struct tst_cg_group *cg)return cg->dirs_by_ctrl[0 ]->dir_root->memory_recursiveprot;return 0 ; } + +void tst_check_rt_group_sched_support (void ) +{ +static const char *const kconf[] = {"CONFIG_RT_GROUP_SCHED=y" ,NULL }; + +if ((access ("/sys/fs/cgroup/cgroup.controllers" ,F_OK ) ==0 ) && !tst_kconfig_check (kconf)) { +tst_brk (TCONF ,"CONFIG_RT_GROUP_SCHED not support on cgroupv2" ); + } + +}
testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c +2 -0
@@ -39,6 +39,8 @@ static void run(unsigned int n)struct test_cases_t *tc = &tcases[n];struct sched_param p = { .sched_priority = tc->priority }; +tst_check_rt_group_sched_support (); +TST_EXP_PASS_SILENT (tv->sched_setscheduler (0 , tc->policy, &p));if (!TST_PASS )
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +2 -0
@@ -43,6 +43,8 @@ static void setup(void) tp.type = tv->ts_type; +tst_check_rt_group_sched_support (); +if ((sys_sched_setscheduler (0 ,SCHED_RR , &p)) ==-1 )tst_res (TFAIL |TERRNO ,"sched_setscheduler() failed" );
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c +2 -0
@@ -36,6 +36,8 @@ static void setup(void) tp.type = tv->ts_type; +tst_check_rt_group_sched_support (); +if ((sys_sched_setscheduler (0 ,SCHED_FIFO , &p)) ==-1 )tst_res (TFAIL |TERRNO ,"sched_setscheduler() failed" ); }
testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c +2 -0
@@ -59,6 +59,8 @@ static void setup(void) bad_addr =tst_get_bad_addr (NULL ); tp.type = tv->ts_type; +tst_check_rt_group_sched_support (); +if ((sys_sched_setscheduler (0 ,SCHED_RR , &p)) ==-1 )tst_res (TFAIL |TERRNO ,"sched_setscheduler() failed" );
testcases/kernel/syscalls/sched_setparam/sched_setparam02.c +2 -0
@@ -36,6 +36,8 @@ static void run(unsigned int n)struct sched_variant *tv = &sched_variants[tst_variant];struct sched_param p = { .sched_priority = tc->param }; +tst_check_rt_group_sched_support (); +TST_EXP_PASS_SILENT (tv->sched_setscheduler (0 , tc->policy, &p)); p.sched_priority = tc->priority;
Signature · 5 lines
2.49.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] tst_cgroup.c: Skip cases which testing cgroup v2 with CONFIG_RT_GROUP_SCHED=y
Quoted 59 lines · Wei Gao via ltp
RT_GROUPscheduling is cgroup v1 feature as of now. So we need skip test cases
for cgroup v2 withCONFIG_RT_GROUP_SCHED=y.Skip cases list:
sched_rr_get_interval01sched_rr_get_interval02sched_rr_get_interval03sched_setparam02sched_getscheduler01Signed-off-by Wei Gao <[email protected]>--- include/tst_cgroup.h | 2 ++ lib/tst_cgroup.c | 11 +++++++++++ .../sched_getscheduler/sched_getscheduler01.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval01.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval02.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval03.c | 2 ++ .../kernel/syscalls/sched_setparam/sched_setparam02.c | 2 ++ 7 files changed, 23 insertions(+)include/tst_cgroup.h +2
-0@@ -256,4 +256,6 @@ int safe_cg_occursin(const char *file, const int lineno, int tst_cg_memory_recursiveprot(struct tst_cg_group *cg); +void tst_check_rt_group_sched_support (void ); +#endif /*
TST_CGROUP_H*/lib/tst_cgroup.c +5
-0@@ -16,6 +16,7 @@#include "lapi/fcntl.h" #include "lapi/mount.h" #include "tst_safe_file_at.h" +#include "tst_kconfig.h" struct cgroup_root ;@@ -1531,3 +1532,13 @@ int tst_cg_memory_recursiveprot(struct tst_cg_group *cg)return cg->dirs_by_ctrl[0 ]->dir_root->memory_recursiveprot;return 0 ; } + +void tst_check_rt_group_sched_support (void ) +{ +static const char *const kconf[] = {"CONFIG_RT_GROUP_SCHED=y" ,NULL};
lib/tst_cgroup.c +2
-0+ + if ((access("/sys/fs/cgroup/cgroup.controllers", F_OK) == 0) &&
Quoted 2 lines
!tst_kconfig_check(kconf)) {
Here is what we assume the cgrup v2 default mount path, but better to use cgroup_v2_mounted() in case some test env is not mount cgroup on the path.
I made the below change and pushed:
lib/tst_cgroup.c +0 -0
@@ -1537,7 +1537,9 @@ void tst_check_rt_group_sched_support(void) {static const char *const kconf[] = {"CONFIG_RT_GROUP_SCHED=y" ,
NULL};
- if (cgroup_v2_mounted() && !tst_kconfig_check(kconf)) {
+ tst_cg_scan();
+
+ if (cgroup_v2_mounted() && tst_kconfig_check(kconf)) {
tst_brk(TCONF, "CONFIG_RT_GROUP_SCHED not support on
cgroupv2");
}Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] tst_cgroup.c: Skip cases which testing cgroup v2 with CONFIG_RT_GROUP_SCHED=y
Quoted 87 lines · Li Wang
Quoted 60 lines · Wei Gao via ltp
RT_GROUPscheduling is cgroup v1 feature as of now. So we need skip test cases
for cgroup v2 withCONFIG_RT_GROUP_SCHED=y.Skip cases list:
sched_rr_get_interval01sched_rr_get_interval02sched_rr_get_interval03sched_setparam02sched_getscheduler01Signed-off-by Wei Gao <[email protected]>--- include/tst_cgroup.h | 2 ++ lib/tst_cgroup.c | 11 +++++++++++ .../sched_getscheduler/sched_getscheduler01.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval01.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval02.c | 2 ++ .../sched_rr_get_interval/sched_rr_get_interval03.c | 2 ++ .../kernel/syscalls/sched_setparam/sched_setparam02.c | 2 ++ 7 files changed, 23 insertions(+)include/tst_cgroup.h +2
-0@@ -256,4 +256,6 @@ int safe_cg_occursin(const char *file, const int lineno, int tst_cg_memory_recursiveprot(struct tst_cg_group *cg); +void tst_check_rt_group_sched_support (void ); +#endif /*
TST_CGROUP_H*/lib/tst_cgroup.c +5
-0@@ -16,6 +16,7 @@#include "lapi/fcntl.h" #include "lapi/mount.h" #include "tst_safe_file_at.h" +#include "tst_kconfig.h" struct cgroup_root ;@@ -1531,3 +1532,13 @@ int tst_cg_memory_recursiveprot(struct tst_cg_group *cg)return cg->dirs_by_ctrl[0 ]->dir_root->memory_recursiveprot;return 0 ; } + +void tst_check_rt_group_sched_support (void ) +{ +static const char *const kconf[] = {"CONFIG_RT_GROUP_SCHED=y" ,NULL};
lib/tst_cgroup.c +2
-0+ + if ((access("/sys/fs/cgroup/cgroup.controllers", F_OK) == 0) &&Quoted 2 lines
!tst_kconfig_check(kconf)) {
Here is what we assume the cgrup v2 default mount path, but better to use
cgroup_v2_mounted()in case some test env is not mount cgroup on the path.I made the below change and pushed:
lib/tst_cgroup.c +3
-1@@ -1537,7 +1537,9 @@ void tst_check_rt_group_sched_support(void) {static const char *const kconf[] = {"CONFIG_RT_GROUP_SCHED=y" ,NULL }; -if (cgroup_v2_mounted () && !tst_kconfig_check (kconf)) { +tst_cg_scan (); + +if (cgroup_v2_mounted () &&tst_kconfig_check (kconf)) {tst_brk (TCONF ,"CONFIG_RT_GROUP_SCHED not support on cgroupv2");
Quoted 2 lines
}
Sorry, I copied the wrong content from my test machine, the merged patch is actually like:
https://github.com/linux-test-project/ltp/commit/1bddde12f1d7b96d5c7a2157877330bbeb9b26d9
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp