From owner-cvs-all@FreeBSD.ORG Wed Jan 11 14:20:35 2006 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A75A716A41F; Wed, 11 Jan 2006 14:20:35 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90A1743D45; Wed, 11 Jan 2006 14:20:34 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 5794942 for multiple; Wed, 11 Jan 2006 09:18:49 -0500 Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k0BEKM4D071494; Wed, 11 Jan 2006 09:20:23 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Scott Long Date: Wed, 11 Jan 2006 09:06:09 -0500 User-Agent: KMail/1.8.3 References: <200601110037.k0B0bDv4009424@repoman.freebsd.org> <200601110847.08614.jhb@freebsd.org> <43C50E9B.5050508@samsco.org> In-Reply-To: <43C50E9B.5050508@samsco.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200601110906.12293.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1238/Wed Jan 11 05:19:06 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: cvs-src@freebsd.org, src-committers@freebsd.org, Scott Long , cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/kern subr_taskqueue.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2006 14:20:35 -0000 On Wednesday 11 January 2006 08:56 am, Scott Long wrote: > John Baldwin wrote: > > On Tuesday 10 January 2006 07:37 pm, Scott Long wrote: > >>scottl 2006-01-11 00:37:13 UTC > >> > >> FreeBSD src repository > >> > >> Modified files: > >> sys/kern subr_taskqueue.c > >> Log: > >> The interlock in taskqueue_terminate() is completely wrong for > >> taskqueues that use spinlocks. Remove it for now. > > > > Eh? It's waiting for the wakeup that comes from kthread_exit() after t= he > > thread has exited which is locked via the proc lock. Sleeping on the > > taskqueue itself doesn't buy you anything. (In fact, it might sleep > > forever.) The simplest solution might be to acquire the proc lock a l= ot > > earlier before the taskqueue lock in this function so that you don't ha= ve > > to acquire it while holding the taskqueue lock since that is what gives > > you problems. > > With the code the way it was, kthread_exit() in taskqueue_thread_loop > can wind up blocking on the proc lock while the lock is still held in > taskqueue_terminate. I don't know why this is actually a problem, but > turning on WITNESS to investigate revealed the immediate problem of > trying to grab the proc lock with a spinlock already held. The > interlock is really just a protection against drivers that don't > adequately quiesce themselves, so I removed it for now until we can > figure out something better. The interlock to make sure the thread has terminated before the function=20 returns. This would be important if the taskqueue routine for this thread= =20 was in a kernel module that was being unloaded to avoid having a kernel pag= e=20 fault. The solution for the LOR you saw is probably to just lock the proc= =20 lock earlier. taskqueue_terminate() is not really a critical path operatio= n=20 (if it is that's a bug) so holding the proc lock a bit longer there won't=20 kill. As it is, there isn't a matching wakeup to ever resume the sleeper i= n=20 taskqueue_terminate(), so the calling thread will block indefinitely (unles= s=20 it is using a timeout). =2D-=20 John Baldwin =A0<>< =A0http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org