Skip to content

Commit

Permalink
cgroup_freezer: don't stall transition to FROZEN for PF_NOFREEZE or P…
Browse files Browse the repository at this point in the history
…F_FREEZER_SKIP tasks

cgroup_freezer doesn't transition from FREEZING to FROZEN if the
cgroup contains PF_NOFREEZE tasks or tasks sleeping with
PF_FREEZER_SKIP set.

Only kernel tasks can be non-freezable (PF_NOFREEZE) and there's
nothing cgroup_freezer or userland can do about or to it.  It's
pointless to stall the transition for PF_NOFREEZE tasks.

PF_FREEZER_SKIP indicates that the task can be skipped when
determining whether frozen state is reached.  A task with
PF_FREEZER_SKIP is guaranteed to perform try_to_freeze() after it
wakes up and can be considered frozen much like stopped or traced
tasks.  Note that a vfork parent uses PF_FREEZER_SKIP while waiting
for the child.

This updates update_if_frozen() such that it only considers freezable
tasks and treats %true freezer_should_skip() tasks as frozen.

This allows cgroups w/ kthreads and vfork parents successfully reach
FROZEN state.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Tejun Heo committed Oct 16, 2012
1 parent 51f246e commit 3c426d5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions kernel/cgroup_freezer.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,18 @@ static void update_if_frozen(struct cgroup *cgroup,

cgroup_iter_start(cgroup, &it);
while ((task = cgroup_iter_next(cgroup, &it))) {
ntotal++;
if (freezing(task) && (frozen(task) ||
task_is_stopped_or_traced(task)))
nfrozen++;
if (freezing(task)) {
ntotal++;
/*
* freezer_should_skip() indicates that the task
* should be skipped when determining freezing
* completion. Consider it frozen in addition to
* the usual frozen condition.
*/
if (frozen(task) || task_is_stopped_or_traced(task) ||
freezer_should_skip(task))
nfrozen++;
}
}

if (old_state == CGROUP_THAWED) {
Expand Down

0 comments on commit 3c426d5

Please sign in to comment.