This can be illustrated with this usage pattern: [root@ptikh-hci-a ~]# mkdir -p /sys/fs/cgroup/test/test [root@ptikh-hci-a ~]# echo +memory > /sys/fs/cgroup/test/test/cgroup.controllers_hidden [root@ptikh-hci-a ~]# echo +memory > /sys/fs/cgroup/test/cgroup.subtree_control [root@ptikh-hci-a ~]# ls /sys/fs/cgroup/test/test/memory* ls: cannot access '/sys/fs/cgroup/test/test/memory*': No such file or directory [root@ptikh-hci-a ~]# echo -memory > /sys/fs/cgroup/test/test/cgroup.controllers_hidden [root@ptikh-hci-a ~]# ls /sys/fs/cgroup/test/test/memory* /sys/fs/cgroup/test/test/memory.cache.current /sys/fs/cgroup/test/test/memory.low /sys/fs/cgroup/test/test/memory.oom_guarantee /sys/fs/cgroup/test/test/memory.swap.high /sys/fs/cgroup/test/test/memory.cache.max /sys/fs/cgroup/test/test/memory.max /sys/fs/cgroup/test/test/memory.peak /sys/fs/cgroup/test/test/memory.swap.max /sys/fs/cgroup/test/test/memory.current /sys/fs/cgroup/test/test/memory.min /sys/fs/cgroup/test/test/memory.reclaim /sys/fs/cgroup/test/test/memory.swap.peak /sys/fs/cgroup/test/test/memory.events /sys/fs/cgroup/test/test/memory.numa_migrate /sys/fs/cgroup/test/test/memory.stat /sys/fs/cgroup/test/test/memory.zswap.current /sys/fs/cgroup/test/test/memory.events.local /sys/fs/cgroup/test/test/memory.numa_stat /sys/fs/cgroup/test/test/memory.swap.current /sys/fs/cgroup/test/test/memory.zswap.max /sys/fs/cgroup/test/test/memory.high /sys/fs/cgroup/test/test/memory.oom.group /sys/fs/cgroup/test/test/memory.swap.events /sys/fs/cgroup/test/test/memory.zswap.writeback
On 12/12/25 21:43, Pavel Tikhomirov wrote: > I intentionally made this interface independent from cgroup_ss_mask, this way > you can hide controller "in advance", even before enabling it. I.e. ve > controller is hidden by default and when it is enabled on some cgroup, css is > created but files are not populated. > > On 12/12/25 21:35, Konstantin Khorenko wrote: >> Add validation to check that controllers are enabled in cgroup_ss_mask >> before attempting to hide or show them. This prevents silent no-op >> operations and returns -ENOENT error, consistent with the validation >> logic in cgroup_subtree_control_write(). >> >> https://virtuozzo.atlassian.net/browse/VSTOR-119803 >> Signed-off-by: Konstantin Khorenko <[email protected]> >> --- >> kernel/cgroup/cgroup.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c >> index f99f1672bde8c..5ab96088eee31 100644 >> --- a/kernel/cgroup/cgroup.c >> +++ b/kernel/cgroup/cgroup.c >> @@ -4003,11 +4003,21 @@ static ssize_t >> cgroup_controllers_hidden_write(struct kernfs_open_file *of, >> hide &= ~(1 << ssid); >> continue; >> } >> + /* Validate that controller is enabled in this cgroup */ >> + if (!(cgroup_ss_mask(cgrp) & (1 << ssid))) { >> + ret = -ENOENT; >> + goto out_unlock; >> + } >> } else if (show & (1 << ssid)) { >> if (!(cgrp->hidden_ss_mask & (1 << ssid))) { >> show &= ~(1 << ssid); >> continue; >> } >> + /* Validate that controller is enabled in this cgroup */ >> + if (!(cgroup_ss_mask(cgrp) & (1 << ssid))) { >> + ret = -ENOENT; >> + goto out_unlock; >> + } >> } >> } >> > -- Best regards, Pavel Tikhomirov Senior Software Developer, Virtuozzo. _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
