Bug 89022 - Some cgroups cleared of processes on daemon-reload.
Summary: Some cgroups cleared of processes on daemon-reload.
Status: RESOLVED NOTABUG
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-07 17:13 UTC by xstill
Modified: 2015-02-10 11:45 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description xstill 2015-02-07 17:13:14 UTC
Hi,

When I create cgroups using filesystem interface and add some processes into them, and later do 'systemctl daemon-reload' and 'systemctl start multi-user.target', in some hierarchies processes are moved from those cgroups, while in other processes stay (no cgroups are deleted though).

Here is a way to reproduce this behavior:

# systemctl --version
systemd 217
+PAM -AUDIT -SELINUX +IMA -APPARMOR +SMACK -SYSVINIT +UTMP -LIBCRYPTSETUP +GCRYPT -GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD -IDN 
# mkdir /sys/fs/cgroup/{blkio,cpu,cpuset,devices,freezer,memory,net_cls}/group
# echo 0-3 > /sys/fs/cgroup/cpuset/group/cpuset.cpus 
# echo 0 > /sys/fs/cgroup/cpuset/group/cpuset.mems
# echo $$ | tee /sys/fs/cgroup/{blkio,cpu,cpuset,devices,freezer,memory,net_cls}/group/tasks
19823
# for t in /sys/fs/cgroup/{blkio,cpu,cpuset,devices,freezer,memory,net_cls}/group/tasks; do echo $t; cat $t; done
/sys/fs/cgroup/blkio/group/tasks
19823
20019
/sys/fs/cgroup/cpu/group/tasks
19823
20020
/sys/fs/cgroup/cpuset/group/tasks
19823
20021
/sys/fs/cgroup/devices/group/tasks
19823
20022
/sys/fs/cgroup/freezer/group/tasks
19823
20023
/sys/fs/cgroup/memory/group/tasks
19823
20024
/sys/fs/cgroup/net_cls/group/tasks
19823
20025
# systemctl daemon-reload 
# systemctl start multi-user.target
# for t in /sys/fs/cgroup/{blkio,cpu,cpuset,devices,freezer,memory,net_cls}/group/tasks; do echo $t; cat $t; done
/sys/fs/cgroup/blkio/group/tasks
/sys/fs/cgroup/cpu/group/tasks
/sys/fs/cgroup/cpuset/group/tasks
19823
20041
/sys/fs/cgroup/devices/group/tasks
/sys/fs/cgroup/freezer/group/tasks
19823
20043
/sys/fs/cgroup/memory/group/tasks
/sys/fs/cgroup/net_cls/group/tasks
19823
20045



I have read some bug reports regarding cg_trim behavior, especially https://bugzilla.redhat.com/show_bug.cgi?id=1139223 which might be related, but the difference is that
1) cgroups are not deleted, processes are just moved away from them
2) in this case cgroups are created manually
3) different hierarchies behave differently

This is big problem when using cgroups to limit user resources, not resources of systemd units.
Comment 1 Lennart Poettering 2015-02-10 11:45:45 UTC
systemd manages the cgroup hierarchy and moves processes around in it, that is expected.

The only places where it's OK to manipulate the tree directly is:

a) when you run in a service or scope with Delegate=yes

b) on controller hierarchies systemd doesn't manager

c) when you stick to changing attributes systemd doesn't support natively, but don't touch the hiearchy or process assignemnts.

Other than that the cgroup tree is a single-writer hierarchy. if you modify it overriding what systemd does you are on your own


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.