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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



02:26, Tejun Heo wrote:
> 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?
> 

The problem is, forks can happen at any time, so there's no way to prevent
forks from happening while iterating tasks in a cgroup, so controllers
have to deal with it. In fact freezer is somewhat aware of this issue,
that's why it provides the ->fork callback, but there's race.

This patch is not too bad (needs a bit modification). cgroup core will detect
(via seqcount) if something's happened to a cgroup and the tasks in it, and
then cgroup will notify controllers to check if newly-forked tasks should
be adjusted accordingly, so they will have consistent status with other tasks
in the same cgroup.
--
To unsubscribe from this list: send the line "unsubscribe cgroups" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux