Re: [PATCH 04/10] cgroup: always lock threadgroup during migration

From: Tejun Heo
Date: Fri Nov 04 2011 - 11:21:59 EST


Hello,

On Fri, Nov 04, 2011 at 05:54:13PM +0900, KAMEZAWA Hiroyuki wrote:
> > - /* if PF_EXITING is set, the tsk->cgroups pointer is no longer safe. */
> > + /* @tsk can't exit as its threadgroup is locked */
> > task_lock(tsk);
> > - if (tsk->flags & PF_EXITING) {
> > - task_unlock(tsk);
> > - put_css_set(newcg);
> > - return -ESRCH;
> > - }
> > + WARN_ON_ONCE(tsk->flags & PF_EXITING);
> > rcu_assign_pointer(tsk->cgroups, newcg);
> > task_unlock(tsk);
>
> Is this task_lock/unlock is required ?

For put, I don't think it's necessary.

> > @@ -2116,11 +2120,6 @@ int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
> > continue;
> > /* get old css_set pointer */
> > task_lock(tsk);
> > - if (tsk->flags & PF_EXITING) {
> > - /* ignore this task if it's going away */
> > - task_unlock(tsk);
> > - continue;
> > - }
> > oldcg = tsk->cgroups;
> > get_css_set(oldcg);
> > task_unlock(tsk);

For get, I think it is; otherwise, nothing prevents someone else from
changing tsk->cgroups between load and get, and destroying it.

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/