From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mandeep Singh Baines Subject: Re: [PATCH 1/2] cgroup: remove tasklist_lock from cgroup_attach_proc Date: Thu, 22 Dec 2011 16:58:57 -0800 Message-ID: <20111223005857.GL13529@google.com> References: <1324592816-13792-1-git-send-email-msb@chromium.org> <20111222225102.GM17084@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20111222225102.GM17084-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Tejun Heo Cc: Frederic Weisbecker , Mandeep Singh Baines , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Oleg Nesterov , Paul Menage , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton , containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: containers.vger.kernel.org Tejun Heo (tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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