All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Blum <bblum@andrew.cmu.edu>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ben Blum <bblum@andrew.cmu.edu>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	fweisbec@gmail.com, neilb@suse.de, paul@paulmenage.org,
	paulmck@linux.vnet.ibm.com
Subject: Re: + cgroups-more-safe-tasklist-locking-in-cgroup_attach_proc.patch added to -mm tree
Date: Thu, 8 Sep 2011 22:11:23 -0400	[thread overview]
Message-ID: <20110909021122.GC16771@unix33.andrew.cmu.edu> (raw)
In-Reply-To: <20110908213130.GA3924@redhat.com>

On Thu, Sep 08, 2011 at 11:31:30PM +0200, Oleg Nesterov wrote:
> On 09/08, Ben Blum wrote:
> >
> > As for the patch below (which is the same as it was last time?):
> 
> It is the same, yes, I simply copied it from my old email. BTW, it
> wasn't tested at all, even compiled.

Testing is recommended ;)

> 
> > did you
> > mean for Andrew to replace the old tasklist_lock patch with this one, or
> > should one of us rewrite this against it?
> 
> This is up to you. And just in case, please feel free to do nothing and
> keep the current fix.

No, I do like the sighand method better now that I've thought about it.
The way it subsumes the check for consistency of the leader's links is
rather nice (much as it still requires deep understanding of de_thread).

If you polished this patch off, I'd be happier, since I have a lot else
on my plate.

> 
> > either way, it should have
> > something like the comment I proposed in the first thread.
> 
> Confused... Aha, I missed another email from you. You mean
> 
> 	/* If the leader exits, its links on the thread_group list become
> 	 * invalid. One way this can happen is if a sub-thread does exec() when
> 	 * de_thread() calls release_task(leader) (and leader->sighand gets set
> 	 * to NULL, in which case lock_task_sighand will fail). Since in that
> 	 * case the threadgroup is still around, cgroup_procs_write should try
> 	 * again (finding the new leader), which EAGAIN indicates here. This is
> 	 * "double-double-toil-and-trouble-check locking". */
> 
> Agreed.
> 
> 
> 
> 
> 
> Off-topic question... Looking at this code, it seems that
> attach_task_by_pid(zombie_pid, threadgroup => true) returns 0.
> single-task-only case fails with -ESRCH in this case. I am not
> saying this is wrong, just this looks a bit strange (unless I
> misread the code).

yeah, this is a side-effect of cgroup_attach_proc continuing to iterate
in case any one of the sub-threads be still alive. you could keep track
of whether all threads were zombies and return -ESRCH then, but it
shouldn't matter, since the user-facing behaviour is indistinguishable
from if the user had sent the command just before the task turned zombie
but while it was still about to exit.

Thanks,
Ben

> 
> Oleg.
> 
> 

  reply	other threads:[~2011-09-09  2:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 21:08 + cgroups-more-safe-tasklist-locking-in-cgroup_attach_proc.patch added to -mm tree akpm
2011-09-02 12:37 ` Oleg Nesterov
2011-09-02 14:00   ` Oleg Nesterov
2011-09-02 14:15     ` Ben Blum
2011-09-02 15:55       ` Oleg Nesterov
2011-09-07 23:59         ` Ben Blum
2011-09-08 17:35           ` Oleg Nesterov
2011-09-08 18:58             ` Ben Blum
2011-09-08 21:31               ` Oleg Nesterov
2011-09-09  2:11                 ` Ben Blum [this message]
2011-09-09 16:41                   ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110909021122.GC16771@unix33.andrew.cmu.edu \
    --to=bblum@andrew.cmu.edu \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=oleg@redhat.com \
    --cc=paul@paulmenage.org \
    --cc=paulmck@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.