@@ -94,9 +94,10 @@ enum cgroup_ctrl_indx {
94
94
CTRL_MISC ,
95
95
CTRL_PERFEVENT ,
96
96
CTRL_DEBUG ,
97
- CTRL_RDMA
97
+ CTRL_RDMA ,
98
+ CTRL_BASE
98
99
};
99
- #define CTRLS_MAX CTRL_RDMA
100
+ #define CTRLS_MAX CTRL_BASE
100
101
101
102
/* At most we can have one cgroup V1 tree for each controller and one
102
103
* (empty) v2 tree.
@@ -258,6 +259,10 @@ static const struct cgroup_file rdma_ctrl_files[] = {
258
259
{ }
259
260
};
260
261
262
+ static const struct cgroup_file base_ctrl_files [] = {
263
+ { }
264
+ };
265
+
261
266
#define CTRL_NAME_MAX 31
262
267
#define CGROUP_CTRL_MEMBER (x , y )[y] = { .ctrl_name = #x, .files = \
263
268
x ## _ctrl_files, .ctrl_indx = y, NULL, 0 }
@@ -281,6 +286,7 @@ static struct cgroup_ctrl controllers[] = {
281
286
CGROUP_CTRL_MEMBER (perf_event , CTRL_PERFEVENT ),
282
287
CGROUP_CTRL_MEMBER (debug , CTRL_DEBUG ),
283
288
CGROUP_CTRL_MEMBER (rdma , CTRL_RDMA ),
289
+ CGROUP_CTRL_MEMBER (base , CTRL_BASE ),
284
290
{ }
285
291
};
286
292
@@ -797,6 +803,10 @@ void tst_cg_require(const char *const ctrl_name,
797
803
const char * const cgsc = "cgroup.subtree_control" ;
798
804
struct cgroup_ctrl * const ctrl = cgroup_find_ctrl (ctrl_name );
799
805
struct cgroup_root * root ;
806
+ int base = !strcmp (ctrl -> ctrl_name , "base" );
807
+
808
+ if (base && options -> needs_ver != TST_CG_V2 )
809
+ tst_brk (TCONF , "Base control only support needs_ver TST_CG_V2!" );
800
810
801
811
if (!ctrl ) {
802
812
tst_brk (TBROK , "'%s' controller is unknown to LTP" , ctrl_name );
@@ -826,6 +836,9 @@ void tst_cg_require(const char *const ctrl_name,
826
836
if (options -> needs_ver != TST_CG_V2 )
827
837
cgroup_mount_v1 (ctrl );
828
838
839
+ if (base )
840
+ ctrl -> ctrl_root = roots ;
841
+
829
842
if (!ctrl -> ctrl_root ) {
830
843
tst_brk (TCONF ,
831
844
"'%s' controller required, but not available" ,
@@ -848,7 +861,7 @@ void tst_cg_require(const char *const ctrl_name,
848
861
ctrl -> ctrl_name );
849
862
}
850
863
851
- if (cgroup_ctrl_on_v2 (ctrl )) {
864
+ if (cgroup_ctrl_on_v2 (ctrl ) && ! base ) {
852
865
if (root -> we_mounted_it ) {
853
866
SAFE_FILE_PRINTFAT (root -> mnt_dir .dir_fd ,
854
867
cgsc , "+%s" , ctrl -> ctrl_name );
@@ -863,15 +876,17 @@ void tst_cg_require(const char *const ctrl_name,
863
876
else
864
877
root -> ltp_dir .ctrl_field |= root -> mnt_dir .ctrl_field ;
865
878
866
- if (cgroup_ctrl_on_v2 (ctrl )) {
867
- SAFE_FILE_PRINTFAT (root -> ltp_dir .dir_fd ,
868
- cgsc , "+%s" , ctrl -> ctrl_name );
869
- } else {
870
- SAFE_FILE_PRINTFAT (root -> ltp_dir .dir_fd ,
871
- "cgroup.clone_children" , "%d" , 1 );
879
+ if (!base ) {
880
+ if (cgroup_ctrl_on_v2 (ctrl )) {
881
+ SAFE_FILE_PRINTFAT (root -> ltp_dir .dir_fd ,
882
+ cgsc , "+%s" , ctrl -> ctrl_name );
883
+ } else {
884
+ SAFE_FILE_PRINTFAT (root -> ltp_dir .dir_fd ,
885
+ "cgroup.clone_children" , "%d" , 1 );
872
886
873
- if (ctrl -> ctrl_indx == CTRL_CPUSET )
874
- cgroup_copy_cpuset (root );
887
+ if (ctrl -> ctrl_indx == CTRL_CPUSET )
888
+ cgroup_copy_cpuset (root );
889
+ }
875
890
}
876
891
877
892
cgroup_dir_mk (& root -> ltp_dir , cgroup_ltp_drain_dir , & root -> drain_dir );
@@ -996,7 +1011,8 @@ void tst_cg_cleanup(void)
996
1011
}
997
1012
998
1013
for_each_ctrl (ctrl ) {
999
- if (!cgroup_ctrl_on_v2 (ctrl ) || !ctrl -> ctrl_root -> we_mounted_it )
1014
+ if (!cgroup_ctrl_on_v2 (ctrl ) || !ctrl -> ctrl_root -> we_mounted_it
1015
+ || !strcmp (ctrl -> ctrl_name , "base" ))
1000
1016
continue ;
1001
1017
1002
1018
SAFE_FILE_PRINTFAT (ctrl -> ctrl_root -> mnt_dir .dir_fd ,
@@ -1049,8 +1065,10 @@ static void cgroup_group_add_dir(const struct tst_cg_group *const parent,
1049
1065
if (!parent || dir -> dir_root -> ver == TST_CG_V1 )
1050
1066
continue ;
1051
1067
1052
- SAFE_CG_PRINTF (parent , "cgroup.subtree_control" ,
1053
- "+%s" , ctrl -> ctrl_name );
1068
+ if (strcmp (ctrl -> ctrl_name , "base" )) {
1069
+ SAFE_CG_PRINTF (parent , "cgroup.subtree_control" ,
1070
+ "+%s" , ctrl -> ctrl_name );
1071
+ }
1054
1072
}
1055
1073
1056
1074
for (i = 0 ; cg -> dirs [i ]; i ++ )
0 commit comments