Copy data from kernel to user space memory

Andrey Simonenko simon at comsys.ntu-kpi.kiev.ua
Thu Sep 23 03:20:37 PDT 2004


On Thu, Sep 23, 2004 at 11:38:28AM +0200, Niels Heinen wrote:

> The module buffers packets and currently copies it into user memory
> when its system call interface is used.  At the moment my user space 
> application is the one that allocates the memory. I want the memory 
> to be allocated by the module in order to make things more efficient.
> 
> I'd really appriciate it if someone could explain how this should be done

You can allocate OBJT_DEFAULT object with desired size, then map it to
the process' vmspace and copy packets from the module to this region
of process' memory, then tell process the start address of the mapped
object and its size.  And don't forget to serialize access to the region
of memory.

Read documentation (or relevant sys/vm code) for vm_object_allocate(9),
vm_map_find(9), vm_map_remove(9).

I'm not sure that you get some performance with this method, usually
an application allocates memory, makes syscall and tells how many bytes
the kernel (the module) can store in this memory.  But I don't see
the complete picture, so may be you can't use this standard approach.


More information about the freebsd-hackers mailing list