"lazy" mmap for a device driver ?

Kostik Belousov kostikbel at gmail.com
Tue May 31 20:45:25 UTC 2011


On Tue, May 31, 2011 at 10:21:42PM +0200, Luigi Rizzo wrote:
> hi,
> i have a kernel module implementing a memory mapped special device
> which exports a large block of memory to the process.
> I see that when the process calls mmap(), my routine foo_mmap()
> is called immediately once per page, even though the process is
> not actually touching the pages. I believe this happens
> through dev_pager_alloc().
> 
> Right now i can live with that because all the memory is allocated
> at module load time, but i might want to have a sparse memory
> region which is populated dynamically, so i was wondering if
> there is a way to achieve this. I see there are two other
> device routines, d_mmap2 and d_mmap_single, any pointer to
> documentation or comments on how they differ ?

During the porting of GEM to our kernel, I had to make a device
pager interface more flexible. In particular, the updated pager allows
the device to handle individual faults and return an explicit
page to satisfy the fault, instead of the physical address.

More, the driver can do any appropriate setup by ctr method.
The new interface is supposed to be used with d_mmap_single().

http://people.freebsd.org/~kib/misc/device_pager.2.patch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20110531/6e617d43/attachment.pgp


More information about the freebsd-current mailing list