How does L4Re handle contiguous memory blocks? What are the system calls used to allocate and manage contiguous memory? Is it possible to do zero copy data transfer between drivers and if so how is it done in Fiasco (so in linux world you would say no copy_to_user() and copy_from_user() )
thanks,
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
On 09.10.2014 18:57, teclis High Elf wrote:
How does L4Re handle contiguous memory blocks?
The dataspace managers (aka the user-level applications that provide allocation and management of memory) provide the possibility to allocate physically contiguous memory.
What are the system calls used to allocate and manage contiguous memory?
The alloc() function of the Mem_alloc interface (provided e.g., by the default memory allocator that you can access through L4Re::Env::env()->mem_alloc) has a flags parameter. One of the flags is the "Contiguous" flag, which asks the allocator for such memory. See l4re/include/mem_alloc for docs.
Is it possible to do zero copy data transfer between drivers and if so how is it done in Fiasco (so in linux world you would say no copy_to_user() and copy_from_user() )
Zero-copy transfer is possible if you have the same chunk of memory mapped to both address spaces. For L4Re you would need to take the following steps:
1. Allocate a memory dataspace. (Contiguous memory isn't strictly necessary.) 2. Give a capability to this dataspace to your two participants, let's call them tasks A and B. 3. In both A and B attach the dataspace using the region manager interface.
As a result of these three steps you will have shared memory between the tasks and if one of the tasks writes to this memory, the other task will see the results without further copying.
Besides the shared memory region, a real-life scenario will need means for signalling between the partners. For an implementation of such shared memory see l4/pkg/shmc.
Cheers, Bjoern
Hello,
How does L4Re handle contiguous memory blocks? What are the system calls used to allocate and manage contiguous memory? Is it possible to do zero copy data transfer between drivers and if so how is it done in Fiasco (so in linux world you would say no copy_to_user() and copy_from_user() )
I'm not an expert but I would say that can be done by using a Dataspace. If you look into src/l4/pkg/examples/libs/l4re/c++/shared_ds/ you will find an example where two tasks share a block of memory. Basically, in order to grant both tasks access to the dataspace, you need an IPC-Gate between the two (just like when you do regular IPC). Then the client (which wants to get access to the ds of the server) writes an instance of Small_buf, initialised with an allocated dataspace capability, into an Ipc_iostream (see line 38 of interface.h) and then makes an IPC-call to the server. The server writes its dataspace capability into an Ipc_iostream and answers. The kernel then maps the capability to the client, so now both tasks have access to the dataspace.
Josef
l4-hackers@os.inf.tu-dresden.de