Menu

#58 cgclassify no longer place individual threads

v1.0 (example)
open
nobody
None
5
2019-12-06
2019-12-06
No

cgclassify used to place individual threads (still does in the latest official release). However using the git HEAD all tasks move at once. I created a simple threaded program to show this:

root@debian:~/cgbug/libcgroups# pstree -lp |grep threads
           |               |-threads(19384)-+-{threads}(19385)
           |               |                `-{threads}(19386)
root@debian:~/cgbug/libcgroups# cat /sys/fs/cgroup/cpuset/test/tasks
root@debian:~/cgbug/libcgroups# src/tools/cgclassify -g cpuset:/test 19386
root@debian:~/cgbug/libcgroups# cat /sys/fs/cgroup/cpuset/test/tasks
19384
19385
19386
root@debian:~/cgbug/libcgroups# 

The latest official release which comes with Debian Buster (10) works as expected:

root@debian:~/cgbug/libcgroups# cat /sys/fs/cgroup/cpuset/test/tasks
root@debian:~/cgbug/libcgroups# cgclassify -g cpuset:/test 19386
root@debian:~/cgbug/libcgroups# cat /sys/fs/cgroup/cpuset/test/tasks
19386
root@debian:~/cgbug/libcgroups#

This is an odd change considering it's very easy to move all tasks of a pid, but there is no way to move a single task any more - even the api has changed its behavior...

Here again using the old version, with one command I pass all pids at once:

root@debian:~/cgbug/libcgroups# cat /sys/fs/cgroup/cpuset/test/tasks
root@debian:~/cgbug/libcgroups# ls /proc/19386/task/|xargs cgclassify -g cpuset:/test
root@debian:~/cgbug/libcgroups# cat /sys/fs/cgroup/cpuset/test/tasks
19384
19385
19386
root@debian:~/cgbug/libcgroups#

If that functionality is desired regardless then it should be a switch / new api call, not a breaking change. Multi-threadded programs may rely on cgclassify or its underlying api call, cgroup_change_cgroup_path() to place their threads at the right place and this is no longer possible.

Discussion

  • Thomas Guyot-Sionnest

    And FWIW that change was introduced with commit g16f2fc1

     
    • Nikola Forró

      Nikola Forró - 2019-12-06

      The original motivation behind the change was that tools respecting cgrules.conf had only been able to change cgroup of the main thread of a process matching specified rules.

      I didn't see the use case for having individual threads in different cgroups, but that was probably a mistake.

      I see two options:

      • keep the change, but make necessary adjustments so that individual threads can still be moved
      • move the change to cgroup_change_cgroup_flags(), so it's in effect only when processing the rules from cgrules.conf
       

Log in to post a comment.

MongoDB Logo MongoDB