Locking memory (was Re: Questions regarding Linux swapping.)

Peter Desnoyers (pjd@fred001.dynip.com)
Tue, 3 Aug 1999 00:13:52 -0400 (EDT)


thomas.putnam@natinst.com wrote:
>
> Actually, I've been looking for a way to lock down chunks of user memory from
> within the driver I'm writing without the permission check in mlock. Is there a
> clean, exported interface to this?

I have to do the same thing, and I'm doing it by incrementing the count
in the page table with mem_map_inc_count(). Mlock takes the opposite
approach, modifying the virtual memory areas. I'm not sure which is the
right approach - I'm suspicious of the approach I've used as I end up
having to do a read/write on each page to properly handle copy-on-write,
but I don't know enough about VMAs to feel confident taking the mlock
approach.

I assume that the reason you're looking to do this is similar to mine -
allowing the user to register a buffer which the hardware DMAs into, and
which can then be read directly from user space. This is the opposite of
the approach taken by the sound drivers I've skimmed through, which seem
to allocate pages in the kernel, set the reserved bit in the page table,
and then let the user code mmap them. That's probably partly because
the sound cards need physically contiguous pages for DMA, while my device
(and yours?) can do scatter/gather.

-- 
............................................................................
 Peter Desnoyers 
 162 Pleasant St.         (617) 661-1979          pjd@fred.cambridge.ma.us
 Cambridge, Mass. 02139   (978) 461-0402 (work)   pjd@giga-net.com 

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/