mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Roland McGrath <roland@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fix group stop with exit race
Date: Thu, 6 Dec 2007 19:22:07 +0300	[thread overview]
Message-ID: <20071206162207.GA7378@tv-sign.ru> (raw)
In-Reply-To: <Pine.LNX.4.64.0712051704590.6288@alien.or.mcafeemobile.com>

On 12/05, Davide Libenzi wrote:
>
> On Wed, 5 Dec 2007, Oleg Nesterov wrote:
>
> > do_signal_stop() counts all sub-thread and sets ->group_stop_count accordingly.
> > Every thread should decrement ->group_stop_count and stop, the last one should
> > notify the parent.
> >
> > However a sub-thread can exit before it notices the signal_pending(), or it may
> > be somewhere in do_exit() already. In that case the group stop never finishes
> > properly.
> >
> > Note: this is a minimal fix, we can add some optimizations later. Say we can
> > return quickly if thread_group_empty(). Also, we can move some signal related
> > code from exit_notify() to exit_signals().
> >
> > Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
>
> Looks OK for me, even though we're doing more work on the exit path. OTOH
> I don't see a non-racy way of doing it w/out grabbing the lock. Did you
> try to bench how much this change costs?

Yes, you are right, this unconditional spin_lock() is not good, especially for
exit_group/exec.

But please look at the next patch I am sending, it removes the pessimization
almost completely.

The only difference: when there is no group exit in progress, we are doing

	spin_lock_irq(siglock);
	if (!signal_pending()) {
		unlock and return
	}

while the current code does

	if (!signal_pending())
		return;
	spin_lock_irq(siglock);
	...

It would be nice to measure the difference, but I can't invent the test-case.

I tested (just in case) 100000 fork+exit 's

	perl -e 'fork ? wait : exit for 1 .. 100_000'

with and without the patch, and didn't notice any difference as expected.

> Acked-by: Davide Libenzi <davidel@xmailserver.org>

Thanks for looking at this!

Oleg.


      reply	other threads:[~2007-12-06 16:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-05 17:30 Oleg Nesterov
2007-12-06  1:08 ` Davide Libenzi
2007-12-06 16:22   ` Oleg Nesterov [this message]

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=20071206162207.GA7378@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®