How to pin a userland page in memory(avoid copyin and copyout)
gurney_j at resnet.uoregon.edu
Tue Jan 31 00:20:30 PST 2006
Bharma Ji wrote this message on Mon, Jan 30, 2006 at 11:46 -0800:
> 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?
> 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 really depends upon how much data you are going to copy... There
was some tests performed that showed that for sizes less than 32k or
so that it was faster to read/write (copyout/copyin) than it was to
mmap a file...
I am working on a driver that passed the buffer address w/ an ioctl,
and use vslock + bus_dmamap_load_uio to be able to make the card dma
directly into the user's buffers:
I believe there is a way to map a userland page into the kernel, though
someone else will have to provide the hints for it...
Unless you are trying to move many 10's of megabytes per second, and in
very large chuncks, I doubt you'll see much of a difference...
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
More information about the freebsd-hackers