From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@osdl.org>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, dipankar@in.ibm.com,
suzannew@cs.pdx.edu
Subject: Re: [PATCH] Fixes for RCU handling of task_struct
Date: Sun, 6 Nov 2005 14:59:26 -0800 [thread overview]
Message-ID: <20051106225926.GC22876@us.ibm.com> (raw)
In-Reply-To: <436DF0A6.342717A6@tv-sign.ru>
On Sun, Nov 06, 2005 at 03:01:42PM +0300, Oleg Nesterov wrote:
> "Paul E. McKenney" wrote:
> >
> > So the idea is to error out of send_sigqueue() so that posix_timer_event()
> > will instead call send_group_sigqueeue(). But that could suffer from
> > the same race if the new leader thread also exits -- or if the exiting
> > thread was the leader thread to begin with.
>
> The case when leader exits is ok. If it is the only (last) thread - it will
> call exit_itimers(). If not - it (or sys_wait4 from parent) will not call
> release_task(), but will stay TASK_ZOMBIE with valid ->signal/sighand until
> the last thread in same thread group exits (and call exit_itimers).
>
> > But once send_group_sigqueue() read-acquires tasklist_lock, threads
> > and processes must stay put. So it should be possible to follow the
> > ->group_leader chain at that point.
>
> Not quite so, I think. See below.
>
> > Except that the group leader could do an exec(), right? If it does so,
> > it must do so before tasklist_lock is read-acquired. So the nightmare
> > case is where all but one thread exits, and then that one thread does
> > and exec().
>
> ... and that thread is not group leader. Actually, it does not matter
> if other threads exited or not, execing thread will kill other threads.
>
> > If this case can really happen, we want to drop the signal
> > on the floor, right?
>
> I think yes.
>
> > diff -urpNa -X dontdiff linux-2.6.14-mm0-fix/kernel/signal.c linux-2.6.14-mm0-fix-2/kernel/signal.c
> > --- linux-2.6.14-mm0-fix/kernel/signal.c 2005-11-04 17:23:40.000000000 -0800
> > +++ linux-2.6.14-mm0-fix-2/kernel/signal.c 2005-11-05 15:05:38.000000000 -0800
> > @@ -1408,6 +1408,11 @@ send_sigqueue(int sig, struct sigqueue *
> >
> > retry:
> > sh = rcu_dereference(p->sighand);
> > + if (sh == NULL) {
> > + /* We raced with pthread_exit()... */
> > + ret = -1;
> > + goto out_err;
> > + }
>
> I lost the plot. Because I can't apply this and previous patches (rejects)
> and can't imagine how send_sigqueue() looks now. I think this is ok, but
> we also need to re-check ->signal != NULL after lock(->sighand) or check
> PF_EXITING (iirc ve do have such check).
I lost the plot as well. There were apparently a very large number of
changes awaiting 2.6.14 coming out. ;-)
I also believe we have such a check.
> > @@ -1474,7 +1479,8 @@ send_group_sigqueue(int sig, struct sigq
> > BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
> >
> > read_lock(&tasklist_lock);
> > - /* Since it_lock is held, p->sighand cannot be NULL. */
> > + while (p->group_leader != p)
> > + p = p->group_leader;
>
> No, this is definitely not right. de_thread() does not change leader->group_leader
> when non-leader execs, so p->group_leader == p always.
This was intended for the case where the group leader does pthread_exit,
which would cause some other thread to assume group leadership. Or am
I missing something from that code path? (Quite likely that I am...)
Thanx, Paul
next prev parent reply other threads:[~2005-11-06 22:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-31 2:05 [PATCH] Fixes for RCU handling of task_struct Paul E. McKenney
2005-10-31 14:04 ` Ingo Molnar
2005-10-31 14:08 ` Ingo Molnar
2005-11-01 4:51 ` Andrew Morton
2005-11-03 19:09 ` Paul E. McKenney
2005-11-04 17:41 ` Oleg Nesterov
2005-11-04 20:08 ` Paul E. McKenney
2005-11-05 16:32 ` Oleg Nesterov
2005-11-05 23:20 ` Paul E. McKenney
2005-11-06 12:01 ` Oleg Nesterov
2005-11-06 22:59 ` Paul E. McKenney [this message]
2005-11-07 13:17 ` Oleg Nesterov
2005-11-07 18:28 ` Oleg Nesterov
2005-11-06 21:49 ` Andrew Morton
2005-11-06 22:43 ` Paul E. McKenney
2005-11-07 1:12 ` Nick Piggin
2005-11-07 4:58 ` Paul E. McKenney
2005-11-07 5:51 ` Nick Piggin
2005-11-07 18:10 ` Paul E. McKenney
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=20051106225926.GC22876@us.ibm.com \
--to=paulmck@us.ibm.com \
--cc=akpm@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=suzannew@cs.pdx.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox