Lines Matching refs:ctrl
216 #define for_each_ctrl(ctrl) \ argument
217 for ((ctrl) = controllers + 1; (ctrl)->ctrl_name; (ctrl)++)
226 #define for_each_dir(cg, ctrl, t) \ argument
227 for ((t) = (ctrl) ? (cg)->dirs_by_ctrl + (ctrl) : (cg)->dirs; \
229 (t) = (ctrl) ? (cg)->dirs + ROOTS_MAX : (t) + 1)
233 const struct cgroup_ctrl *const ctrl) in has_ctrl() argument
235 return !!(ctrl_field & (1 << ctrl->ctrl_indx)); in has_ctrl()
240 const struct cgroup_ctrl *const ctrl) in add_ctrl() argument
242 *ctrl_field |= 1 << ctrl->ctrl_indx; in add_ctrl()
261 static int cgroup_ctrl_on_v2(const struct cgroup_ctrl *const ctrl) in cgroup_ctrl_on_v2() argument
263 return ctrl->ctrl_root && ctrl->ctrl_root->ver == TST_CGROUP_V2; in cgroup_ctrl_on_v2()
307 const struct cgroup_ctrl *ctrl; in tst_cgroup_print_config() local
311 for_each_ctrl(ctrl) { in tst_cgroup_print_config()
312 root = ctrl->ctrl_root; in tst_cgroup_print_config()
318 ctrl->ctrl_name, in tst_cgroup_print_config()
328 struct cgroup_ctrl *ctrl = controllers; in cgroup_find_ctrl() local
330 while (ctrl->ctrl_name && strcmp(ctrl_name, ctrl->ctrl_name)) in cgroup_find_ctrl()
331 ctrl++; in cgroup_find_ctrl()
333 if (!ctrl->ctrl_name) in cgroup_find_ctrl()
334 ctrl = NULL; in cgroup_find_ctrl()
336 return ctrl; in cgroup_find_ctrl()
362 struct cgroup_ctrl *ctrl; in cgroup_root_scan() local
430 for_each_ctrl(ctrl) { in cgroup_root_scan()
431 if (has_ctrl(root->ctrl_field, ctrl)) in cgroup_root_scan()
432 ctrl->ctrl_root = root; in cgroup_root_scan()
506 static void cgroup_mount_v1(struct cgroup_ctrl *const ctrl) in cgroup_mount_v1() argument
511 sprintf(mnt_path, "%s%s", cgroup_mount_ltp_prefix, ctrl->ctrl_name); in cgroup_mount_v1()
532 if (mount(ctrl->ctrl_name, mnt_path, "cgroup", 0, ctrl->ctrl_name)) { in cgroup_mount_v1()
541 tst_res(TINFO, "Mounted V1 %s CGroup on %s", ctrl->ctrl_name, mnt_path); in cgroup_mount_v1()
543 if (!ctrl->ctrl_root) in cgroup_mount_v1()
546 ctrl->ctrl_root->we_mounted_it = 1; in cgroup_mount_v1()
547 ctrl->ctrl_root->mnt_dir.we_created_it = made_dir; in cgroup_mount_v1()
549 if (ctrl->ctrl_indx == CTRL_MEMORY) { in cgroup_mount_v1()
550 SAFE_FILE_PRINTFAT(ctrl->ctrl_root->mnt_dir.dir_fd, in cgroup_mount_v1()
602 struct cgroup_ctrl *const ctrl = cgroup_find_ctrl(ctrl_name); in tst_cgroup_require() local
605 if (!ctrl) { in tst_cgroup_require()
614 if (ctrl->we_require_it) in tst_cgroup_require()
615 tst_res(TWARN, "Duplicate %s(%s, )", __func__, ctrl->ctrl_name); in tst_cgroup_require()
617 ctrl->we_require_it = 1; in tst_cgroup_require()
619 if (ctrl->ctrl_root) in tst_cgroup_require()
624 if (ctrl->ctrl_root) in tst_cgroup_require()
630 if (ctrl->ctrl_root) in tst_cgroup_require()
633 cgroup_mount_v1(ctrl); in tst_cgroup_require()
635 if (!ctrl->ctrl_root) { in tst_cgroup_require()
638 ctrl->ctrl_name); in tst_cgroup_require()
643 root = ctrl->ctrl_root; in tst_cgroup_require()
644 add_ctrl(&root->mnt_dir.ctrl_field, ctrl); in tst_cgroup_require()
646 if (cgroup_ctrl_on_v2(ctrl)) { in tst_cgroup_require()
649 cgsc, "+%s", ctrl->ctrl_name); in tst_cgroup_require()
652 cgsc, "+%s", ctrl->ctrl_name); in tst_cgroup_require()
661 if (cgroup_ctrl_on_v2(ctrl)) { in tst_cgroup_require()
663 cgsc, "+%s", ctrl->ctrl_name); in tst_cgroup_require()
668 if (ctrl->ctrl_indx == CTRL_CPUSET) in tst_cgroup_require()
756 struct cgroup_ctrl *ctrl; in tst_cgroup_cleanup() local
789 for_each_ctrl(ctrl) { in tst_cgroup_cleanup()
790 if (!cgroup_ctrl_on_v2(ctrl) || !ctrl->ctrl_root->we_mounted_it) in tst_cgroup_cleanup()
793 SAFE_FILE_PRINTFAT(ctrl->ctrl_root->mnt_dir.dir_fd, in tst_cgroup_cleanup()
795 "-%s", ctrl->ctrl_name); in tst_cgroup_cleanup()
812 for_each_ctrl(ctrl) { in tst_cgroup_cleanup()
813 ctrl->ctrl_root = NULL; in tst_cgroup_cleanup()
814 ctrl->we_require_it = 0; in tst_cgroup_cleanup()
843 const struct cgroup_ctrl *ctrl; in cgroup_group_add_dir() local
849 for_each_ctrl(ctrl) { in cgroup_group_add_dir()
850 if (!has_ctrl(dir->ctrl_field, ctrl)) in cgroup_group_add_dir()
853 cg->dirs_by_ctrl[ctrl->ctrl_indx] = dir; in cgroup_group_add_dir()
859 "+%s", ctrl->ctrl_name); in cgroup_group_add_dir()
914 const struct cgroup_ctrl *ctrl; in cgroup_file_find() local
930 ctrl = cgroup_find_ctrl(ctrl_name); in cgroup_file_find()
932 if (!ctrl) { in cgroup_file_find()
938 for (cfile = ctrl->files; cfile->file_name; cfile++) { in cgroup_file_find()
946 file_name, ctrl->ctrl_name); in cgroup_file_find()
957 const struct cgroup_ctrl *const ctrl = cgroup_find_ctrl(ctrl_name); in tst_cgroup_ver() local
967 if (!ctrl) { in tst_cgroup_ver()
973 dir = cg->dirs_by_ctrl[ctrl->ctrl_indx]; in tst_cgroup_ver()