lkml.org 
[lkml]   [2011]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] cgroup: remove tasklist_lock from cgroup_attach_proc
Tejun Heo (tj@kernel.org) wrote:
> Hello,
>
> On Thu, Dec 22, 2011 at 02:26:55PM -0800, Mandeep Singh Baines wrote:
> > @@ -2283,14 +2261,26 @@ static int attach_task_by_pid(struct cgroup *cgrp, u64 pid, bool threadgroup)
> >
> > threadgroup_lock(tsk);
> >
> > - if (threadgroup)
> > + if (threadgroup) {
> > + if (!thread_group_leader(tsk)) {
> > + /*
> > + * a race with de_thread from another thread's exec()
> > + * may strip us of our leadership, if this happens,
> > + * there is no choice but to throw this task away and
> > + * try again (from cgroup_procs_write); this is
> > + * "double-double-toil-and-trouble-check locking".
> > + */
> > + ret = -EAGAIN;
> > + goto out_unlock_threadgroup;
> > + }
> > ret = cgroup_attach_proc(cgrp, tsk);
>
> Ummm... can't we just do tsk = tsk->leader after locking threadgroup?

You're right. Nice!

New series coming up.

> Why do we need to retry from the beginning?
>
> Thanks.
>
> --
> tejun


\
 
 \ /
  Last update: 2011-12-23 02:01    [W:0.076 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site