提交 0cd9d33a 编写于 作者: T Tejun Heo

cgroup: init_tasks shouldn't be linked to the root cgroup

5153faac ("cgroup: remove cgroup_enable_task_cg_lists()
optimization") removed lazy initialization of css_sets so that new
tasks are always lniked to its css_set. In the process, it incorrectly
ended up adding init_tasks to root css_set. They show up as PID 0's in
root's cgroup.procs triggering warnings in systemd and generally
confusing people.

Fix it by skip css_set linking for init_tasks.
Signed-off-by: NTejun Heo <tj@kernel.org>
Reported-by: https://github.com/joanbm
Link: https://github.com/systemd/systemd/issues/14682
Fixes: 5153faac ("cgroup: remove cgroup_enable_task_cg_lists() optimization")
Cc: stable@vger.kernel.org # v5.5+
上级 39bed42d
...@@ -5932,11 +5932,14 @@ void cgroup_post_fork(struct task_struct *child) ...@@ -5932,11 +5932,14 @@ void cgroup_post_fork(struct task_struct *child)
spin_lock_irq(&css_set_lock); spin_lock_irq(&css_set_lock);
WARN_ON_ONCE(!list_empty(&child->cg_list)); /* init tasks are special, only link regular threads */
cset = task_css_set(current); /* current is @child's parent */ if (likely(child->pid)) {
get_css_set(cset); WARN_ON_ONCE(!list_empty(&child->cg_list));
cset->nr_tasks++; cset = task_css_set(current); /* current is @child's parent */
css_set_move_task(child, NULL, cset, false); get_css_set(cset);
cset->nr_tasks++;
css_set_move_task(child, NULL, cset, false);
}
/* /*
* If the cgroup has to be frozen, the new task has too. Let's set * If the cgroup has to be frozen, the new task has too. Let's set
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册