diff options
author | Tejun Heo <tj@kernel.org> | 2012-10-16 18:03:14 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-10-16 18:03:14 -0400 |
commit | 3c426d5e114035d00453bb5d82a92826db1ed71f (patch) | |
tree | abb6a8f7d1dc278e2acd76f8a73baa39ddd8ff4e /kernel/cgroup_freezer.c | |
parent | 51f246ed95caed12898649d8170d2d352da6af76 (diff) |
cgroup_freezer: don't stall transition to FROZEN for PF_NOFREEZE or PF_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>
Diffstat (limited to 'kernel/cgroup_freezer.c')
-rw-r--r-- | kernel/cgroup_freezer.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index 05d52185139c..557f3678c4e4 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
@@ -214,10 +214,18 @@ static void update_if_frozen(struct cgroup *cgroup, | |||
214 | 214 | ||
215 | cgroup_iter_start(cgroup, &it); | 215 | cgroup_iter_start(cgroup, &it); |
216 | while ((task = cgroup_iter_next(cgroup, &it))) { | 216 | while ((task = cgroup_iter_next(cgroup, &it))) { |
217 | ntotal++; | 217 | if (freezing(task)) { |
218 | if (freezing(task) && (frozen(task) || | 218 | ntotal++; |
219 | task_is_stopped_or_traced(task))) | 219 | /* |
220 | nfrozen++; | 220 | * freezer_should_skip() indicates that the task |
221 | * should be skipped when determining freezing | ||
222 | * completion. Consider it frozen in addition to | ||
223 | * the usual frozen condition. | ||
224 | */ | ||
225 | if (frozen(task) || task_is_stopped_or_traced(task) || | ||
226 | freezer_should_skip(task)) | ||
227 | nfrozen++; | ||
228 | } | ||
221 | } | 229 | } |
222 | 230 | ||
223 | if (old_state == CGROUP_THAWED) { | 231 | if (old_state == CGROUP_THAWED) { |