]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
cgroup: get rid of cgroup_freezer_frozen_exit()
authorRoman Gushchin <guro@fb.com>
Fri, 26 Apr 2019 17:59:45 +0000 (10:59 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 6 May 2019 15:39:11 +0000 (08:39 -0700)
A task should never enter the exit path with the task->frozen bit set.
Any frozen task must enter the signal handling loop and the only
way to escape is through cgroup_leave_frozen(true), which
unconditionally drops the task->frozen bit. So it means that
cgroyp_freezer_frozen_exit() has zero chances to be called and
has to be removed.

Let's put a WARN_ON_ONCE() instead of the cgroup_freezer_frozen_exit()
call to catch any potential leak of the task's frozen bit.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
include/linux/cgroup.h
kernel/cgroup/cgroup.c
kernel/cgroup/freezer.c

index 3e2efd412dfa540884d412d7c380b8693a17f033..c0077adeea8334dc136233de439351ca3e742eff 100644 (file)
@@ -889,7 +889,7 @@ void cgroup_update_frozen(struct cgroup *cgrp);
 void cgroup_freeze(struct cgroup *cgrp, bool freeze);
 void cgroup_freezer_migrate_task(struct task_struct *task, struct cgroup *src,
                                 struct cgroup *dst);
-void cgroup_freezer_frozen_exit(struct task_struct *task);
+
 static inline bool cgroup_task_freeze(struct task_struct *task)
 {
        bool ret;
index 4fe9f7f1a3fadcfcdcbf1fa1dd3c9d2b04fabaf5..327f37c9fdfaaf4ca9ea475129fa8b28cb75fe6a 100644 (file)
@@ -5926,9 +5926,8 @@ void cgroup_exit(struct task_struct *tsk)
                css_set_move_task(tsk, cset, NULL, false);
                cset->nr_tasks--;
 
-               if (unlikely(cgroup_task_frozen(tsk)))
-                       cgroup_freezer_frozen_exit(tsk);
-               else if (unlikely(cgroup_task_freeze(tsk)))
+               WARN_ON_ONCE(cgroup_task_frozen(tsk));
+               if (unlikely(cgroup_task_freeze(tsk)))
                        cgroup_update_frozen(task_dfl_cgroup(tsk));
 
                spin_unlock_irq(&css_set_lock);
index c321e768f8d321123181a4a4800bf815aaad404d..8cf010680678949cd131c9913b5cd08e521227f9 100644 (file)
@@ -248,16 +248,6 @@ void cgroup_freezer_migrate_task(struct task_struct *task,
        cgroup_freeze_task(task, test_bit(CGRP_FREEZE, &dst->flags));
 }
 
-void cgroup_freezer_frozen_exit(struct task_struct *task)
-{
-       struct cgroup *cgrp = task_dfl_cgroup(task);
-
-       lockdep_assert_held(&css_set_lock);
-
-       cgroup_dec_frozen_cnt(cgrp);
-       cgroup_update_frozen(cgrp);
-}
-
 void cgroup_freeze(struct cgroup *cgrp, bool freeze)
 {
        struct cgroup_subsys_state *css;