]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup: enable task_cg_lists on the first cgroup mount
authorTejun Heo <tj@kernel.org>
Thu, 13 Feb 2014 11:58:38 +0000 (06:58 -0500)
committerTejun Heo <tj@kernel.org>
Thu, 13 Feb 2014 11:58:38 +0000 (06:58 -0500)
commitb73f04a6adb8eca9a5080d8530e8a4e00c6d6e93
tree93eec834c34d59104ca88344c9c8455060c59284
parent6b62fb14e47ed3f42c15d5e5a012a5e715137266
cgroup: enable task_cg_lists on the first cgroup mount

Tasks are not linked on their css_sets until cgroup task iteration is
actually used.  This is to avoid incurring overhead on the fork and
exit paths for systems which have cgroup compiled in but don't use it.

This lazy binding also affects the task migration path.  It has to be
careful so that it doesn't link tasks to css_sets when task_cg_lists
linking is not enabled yet.  Unfortunately, this conditional linking
in the migration path interferes with planned migration updates.

This patch moves the lazy binding a bit earlier, to the first cgroup
mount.  It's a clear indication that cgroup is being used on the
system and task_cg_lists linking is highly likely to be enabled soon
anyway through "tasks" and "cgroup.procs" files.

This allows cgroup_task_migrate() to always link @tsk->cg_list.  Note
that it may still race with cgroup_post_fork() but who wins that race
is inconsequential.

While at it, make use_task_css_set_links a bool, add sanity checks in
cgroup_enable_task_cg_lists() and css_task_iter_start(), and update
the former so that it's guaranteed and assumes to run only once.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
kernel/cgroup.c