From owner-freebsd-threads@FreeBSD.ORG Tue Feb 14 02:30:19 2006 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4DFDC16A423 for ; Tue, 14 Feb 2006 02:30:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04B8E43D46 for ; Tue, 14 Feb 2006 02:30:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k1E2UHjC036610 for ; Tue, 14 Feb 2006 02:30:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k1E2UHhK036609; Tue, 14 Feb 2006 02:30:17 GMT (envelope-from gnats) Date: Tue, 14 Feb 2006 02:30:17 GMT Message-Id: <200602140230.k1E2UHhK036609@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: David Xu Cc: Subject: Re: threads/89262: [kernel] [patch] multi-threaded process hangs in kernel in fork() X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: David Xu List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Feb 2006 02:30:19 -0000 The following reply was made to PR threads/89262; it has been noted by GNATS. From: David Xu To: John Baldwin Cc: bug-followup@freebsd.org, garry@networkphysics.com Subject: Re: threads/89262: [kernel] [patch] multi-threaded process hangs in kernel in fork() Date: Tue, 14 Feb 2006 10:23:14 +0800 John Baldwin wrote: > On Monday 13 February 2006 04:11, David Xu wrote: > >>ast will call userret which in turn will call thread_suspend_check. >>so the bug may not be here, but in other code. >> >>I have found a race between sleep queue and thread suspension code, >>the following patch fixed the bug, it also simplified interaction >>between sleep queue and signal code. now, sleepq_abort() is also >>fixed, it can save an errno, unlike current code, it wrongly works >>as wakeup(). >> >>http://people.freebsd.org/~davidxu/patch/slpq_susp4.patch >> >>David Xu > > > Only thing I would prefer is that you keep sleepq_catch_signals() but make it > an internal function that sleepq_waitsig() and sleepq_timed_waitsig() call > before sleepq_switch() so that sleepq_switch() doesn't get so long. The main reason I have inlined sleepq_catch_signals into sleepq_switch is proc and scheduler lock, I have to lock scheduler lock before releasing proc lock. if I leave sleepq_catch_signals there, other places have to lock scheduler lock before calling sleepq_switch. > Also, it > would be good. Also, in sleepq_switch() you are using sleepq_release() and > sleepq_lock() even though you already have a sleepqueue_chain pointer, and > you do mtx operations on sc->sc_lock explicitly in some other places. It > would be best to consistently just do mutex ops on sc->sc_lock instead of > redoing the hash-lookup several times. > Yes, this can be improved. David Xu