lkml.org 
[lkml]   [2011]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/10] cgroup: always lock threadgroup during migration
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


\
 
 \ /
  Last update: 2011-11-04 16:25    [W:0.255 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site