Skip to content

Commit 599c963

Browse files
committed
cgroup_freezer: simplify propagation of CGROUP_FROZEN clearing in freezer_attach()
If one or more tasks get moved into a frozen css, the frozen state is cleared up from the destination css so that it can be reasserted once the migrated tasks are frozen. freezer_attach() implements this in two separate steps - clearing CGROUP_FROZEN on the target css while processing each task and propagating the clearing upwards after the task loop is done if necessary. This patch merges the two steps. Propagation now takes place inside the task loop. This simplifies the code and prepares it for the fix of multi-destination migration. Signed-off-by: Tejun Heo <[email protected]>
1 parent afbcb36 commit 599c963

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

kernel/cgroup_freezer.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ static void freezer_css_free(struct cgroup_subsys_state *css)
158158
static void freezer_attach(struct cgroup_subsys_state *new_css,
159159
struct cgroup_taskset *tset)
160160
{
161-
struct freezer *freezer = css_freezer(new_css);
162161
struct task_struct *task;
163-
bool clear_frozen = false;
164162

165163
mutex_lock(&freezer_mutex);
166164

@@ -175,21 +173,20 @@ static void freezer_attach(struct cgroup_subsys_state *new_css,
175173
* be visible in a FROZEN cgroup and frozen tasks in a THAWED one.
176174
*/
177175
cgroup_taskset_for_each(task, tset) {
176+
struct freezer *freezer = css_freezer(new_css);
177+
178178
if (!(freezer->state & CGROUP_FREEZING)) {
179179
__thaw_task(task);
180180
} else {
181181
freeze_task(task);
182-
freezer->state &= ~CGROUP_FROZEN;
183-
clear_frozen = true;
182+
/* clear FROZEN and propagate upwards */
183+
while (freezer && (freezer->state & CGROUP_FROZEN)) {
184+
freezer->state &= ~CGROUP_FROZEN;
185+
freezer = parent_freezer(freezer);
186+
}
184187
}
185188
}
186189

187-
/* propagate FROZEN clearing upwards */
188-
while (clear_frozen && (freezer = parent_freezer(freezer))) {
189-
freezer->state &= ~CGROUP_FROZEN;
190-
clear_frozen = freezer->state & CGROUP_FREEZING;
191-
}
192-
193190
mutex_unlock(&freezer_mutex);
194191
}
195192

0 commit comments

Comments
 (0)