[PATCH] cgroup_freezer: fix freezing groups with stopped tasks

Michal Hocko mhocko at suse.cz
Tue Nov 22 09:05:22 UTC 2011


On Mon 21-11-11 18:21:18, Tejun Heo wrote:
> On Tue, Nov 22, 2011 at 10:20:02AM +0800, Li Zefan wrote:
> > Tejun Heo wrote:
> > > Hello, Michal.
> > > 
> > > On Wed, Nov 16, 2011 at 10:50:34PM +0100, Michal Hocko wrote:
> > >> +/* Task is frozen or will freeze immediately when next it gets woken */
> > >> +static bool is_task_frozen_enough(struct task_struct *task)
> > >> +{
> > >> +	return frozen(task) ||
> > >> +		(task_is_stopped_or_traced(task) && freezing(task));
> > >> +}
> > > 
> > > Hmmm... w/ pending freezer updates, the above would always return
> > > %true if there's freezing in progress, which can't be right.  Maybe
> > 
> > Only if the task is stopped/trace.
> 
> You're right, missed parantheses.
> 
> > If we try to freeze a stopped task, it will be kept in freezing state.
> > 
> > > just test stopped/traced?
> > 
> > This can trigger a BUG_ON in update_if_frozen(), because we always count a
> > stopped task as frozen.
> 
> So, yeah, the patch looks good to me, but it still isn't difficult to
> trigger BUG_ON() there.  We need a lot of fixes in cgroup_freezer.

I am not sure which BUG_ON you have in mind.
update_if_frozen:
	BUG_ON(nfrozen != ntotal);

Should be OK because this patch does:
@@ -231,7 +238,7 @@ static void update_if_frozen(struct cgroup *cgroup,
        cgroup_iter_start(cgroup, &it);
        while ((task = cgroup_iter_next(cgroup, &it))) {
                ntotal++;
-               if (frozen(task))
+               if (is_task_frozen_enough(task))

AFAICS your current implementation in (pm-freezer) uses (freezing || frozen)
so the patch should be updated to (freezing || is_task_frozen_enough).

Updated patch - on top of your pm-freezer branch
---


More information about the Containers mailing list