Hi all,
I am trying to understand the workings of the emul_l4rm.c.
Please allow me to explain how I understand the working of this file so that you can correct me.
When calling l4rm_attach(), the function l4rm_do_attach() gets called. This function calls reserve_virtual_area() which uses mmap(). Mmap() searches for an available area (with a certain size) in the calling process's virtual memory. After finding such an area it remaps memory, allocated using kmalloc() by /dev/zero, to the newly found virtual memory space. Kmalloc() allocates memory from the l4linux dataspace and that piece of memory is now mapped into user space. Next, the call to l4dm_map_pages(), maps my specified dataspace's pages into this mapped virtual address.
Q1: Why go thru the first memory mapping of the kmalloc-ed memory into user space if immediately after it is remapped again by l4dm? Seems like a waste of the l4linux dataspace.
Q2: Can the free virtual memory area be determined by another method and then call l4dm_map_pages()?
Q2: When l4_fpage_unmap() is called, is the previous mapping to the pages of the kmalloc-ed memory restored?
Thanks for your time. Leon
Hi Leon,
On Friday 01 April 2005 14:21, Leon Brits wrote:
When calling l4rm_attach(), the function l4rm_do_attach() gets called. This function calls reserve_virtual_area() which uses mmap(). Mmap() searches for an available area (with a certain size) in the calling process's virtual memory. After finding such an area it remaps memory, allocated using kmalloc() by /dev/zero, to the newly found virtual memory space. Kmalloc() allocates memory from the l4linux dataspace and that piece of memory is now mapped into user space. Next, the call to l4dm_map_pages(), maps my specified dataspace's pages into this mapped virtual address.
Q1: Why go thru the first memory mapping of the kmalloc-ed memory into user space if immediately after it is remapped again by l4dm? Seems like a waste of the l4linux dataspace.
kmalloc is only used for allocating the descriptor. Since /dev/zero is mapped into the VM area, no memory is wasted.
Q2: Can the free virtual memory area be determined by another method and then call l4dm_map_pages()?
Why that? Note that emul_l4rm is not much more than a hack.
Q2: When l4_fpage_unmap() is called, is the previous mapping to the pages of the kmalloc-ed memory restored?
After the external pages are unmapped, pagefaults to the area are served by the Linux server which maps pages of /dev/zero.
Frank
l4-hackers@os.inf.tu-dresden.de