Date: Wed, 10 Mar 2010 15:32:24 +0200 From: Kostik Belousov <kostikbel@gmail.com> To: son goku <ryu.planka@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: physio and vmapbuf Message-ID: <20100310133224.GA2489@deviant.kiev.zoral.com.ua> In-Reply-To: <b5a284501003100340r2962a15fwc8c5886da8b74714@mail.gmail.com> References: <b5a284501003100340r2962a15fwc8c5886da8b74714@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100310133224.GA2489>