Re: copyin()/copyout() constraints ?

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Sat, 15 Jun 2013 14:31:34 +0300
On Sat, Jun 15, 2013 at 01:26:10PM +0200, Luigi Rizzo wrote:
> With "indirect buffers" in netmap/vale, i can eliminate the A->B copy,
> and do A->C with a copyin in the kernel of the host.
> But the per-packet budget is minuscule, and i am afraid that doing
> an unconditional vslock() on each buffer is going to be too expensive
> (and then i should also unwire the page ?

Using vslock() causes enormous user map fragmentation and should be
avoided. The cost is basically the same as the page fault, since
vslock() is a wrapper around vm_map_wire(), which just calls page fault
handler for each address in region.

On the other hand, I do not understand how any kernel-side lock would
prevent usermode from unmapping a buffer while other thread in kernel
mode access it.

IMO you would be much better served with either with proc_rwmem(), as
discussed before, or direct use of vm_fault_quick_hold_pages() and
uiomove_fromphys() afterward. vm_fault_quick_hold_pages() also makes you
code immune against usermode doing any unmap or mapping over the passed
buffer.

Received on Sat Jun 15 2013 - 09:31:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:38 UTC