Skip to content

Commit

Permalink
cgroup: freezer: don't change task and cgroups status unnecessarily
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Roman Gushchin <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
Honglei Wang authored and htejun committed Nov 7, 2019
1 parent 1bb5ec2 commit 742e8cd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kernel/cgroup/freezer.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ void cgroup_freezer_migrate_task(struct task_struct *task,
if (task->flags & PF_KTHREAD)
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
Expand Down

0 comments on commit 742e8cd

Please sign in to comment.