From owner-freebsd-hackers@FreeBSD.ORG Tue May 13 19:16:24 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BADE21065676; Tue, 13 May 2008 19:16:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from relay02.kiev.sovam.com (relay02.kiev.sovam.com [62.64.120.197]) by mx1.freebsd.org (Postfix) with ESMTP id 52FBF8FC25; Tue, 13 May 2008 19:16:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from [212.82.216.226] (helo=skuns.kiev.zoral.com.ua) by relay02.kiev.sovam.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1Jvzz4-0004Hj-JG; Tue, 13 May 2008 22:16:22 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by skuns.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m4DJGCro088179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 May 2008 22:16:12 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m4DJGAuG082232; Tue, 13 May 2008 22:16:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2/Submit) id m4DJGAw7082231; Tue, 13 May 2008 22:16:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 13 May 2008 22:16:10 +0300 From: Kostik Belousov To: Andriy Gapon Message-ID: <20080513191610.GK18958@deviant.kiev.zoral.com.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> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KWJGpjkfDfw3nKYG" Content-Disposition: inline In-Reply-To: <4829E658.3000605@icyb.net.ua> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.91.2, clamav-milter version 0.91.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.4 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on skuns.kiev.zoral.com.ua X-Scanner-Signature: eacc24c597fa83a26e5f02f00d1ff66c X-DrWeb-checked: yes X-SpamTest-Envelope-From: kostikbel@gmail.com X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2809 [May 13 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Method: none X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release Cc: freebsd-hackers@freebsd.org Subject: Re: devctl (alike?) for devfs X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2008 19:16:24 -0000 --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--