Provide an option for users to replace the default idle_thread created
for systemd scope. With '-r' option specified, the first pid passed as
the argument to cgclassify will replace the default idle_thread, if it
exists. Also, if it's the only task, killing it will remove the .scope
cgroup it's running in.
For non scope cgroups, it launches the task program. The algorithm in
brief is as follows:
Once the first pid of argument list migrated to the expected cgroup(s):
1. The controller, cgroups details of the pid is captured before the
migration, so incase an error occurs, it easy to roll back to the
original cgroups the pid belonged to.
2. Once the migrated is done, parse /proc/<pid>/cgroup of the first
pid and if the cgroup name ends with .scope and has a task with
/proc/<pid>/cmdline as "libcgroup_systemd_idle_thread", kill
the task. This gives the illusion of replacement.
3. If an error occurs, migrate the pid back to the original cgroups.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>