Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 May 2008 22:16:10 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Andriy Gapon <avg@icyb.net.ua>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: devctl (alike?) for devfs
Message-ID:  <20080513191610.GK18958@deviant.kiev.zoral.com.ua>
In-Reply-To: <4829E658.3000605@icyb.net.ua>
References:  <480FBAB9.1000904@icyb.net.ua> <48103F36.6060707@icyb.net.ua> <200804240811.26183.jhb@freebsd.org> <4810FD1E.70602@icyb.net.ua> <20080425095009.GD18958@deviant.kiev.zoral.com.ua> <4811E6BC.4060306@icyb.net.ua> <20080425143646.GF18958@deviant.kiev.zoral.com.ua> <48275C0C.2040601@icyb.net.ua> <20080511214833.GB18958@deviant.kiev.zoral.com.ua> <4829E658.3000605@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--KWJGpjkfDfw3nKYG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, May 13, 2008 at 10:04:56PM +0300, Andriy Gapon wrote:
> on 12/05/2008 00:48 Kostik Belousov said the following:
> >No, we do not have a leak, but we have somewhat non-obvious behaviour.
> >
> >The cdev structure is freed only after the last reference to cdev is
> >gone. Typical holder of the reference is the devfs vnode. In the normal
> >usage, the vnode is present until both the device is destroyed _and_
> >devfs_populate_loop() run is performed. This function actually reclaim
> >the vnodes for destroyed devices, that causes last reference to cdev to
> >be dropped and memory freed.
> >
> >The populate loop is called syncronously from the upper levels. The
> >easiest method to trigger it is to do ls /dev, since it is called from
> >the devfs_lookupx().
>=20
> Thank you for the explanation! ls did trigger DESTROY notifications.
> But this arbitrary delay between device entry going away and=20
> notification about about it is a little bit "uncool".
>=20
> So I re-wrote the patch to post notifications about deleted devices with=
=20
> si_refcount > 0 in a fashion similar to how si_refcount=3D0 devices are=
=20
> freed. I put those cdev-s onto a special list (re-/ab-using si_siblings=
=20
> LIST link field) and bump their si_refcount to prevent them from getting=
=20
> destroyed before the notification is sent (it would need si_name).
> Then, in dev_unlock_and_free() I send notifications and call dev_rel on=
=20
> the devices.
>=20
> I am not entirely satisfied with the code:
> 1. I don't like the way I move LIST elements from one head to the other,=
=20
> this should be a macro in queue.h
> 2. I am not sure about the names I picked
> 3. I slightly don't like a fact that parent-child destroy notifications=
=20
> are sent in reverse order because of my simplistic LIST usage.

I looked at your previous patch, and it seems it is much simpler to
do drop the devmtx once more then to try to abuse free lists.
In the destroy_devl(), after the=20

	while (dev->si_threadcount !=3D 0) {
		/* Use unique dummy wait ident */
		msleep(&csw, &devmtx, PRIBIO, "devdrn", hz / 10);
	}

loop, add

	mtx_unlock(&devmtx);
	if (!cold)
		devctl_notify("DEVFS", dev->si_name, "DESTROY", NULL);
	mtx_lock(&devmtx);

--KWJGpjkfDfw3nKYG
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkgp6PkACgkQC3+MBN1Mb4imDACg0StKn5T1Pwa1YM47p9jMpV86
eZsAoNV5x65YeTg7CQtFHRYWdU5Eb8XD
=9Goh
-----END PGP SIGNATURE-----

--KWJGpjkfDfw3nKYG--



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