From owner-freebsd-arch@FreeBSD.ORG Tue May 27 19:13:29 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 39A281065672 for ; Tue, 27 May 2008 19:13:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id B33778FC1D for ; Tue, 27 May 2008 19:13:28 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m4RJD37N035578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 May 2008 22:13:03 +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 m4RJD3kb080567; Tue, 27 May 2008 22:13:03 +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 m4RJD3rF080519; Tue, 27 May 2008 22:13:03 +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, 27 May 2008 22:13:03 +0300 From: Kostik Belousov To: Ed Schouten Message-ID: <20080527191302.GS21317@deviant.kiev.zoral.com.ua> References: <20080527130615.GJ64397@hoeg.nl> <20080527150244.GN21317@deviant.kiev.zoral.com.ua> <20080527165753.GK64397@hoeg.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1IOPqZ3f1xe/JZlz" Content-Disposition: inline In-Reply-To: <20080527165753.GK64397@hoeg.nl> 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 Cc: arch@freebsd.org Subject: Re: Simplifying devfs: minor == unit 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: Tue, 27 May 2008 19:13:29 -0000 --1IOPqZ3f1xe/JZlz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 27, 2008 at 06:57:53PM +0200, Ed Schouten wrote: > * Kostik Belousov wrote: > > > - I've seen most drivers only use the device cloner, because they need > > > descriptor local storage. It turns out more drivers need this than I > > > initially thought. kib@ has a patch for this, so I hope this gets > > > committed one of these {days,weeks,months}. > > The patch was committed ~ a week ago. >=20 > Great. Looks like I wasn't paying attention back then. >=20 > > > - After we've got file descriptor local storage, I think we can live > > > without the cloner. This means we could consider removing the minor > > > number argument from make_dev(), removing the unique unit number > > > restriction we currently have inside devfs, which causes many drive= rs > > > to use number pools for no obvious reason. > > I think we cannot live without clones regardless of devfs_cdevpriv. > > The model assumed for the pty, snp and probably several other devices > > actually requires new cdev instead of the priv data. >=20 > The pty driver does not use the clone_* interface. It only uses the > eventhandler, which should indeed be left intact. The snp driver does > use the clone_* interface, but not in a way that can't be done using the > eventhandler, validating the device name and calling make_dev() > directly. Ok. >=20 > Please take a look at src/usr.sbin/watch/watch.c:open_snp(). We might as > well turn snp(4) into a single /dev/snp, where the kernel space driver > uses per-descriptor data to distinguish the instances. This provides > some advantages: >=20 > - No more silly open()-loops. >=20 > - A system administrator can change the permissions on /dev/snp, which > automatically sets a system wide policy, instead on one of the device > nodes. >=20 > - We don't fill up the system with a lot of unused nodes. >=20 > for i in `seq 1000` > do > ls /dev/bpf$i > /dev/null > done Please, do not overuse the cdevpriv data (I am not speaking about snp/watch ATM, each case requires careful decision). Using cdevpriv disables some features that may be provided by the clones, i.e. actual cdevs. For example, you cannot have several independent opens operate on the same instance. >=20 > > > I was thinking about discussing this patch with my mentor + committing > > > it somewhere in the nearby future. Any comments? > >=20 > > Making minor =3D=3D unit number looks to be not a bad idea, please, loo= k at > > the saga of the tty_pty.c revs. 1.153, 156, 1.157. Making the devices u= se > > si_drv0 directly probably is not so good since we remove the indirection > > layer that is already present and allows for some (minor) freedom in the > > devfs/kern_conf implementation. >=20 > But why isn't this done for si_drv1 and si_drv2 then? My idea is to turn > si_drv0 in an integer field that can be freely used. There is reason to > force a policy on this field. I would argue that si_drv{1,2} are the warts. I do not want to point finger at the drivers, but I remember there is a representative subset of them using si_drv in the racy way when simultaneous open/close is performed. I would much prefer to have some KPI there instead of the direct access into cdev members. --1IOPqZ3f1xe/JZlz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkg8XT4ACgkQC3+MBN1Mb4ju+gCg4ewkjv2YIFyOqLLUhHblCEF6 rBAAn3Bhc4ceVqK4LQVF5SjYMOu5CCJU =Fy/c -----END PGP SIGNATURE----- --1IOPqZ3f1xe/JZlz--