Re: [LTP] [PATCH v1] tst_cgroup.c: Force tst_cg_scan only scan specific cgroup version if needs_ver exist

Wei Gao via ltp
2024-11-11T02:47:36Z

On Fri, Nov 08, 2024 at 12:23:48PM +0100, Cyril Hrubis wrote:
> Hi!
> > If you add .needs_cgroup_ver = TST_CG_V1 in cpuset02.c and running on sle-micro you will hit
> > https://github.com/linux-test-project/ltp/blob/6408294d83682635393e36c14bbd6ebd94fead94/lib/tst_cgroup.c#L892
> >
> > Since sle-micro platform already create cgroupv2 mount point, the tst_cg_scan will get cgroupv2 info and
> > will not call cgroup_mount_v1.
>
> And that is, as far as I can tell, correct. You cannot mount a
> controller under v1 when it was already mounted under v2.
On sle-micro 6.1, you can mount v1 controller when it was already mounted under v2
And after you force mount v1 cpuset controller, the v2 cpuset controller will be removed

localhost:~ # mount | grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)

localhost:~ # ll /sys/fs/cgroup/
total 0
-r--r--r-- 1 root root 0 Nov 11 01:39 cgroup.controllers
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.max.depth
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.max.descendants
-rw-r--r-- 1 root root 0 Nov 11 01:39 cgroup.procs
-r--r--r-- 1 root root 0 Nov 11 01:44 cgroup.stat
-rw-r--r-- 1 root root 0 Nov 11 01:39 cgroup.subtree_control
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.threads
-r--r--r-- 1 root root 0 Nov 11 01:44 cpu.stat
-r--r--r-- 1 root root 0 Nov 11 01:44 cpu.stat.local
-r--r--r-- 1 root root 0 Nov 11 01:44 cpuset.cpus.effective <<<<
-r--r--r-- 1 root root 0 Nov 11 01:44 cpuset.mems.effective <<<<
drwxr-xr-x 2 root root 0 Nov 11 01:39 dev-hugepages.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 dev-mqueue.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 init.scope
-rw-r--r-- 1 root root 0 Nov 11 01:44 io.cost.model
-rw-r--r-- 1 root root 0 Nov 11 01:44 io.cost.qos
-r--r--r-- 1 root root 0 Nov 11 01:44 io.stat
drwxr-xr-x 2 root root 0 Nov 11 01:39 machine.slice
-r--r--r-- 1 root root 0 Nov 11 01:44 memory.numa_stat
--w------- 1 root root 0 Nov 11 01:44 memory.reclaim
-r--r--r-- 1 root root 0 Nov 11 01:44 memory.stat
-r--r--r-- 1 root root 0 Nov 11 01:44 misc.capacity
drwxr-xr-x 2 root root 0 Nov 11 01:39 proc-fs-nfsd.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-fs-fuse-connections.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-kernel-config.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-kernel-debug.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-kernel-tracing.mount
drwxr-xr-x 40 root root 0 Nov 11 01:42 system.slice
drwxr-xr-x 2 root root 0 Nov 11 01:39 user.slice

localhost:/tmp # mkdir /var/tmp/cpuset
localhost:/tmp # mount -t cgroup -o cpuset cpuset /var/tmp/cpuset <<<<<<
localhost:/tmp # ll /var/tmp/cpuset/
total 0
-rw-r--r-- 1 root root 0 Nov 11 01:53 cgroup.clone_children
-rw-r--r-- 1 root root 0 Nov 11 01:53 cgroup.procs
-r--r--r-- 1 root root 0 Nov 11 01:53 cgroup.sane_behavior
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.cpu_exclusive
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.cpus
-r--r--r-- 1 root root 0 Nov 11 01:53 cpuset.effective_cpus
-r--r--r-- 1 root root 0 Nov 11 01:53 cpuset.effective_mems
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.mem_exclusive
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.mem_hardwall
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.memory_migrate
-r--r--r-- 1 root root 0 Nov 11 01:53 cpuset.memory_pressure
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.memory_pressure_enabled
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.memory_spread_page
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.memory_spread_slab
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.mems
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.sched_load_balance <<<<<<
-rw-r--r-- 1 root root 0 Nov 11 01:53 cpuset.sched_relax_domain_level
-rw-r--r-- 1 root root 0 Nov 11 01:53 notify_on_release
-rw-r--r-- 1 root root 0 Nov 11 01:53 release_agent
-rw-r--r-- 1 root root 0 Nov 11 01:53 tasks

localhost:/tmp # ll /sys/fs/cgroup/
total 0
-r--r--r-- 1 root root 0 Nov 11 01:44 cgroup.controllers
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.max.depth
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.max.descendants
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.procs
-r--r--r-- 1 root root 0 Nov 11 01:44 cgroup.stat
-rw-r--r-- 1 root root 0 Nov 11 01:39 cgroup.subtree_control
-rw-r--r-- 1 root root 0 Nov 11 01:44 cgroup.threads
-r--r--r-- 1 root root 0 Nov 11 01:44 cpu.stat
-r--r--r-- 1 root root 0 Nov 11 01:44 cpu.stat.local
drwxr-xr-x 2 root root 0 Nov 11 01:39 dev-hugepages.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 dev-mqueue.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 init.scope
-rw-r--r-- 1 root root 0 Nov 11 01:44 io.cost.model
-rw-r--r-- 1 root root 0 Nov 11 01:44 io.cost.qos
-r--r--r-- 1 root root 0 Nov 11 01:44 io.stat
drwxr-xr-x 2 root root 0 Nov 11 01:39 machine.slice
-r--r--r-- 1 root root 0 Nov 11 01:44 memory.numa_stat
--w------- 1 root root 0 Nov 11 01:44 memory.reclaim
-r--r--r-- 1 root root 0 Nov 11 01:44 memory.stat
-r--r--r-- 1 root root 0 Nov 11 01:44 misc.capacity
drwxr-xr-x 2 root root 0 Nov 11 01:39 proc-fs-nfsd.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-fs-fuse-connections.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-kernel-config.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-kernel-debug.mount
drwxr-xr-x 2 root root 0 Nov 11 01:39 sys-kernel-tracing.mount
drwxr-xr-x 40 root root 0 Nov 11 02:01 system.slice
drwxr-xr-x 2 root root 0 Nov 11 01:39 user.slice

localhost:/tmp # mount | grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
cpuset on /var/tmp/cpuset type cgroup (rw,relatime,cpuset)

>
> --
> Cyril Hrubis
> chrubis@suse.cz