Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Sep 2004 13:19:53 +0300
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        Niels Heinen <niels.heinen@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Copy data from kernel to user space memory
Message-ID:  <20040923101953.GA463@pm514-9.comsys.ntu-kpi.kiev.ua>
In-Reply-To: <dea572790409230238858640@mail.gmail.com>
References:  <dea572790409230238858640@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040923101953.GA463>