From: Oleg Nesterov <oleg@redhat.com>
To: Ben Blum <bblum@andrew.cmu.edu>
Cc: Paul Menage <menage@google.com>,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
ebiederm@xmission.com, lizf@cn.fujitsu.com, matthltc@us.ibm.com,
containers@lists.linux-foundation.org
Subject: Re: [RFC] [PATCH 1/2] cgroups: read-write lock CLONE_THREAD forking per threadgroup
Date: Mon, 22 Mar 2010 11:22:47 +0100 [thread overview]
Message-ID: <20100322102247.GA8363@redhat.com> (raw)
In-Reply-To: <20100117204833.GA29596@unix38.andrew.cmu.edu>
On 01/17, Ben Blum wrote:
>
> On Tue, Jan 05, 2010 at 07:53:30PM +0100, Oleg Nesterov wrote:
> >
> > I don't understand how this can close the race with de_thread().
> > ...
>
> the race with the sighand is handled in the next patch, in attach_proc,
> not in this function.
OK. I didn't verify this, the patches don't apply to 2.6.32-rc, but this
doesn't matter. Please see below.
> > > + /* now try to find a sighand */
> > > + if (likely(tsk->sighand)) {
> > > + sighand = tsk->sighand;
> > > + } else {
> > > + sighand = ERR_PTR(-ESRCH);
> > > + /*
> > > + * tsk is exiting; try to find another thread in the group
> > > + * whose sighand pointer is still alive.
> > > + */
> > > + list_for_each_entry_rcu(p, &tsk->thread_group, thread_group) {
> > > + if (p->sighand) {
> > > + sighand = tsk->sighand;
> >
> > can't understand this "else {}" code... We hold tasklist, if the group
> > leader is dead (->sighand == NULL), then the whole thread group is
> > dead.
> >
> > Even if we had another thread with ->sighand != NULL, what is the point
> > of "if (unlikely(!thread_group_leader(tsk)))" check then?
>
> doesn't the group leader stay on the threadgroup list even when it dies?
> sighand can be null if the group leader has exited, but other threads
> are still running.
No, leader->sighand != NULL until all threads have exited.
Ben, I'd suggest you to redo these patches even if they are correct.
->sighand is not the right place for the mutex/locking
- it is per CLONE_SIGHAND, not per process
- we have to avoid the nasty and hard-to-test races with exec
- we have to play with sighand->count and I really dislike this.
this ->count is not just a reference counter, look at
unshare_sighand(). Yes, this is fake, but still.
Please use ->signal instead. By the lucky coincidence the lifetime rules
for (greatly misnamed) signal_struct were changed recently in -mm.
With the recent changes, it is always safe to use task->signal. It can't
be changed, can't go away, no need to bump the counter, no races, etc.
What do you think?
Oleg.
next prev parent reply other threads:[~2010-03-22 10:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 21:14 + cgroups-add-functionality-to-read-write-lock-clone_thread-forking-per-threadgroup.patch added to -mm tree akpm
2009-08-21 10:26 ` + cgroups-add-functionality-to-read-write-lock-clone_thread-forking-pe r-threadgroup.patch " Oleg Nesterov
2009-08-21 10:45 ` Oleg Nesterov
2009-08-21 23:37 ` Paul Menage
2009-08-22 13:09 ` Oleg Nesterov
2009-08-22 13:28 ` Paul Menage
[not found] ` <20090822130952.GA4240-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-01-03 19:06 ` Ben Blum
2010-01-03 19:06 ` Ben Blum
[not found] ` <20100103190613.GA13423-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org>
2010-01-03 19:07 ` [RFC] [PATCH 1/2] cgroups: read-write lock CLONE_THREAD forking per threadgroup Ben Blum
2010-01-03 19:07 ` Ben Blum
2010-01-05 18:53 ` Oleg Nesterov
[not found] ` <20100105185330.GA17545-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-01-17 20:48 ` Ben Blum
2010-01-17 20:48 ` Ben Blum
2010-03-22 10:22 ` Oleg Nesterov [this message]
2010-03-22 23:57 ` Paul Menage
[not found] ` <20100322102247.GA8363-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-03-22 23:57 ` Paul Menage
[not found] ` <20100117204833.GA29596-DC+BO+AtSRVCM1neWV3AGuCmf2DRS9x2@public.gmane.org>
2010-03-22 10:22 ` Oleg Nesterov
[not found] ` <20100103190752.GB13423-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org>
2010-01-05 18:53 ` Oleg Nesterov
2010-01-03 19:09 ` [RFC] [PATCH 2/2] cgroups: make procs file writable Ben Blum
2010-01-03 19:09 ` Ben Blum
-- strict thread matches above, loose matches on Subject: below --
2010-05-30 1:30 [RFC] [PATCH v2 0/2] cgroups: implement moving a threadgroup's threads atomically with cgroup.procs Ben Blum
[not found] ` <20100530013002.GA762-kwnxxEB+oiWqwBT9kiuFm8WGCVk0P7UB@public.gmane.org>
2010-05-30 1:31 ` [RFC] [PATCH 1/2] cgroups: read-write lock CLONE_THREAD forking per threadgroup Ben Blum
2010-05-30 1:31 ` Ben Blum
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=20100322102247.GA8363@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bblum@andrew.cmu.edu \
--cc=containers@lists.linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=matthltc@us.ibm.com \
--cc=menage@google.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.