Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Mar 2008 02:39:49 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Ed Schouten <ed@80386.nl>
Cc:        Kostik Belousov <kostikbel@gmail.com>, FreeBSD Arch <arch@FreeBSD.org>
Subject:   Re: vgone() calling VOP_CLOSE() -> blocked threads?
Message-ID:  <20080320022557.K10895@besplex.bde.org>
In-Reply-To: <20080319124759.GB51074@hoeg.nl>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080320022557.K10895>