Re: [RFC][PATCH] cgroup: fix race between fork and cgroup freezing

From: Tejun Heo
Date: Thu Mar 08 2012 - 13:26:27 EST


Hello, Li, Frederic.

On Thu, Mar 08, 2012 at 04:45:13PM +0800, Li Zefan wrote:
> +static void freezer_post_fork(struct cgroup_subsys *ss,
> + struct task_struct *task)
> +{
> + struct freezer *freezer;
> +
> + cgroup_lock();
> +
> + freezer = task_freezer(task);
> + if (!freezer->css.cgroup->parent)
> + goto out;
> +
> + spin_lock_irq(&freezer->lock);
> + if (freezer->state != CGROUP_THAWED)
> + freeze_task(task);
> + spin_unlock_irq(&freezer->lock);
> +out:
> + cgroup_unlock();
> +}

Urgh... this is requiring policy implementations to synchronize with
problem caused by cgroup core optimization and it's so very subtle.
IMHO, this definitely should be contained in cgroup core and in a very
confined form even inside cgroup core.

Any other ideas?

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/