From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 10 13:32:29 2010 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 B50CE1065675 for ; Wed, 10 Mar 2010 13:32:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 452678FC0A for ; Wed, 10 Mar 2010 13:32:28 +0000 (UTC) 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 o2ADWOhB014284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 10 Mar 2010 15:32:24 +0200 (EET) (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.4/8.14.4) with ESMTP id o2ADWOxk083677; Wed, 10 Mar 2010 15:32:24 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o2ADWOim083676; Wed, 10 Mar 2010 15:32:24 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 10 Mar 2010 15:32:24 +0200 From: Kostik Belousov To: son goku Message-ID: <20100310133224.GA2489@deviant.kiev.zoral.com.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IxlmieUzCzCqf3CN" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at 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.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org Subject: Re: physio and vmapbuf 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: Wed, 10 Mar 2010 13:32:29 -0000 --IxlmieUzCzCqf3CN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 10, 2010 at 01:40:18PM +0200, son goku wrote: > Hi hackers, > I have some experience with other UNIX kernels but none with FreeBSD. > FreeBSD interests me for a potential project I might be involved in , and > therefore I started researching it. > Browsing through the I/O layer code, I stumbled upon something that looked > strange, and perhaps you guys can help me with it. > Mainly, when reading the physio path, when the I/O buffer is from user-mo= de, > physio calls vmapbuf. The comments says that vmapbuf actually maps the > user-buffer into kernel address space. From my experience, such mapping is > needed only for very old devices that use PIO. Newer device just use DMA = for > data copy, and therefore don't need the mapping, instead they just need to > pin the memory. Checking out vmapbuf only confused me further, I couldn't > find where such kernel mapping was taken place, nevertheless I did saw th= at > the buf->b_data was updated according to buf->b_saveaddr in some weird > offset calculation. > Adding to this confusion, there is a buf field called b_kvabase which > supposedly stores the kernel virtual address which wasn't touched at all!! >=20 > Any help with understanding the flow and the usage of those fields/variab= les > will be greatly appreciated!! For normal VMIO buffers, b_kvabase is provided on the buffer initialization, see getnewbuf() and allocbuf(). b_saveaddr is initialized equial to b_kvabase. But note that physio uses pbufs, that are essentially buffer header and some reserved kva space. Note the bp =3D getpbuf(NULL); sa =3D bp->b_data; at the start of physio(), and then bp->b_saveaddr =3D sa; later at the buffer set up. vmapbuf() looks up the pages using vm_fault_quick()/pmap_extract_and_hold() loop, and then maps the pages into pbuf kva by pmap_qenter(). --IxlmieUzCzCqf3CN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkuXn2cACgkQC3+MBN1Mb4g6PACfRQhCUjG0Zh4jf+ycymPc1Xiw GQgAn3Xw6LqplAY0+/3S7RgADjvzq/dI =SAjw -----END PGP SIGNATURE----- --IxlmieUzCzCqf3CN--