From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 15 08:00:28 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7C12016A41F for ; Tue, 15 Nov 2005 08:00:28 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail16.syd.optusnet.com.au (mail16.syd.optusnet.com.au [211.29.132.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA85F43D49 for ; Tue, 15 Nov 2005 08:00:27 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail16.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id jAF80Nb5003424 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 15 Nov 2005 19:00:23 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id jAF80NHh091777; Tue, 15 Nov 2005 19:00:23 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id jAF80MCs091776; Tue, 15 Nov 2005 19:00:23 +1100 (EST) (envelope-from pjeremy) Date: Tue, 15 Nov 2005 19:00:22 +1100 From: Peter Jeremy To: John Giacomoni Message-ID: <20051115080022.GI39882@cirb503493.alcatel.com.au> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc Cc: freebsd-hackers@freebsd.org Subject: Re: Sharing the same VM address space between Kernel and UserSpace X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Nov 2005 08:00:28 -0000 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