From: Honglei Wang Date: Wed, 30 Oct 2019 08:18:10 +0000 (+0800) Subject: cgroup: freezer: don't change task and cgroups status unnecessarily X-Git-Tag: v5.10.7~3842^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=742e8cd3e1ba6f19cad6d912f8d469df5557d0fd;p=platform%2Fkernel%2Flinux-rpi.git cgroup: freezer: don't change task and cgroups status unnecessarily It's not necessary to adjust the task state and revisit the state of source and destination cgroups if the cgroups are not in freeze state and the task itself is not frozen. And in this scenario, it wakes up the task who's not supposed to be ready to run. Don't do the unnecessary task state adjustment can help stop waking up the task without a reason. Signed-off-by: Honglei Wang Acked-by: Roman Gushchin Signed-off-by: Tejun Heo --- diff --git a/kernel/cgroup/freezer.c b/kernel/cgroup/freezer.c index 8cf0106..3984dd6 100644 --- a/kernel/cgroup/freezer.c +++ b/kernel/cgroup/freezer.c @@ -231,6 +231,15 @@ void cgroup_freezer_migrate_task(struct task_struct *task, return; /* + * It's not necessary to do changes if both of the src and dst cgroups + * are not freezing and task is not frozen. + */ + if (!test_bit(CGRP_FREEZE, &src->flags) && + !test_bit(CGRP_FREEZE, &dst->flags) && + !task->frozen) + return; + + /* * Adjust counters of freezing and frozen tasks. * Note, that if the task is frozen, but the destination cgroup is not * frozen, we bump both counters to keep them balanced.