Re: [PATCH v3 4/7] cgroup: cgroup v2 freezer

From: Tejun Heo
Date: Tue Nov 20 2018 - 11:25:35 EST


On Fri, Nov 16, 2018 at 04:38:27PM -0800, Roman Gushchin wrote:
> +void cgroup_freezer_migrate_task(struct task_struct *task,
> + struct cgroup *src, struct cgroup *dst)
> +{
> + lockdep_assert_held(&css_set_lock);
> +
> + /*
> + * Kernel threads are not supposed to be frozen at all.
> + */
> + if (task->flags & PF_KTHREAD)
> + return;
> +
> + /*
> + * Adjust counters of freezing and frozen tasks.
> + */
> + if (test_bit(CGRP_FREEZE, &src->flags)) {
> + src->freezer.nr_tasks_to_freeze--;
> + WARN_ON_ONCE(src->freezer.nr_tasks_to_freeze < 0);
> + }
> +
> + /*
> + * If the task is frozen, let's bump nr_tasks_to_freeze even
> + * if the target cgroup isn't frozen: the counter will be decreased
> + * in cgroup_leave_frozen().
> + */
> + if (test_bit(CGRP_FREEZE, &dst->flags) || task->frozen)
> + dst->freezer.nr_tasks_to_freeze++;
> +
> + if (task->frozen) {
> + src->freezer.nr_frozen_tasks--;
> + dst->freezer.nr_frozen_tasks++;
> + WARN_ON_ONCE(src->freezer.nr_frozen_tasks < 0);
> + WARN_ON_ONCE(dst->freezer.nr_frozen_tasks >
> + dst->freezer.nr_tasks_to_freeze);
> + }

If a non-frozen task is being moved into a frozen cgroup, shouldn't
that also trigger frozen state update?

Thanks.

--
tejun