From owner-freebsd-arch@FreeBSD.ORG Wed Mar 19 15:39:56 2008 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27113106566C for ; Wed, 19 Mar 2008 15:39:56 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.freebsd.org (Postfix) with ESMTP id 9EDD88FC1D for ; Wed, 19 Mar 2008 15:39:55 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c220-239-252-11.carlnfd3.nsw.optusnet.com.au [220.239.252.11]) by mail07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id m2JFdo8Y030464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 20 Mar 2008 02:39:50 +1100 Date: Thu, 20 Mar 2008 02:39:49 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Schouten In-Reply-To: <20080319124759.GB51074@hoeg.nl> Message-ID: <20080320022557.K10895@besplex.bde.org> References: <20080315124008.GF80576@hoeg.nl> <20080316015903.N39516@delplex.bde.org> <20080315194809.GN10374@deviant.kiev.zoral.com.ua> <20080316133138.J41270@delplex.bde.org> <20080319124759.GB51074@hoeg.nl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Kostik Belousov , FreeBSD Arch Subject: Re: vgone() calling VOP_CLOSE() -> blocked threads? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Mar 2008 15:39:56 -0000 On Wed, 19 Mar 2008, Ed Schouten wrote: > I just changed my TTY code to perform some garbage collecting on TTY's. > It now only performs a device cleanup when si_threadcount == 1 and > TF_OPENED is unset. Unfortunately, I'm checking for these conditions in > all the cdev ops, which is quite expensive. > > It does the trick, but if someone has a better idea, I'm willing to > implement it. When does si_threadcount go to 0 -- can it be 1 due to something other than a cdev op holding a reference? If revoke() is the only problem, and if non-cdev ops can hold a reference, then it might work to acquire a reference at the time of the revoke. Hold this reference in some process (could even be in userland), and consider releasing it some time later (and later again if the synchronization hasn't completed). While this reference is held, si_refcount cannot go to 0, so it is only necessary to check si_threadcount == 1 when considering releasing this reference. New opens on the device probably need to be blocked while the state is unsynchronized -- otherwise too many states are possible. Bruce