Date: Tue, 15 Nov 2005 19:00:22 +1100 From: Peter Jeremy <PeterJeremy@optushome.com.au> To: John Giacomoni <John.Giacomoni@colorado.edu> Cc: freebsd-hackers@freebsd.org Subject: Re: Sharing the same VM address space between Kernel and UserSpace Message-ID: <20051115080022.GI39882@cirb503493.alcatel.com.au> In-Reply-To: <AA4AEE17-32CC-4D47-96C0-0B0B0BC13B68@colorado.edu> References: <AA4AEE17-32CC-4D47-96C0-0B0B0BC13B68@colorado.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2005-Nov-14 13:39:19 -0700, John Giacomoni wrote: >I am in need of a way to share memory between kernel space and possibly >multiple different user-space processes for an extended period of time. >This memory would need to be a single unpageable region. Does the region have to have the same address in both kernel and user space? Based on some of your later comments, I suspect you only need the same address is all userland processes. If this is true, then I think all you need to do is malloc(9) the space, vm_map_wire(9) it and arrange for all userland processes to mmap(2) it at the same address - by having them pass MAP_FIXED. (The malloc() and vm_map_wire() are only needed once because the memory will remain wired until the kernel releases it). Avoiding other mappings isn't that difficult, though it's not totally trivial. You need to avoid KVA, stack, text, heap, shared libraries, SysV SHM and other random mmap()'s. If this is a fairly custom application, you can get a fairly good idea of what other mappings exist and just ensure that you pick an unused address and mmap it fairly early. If you need to allocate a very large region (getting towards the GB region) or this is part of a library that is supposed to be linked into arbitrary applications then things may be more difficult. -- Peter Jeremy
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051115080022.GI39882>