Re: avoding copyin and copyout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On our MIPS based embedded board, we do not have swap space. In 
> our driver we need to pass huge data from user land to kernel land 
> and vice versa. Without using copy in and copy out, can we use the 
> vitual address of the user land directly in the driver. Our 
> understanding is that copy in and copy out is required under 2 
> conditions: we have swapping or we use the buffers in interrupts 
> and we do not have both these conditions imposed on our driver.
> 
> On looking at the way copy_in and copy_out happens, it looks like 
> it ultimately does a mem copy; so from kernel land kernel is 
> accessing user's virtual addresses. So shouldn't just accessing 
> the virtual addresses work?

You can avoid copy in/out using an mmaped buffer. You allocate memory in kernel,
mmap it to user-space (you implement mmap for chardev or proc file) and have
the user-mode app write the data there. It works even if there is swap, because
you can make the buffer is unswappable.

(It should be possible to use any user-space data from kernel, just you have
to make sure, that it's locked in memory while you work with it - and that's
often hard because pointers may be kept somewhere deep in some driver).

--------------------------------------------------------------------------------
                  				- Jan Hudec `Bulb' <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux