How to pin a userland page in memory(avoid copyin and copyout)

Kamal R. Prasad kamalpr at gmail.com
Mon Jan 30 23:47:41 PST 2006


On 1/31/06, Bharma Ji <bharmaji at gmail.com> wrote:
>
> Hi
> I am trying to explore the option avoiding copyin and copyout when mode
> switches from user to kernel and vice versa. One way to achieve this, as I
> understand, is to make the memory address (which contain the data to be
> copied) non pageable. Then just pass the addresses to the kernel and the
> data will be used directly from the userland page. Is there already some
> example code / standard way to do this?


The only way Im aware is to mmap() a file. The vtophys() translation will be
different for kernel and userspace -but there  will be no copyin()/copyout()
involved.

Also is there any way one can determine the amount of time / performance hit
> (CPU %)that happening on a given process due to the copyin and copyout. I
> want to understand how much performance gain one can gain if I am able to
> remove copyin/copyout.



It has an overhead both in copying data as well as using 2x the amt of
memory required. If you just need to pass parameters, copyin()/out() works
fine. If you want to read a multimedia device or pass some other huge block
of memory across address spaces, then mmap() helps. FYI -there is an mmap()
method  supported by usb driver frameworks.

regards
-kamal


_______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>


More information about the freebsd-hackers mailing list