Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754631AbXLFQVh (ORCPT ); Thu, 6 Dec 2007 11:21:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752709AbXLFQVa (ORCPT ); Thu, 6 Dec 2007 11:21:30 -0500 Received: from x346.tv-sign.ru ([89.108.83.215]:40979 "EHLO mail.screens.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752658AbXLFQV3 (ORCPT ); Thu, 6 Dec 2007 11:21:29 -0500 Date: Thu, 6 Dec 2007 19:22:07 +0300 From: Oleg Nesterov To: Davide Libenzi Cc: Andrew Morton , Ingo Molnar , Linus Torvalds , Roland McGrath , Linux Kernel Mailing List Subject: Re: [PATCH] fix group stop with exit race Message-ID: <20071206162207.GA7378@tv-sign.ru> References: <20071205173028.GA3745@tv-sign.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1939 Lines: 61 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 > > 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 Thanks for looking at this! Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/