From owner-freebsd-arch@FreeBSD.ORG Tue Jul 15 09:34:10 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08D1E1065672; Tue, 15 Jul 2008 09:34:10 +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 8AA808FC18; Tue, 15 Jul 2008 09:34:09 +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 m6F9Y22j063305 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 15 Jul 2008 12:34: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 m6F9Y2ju073518; Tue, 15 Jul 2008 12:34:02 +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 m6F9Y2FX073517; Tue, 15 Jul 2008 12:34:02 +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, 15 Jul 2008 12:34:02 +0300 From: Kostik Belousov To: Stacey Son Message-ID: <20080715093402.GO17123@deviant.kiev.zoral.com.ua> References: <4875A5D2.8030902@freebsd.org> <20080711155232.A96384@grasshopper.cs.duke.edu> <48780661.5050002@freebsd.org> <20080712045837.GD17123@deviant.kiev.zoral.com.ua> <487AD49F.6040304@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tlBB11+jzEStP2nB" Content-Disposition: inline In-Reply-To: <487AD49F.6040304@freebsd.org> 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: Andrew Gallatin , freebsd-arch@freebsd.org Subject: Re: ksyms pseudo driver 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, 15 Jul 2008 09:34:10 -0000 --tlBB11+jzEStP2nB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 13, 2008 at 11:22:55PM -0500, Stacey Son wrote: > Kostik Belousov wrote: > >Most likely, I miss some obvious reason there. But for me it looks > >like you do it in the reverse. The natural setup would be to require > >userspace to supply an allocated memory to the driver, and then the > >driver fills the memory with symbol table. This solves the problem of > >exhaustion of kernel address space. > > =20 >=20 > The snapshot of the consolidated symbol table is made when /dev/ksyms is= =20 > opened. The storage for the snapshot is allocated in the memory map of= =20 > the calling process. No kernel address space is used for the snapshot. Again, why this is done this way ? Why not creating snapshot when the user process issues ioctl that supplies neccessary usermode memory to the driver ? >=20 > A temporary buffer is allocated in kernel space in the read() handler=20 > (ksyms_read). Right now, for a read, it does two copies: one from=20 > user space to the temporary kernel space buffer and a second copy from=20 > the kernel space temp buffer and back out to user space. Ideally, it=20 > would be nice to do just one user space to user space copy directly in=20 > the kernel. >=20 > >As usual, when user-supplied region is too small, driver shall return > >both an error and new required size. It is understandable that the size > >is volatile and may be too small for the next call too. But, in fact, > >kernel symtable does not change too often, so I think even the one > >iteration mostly succeed. > > =20 >=20 > The reason the driver tries three times to create a valid snapshot is I= =20 > couldn't figure out a way (without creating a lock reversal) to=20 > temporarily keep modules from being loaded or unloaded while the=20 > snapshot is created. I agree that it should be able to create the=20 > snapshot on the first iteration in most cases. >=20 > BTW, you may have noticed the ksyms driver now uses your per-open file=20 > private data code which I like much better than using clone_create() for= =20 > per-descriptor storage. Does it work ? Do you have any suggestions for the KPI ? --tlBB11+jzEStP2nB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkh8bwkACgkQC3+MBN1Mb4jKCACgk8JxGJf2CHd/JB31ouYKxw5J 7ikAoJtSodf1j2gW1I3xUqNRwA2UMLqO =2azh -----END PGP SIGNATURE----- --tlBB11+jzEStP2nB--