From owner-cvs-src@FreeBSD.ORG Tue Jan 8 22:25:05 2008 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4F7116A41B; Tue, 8 Jan 2008 22:25:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id C70D413C50B; Tue, 8 Jan 2008 22:25:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by elvis.mu.org (Postfix) with ESMTP id 23F1A1A3C1A; Tue, 8 Jan 2008 14:06:13 -0800 (PST) From: John Baldwin To: src-committers@freebsd.org Date: Tue, 8 Jan 2008 17:08:22 -0500 User-Agent: KMail/1.9.7 References: <200801082158.m08LwGXh035451@repoman.freebsd.org> In-Reply-To: <200801082158.m08LwGXh035451@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801081708.23328.jhb@freebsd.org> Cc: cvs-src@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/lib/libc/gen Makefile.inc posixshm.c shm_open.3 src/lib/libc/sys Makefile.inc shm_open.2 src/sys/compat/freebsd32 syscalls.master src/sys/conf files src/sys/kern kern_descrip.c syscalls.master uipc_shm.c src/sys/security/mac mac_framework.h ... X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2008 22:25:06 -0000 On Tuesday 08 January 2008 04:58:16 pm John Baldwin wrote: > jhb 2008-01-08 21:58:16 UTC > > FreeBSD src repository > > Modified files: > lib/libc/gen Makefile.inc > lib/libc/sys Makefile.inc shm_open.2 > sys/compat/freebsd32 syscalls.master > sys/conf files > sys/kern kern_descrip.c syscalls.master > sys/security/mac mac_framework.h mac_policy.h > sys/security/mac_stub mac_stub.c > sys/security/mac_test mac_test.c > sys/sys fcntl.h file.h mman.h > sys/vm vm_mmap.c > Added files: > sys/kern uipc_shm.c > sys/security/mac mac_posix_shm.c > Removed files: > lib/libc/gen posixshm.c shm_open.3 > Log: > Add a new file descriptor type for IPC shared memory objects and use it to > implement shm_open(2) and shm_unlink(2) in the kernel: > - Each shared memory file descriptor is associated with a swap-backed vm > object which provides the backing store. Each descriptor starts off with > a size of zero, but the size can be altered via ftruncate(2). The shared > memory file descriptors also support fstat(2). read(2), write(2), > ioctl(2), select(2), poll(2), and kevent(2) are not supported on shared > memory file descriptors. > - shm_open(2) and shm_unlink(2) are now implemented as system calls that > manage shared memory file descriptors. The virtual namespace that maps > pathnames to shared memory file descriptors is implemented as a hash > table where the hash key is generated via the 32-bit Fowler/Noll/Vo hash > of the pathname. > - As an extension, the constant 'SHM_ANON' may be specified in place of the > path argument to shm_open(2). In this case, an unnamed shared memory > file descriptor will be created similar to the IPC_PRIVATE key for > shmget(2). Note that the shared memory object can still be shared among > processes by sharing the file descriptor via fork(2) or sendmsg(2), but > it is unnamed. This effectively serves to implement the getmemfd() idea > bandied about the lists several times over the years. > - The backing store for shared memory file descriptors are garbage > collected when they are not referenced by any open file descriptors or > the shm_open(2) virtual namespace. > > Submitted by: dillon, peter (previous versions) > Submitted by: rwatson (I based this on his version) > Reviewed by: alc (suggested converting getmemfd() to shm_open()) Some ABI compat stuff I forgot to mention: 1) Even though shm_open() and shm_unlink() are now syscalls instead of functions in libc, the ABI actually should not change since syscalls also show up as functions in libc and they take the same arguments now that they did before. 2) Programs compiled with older libcs are still going to use files to back shm_open() instead of the new system calls. To that end, the flag shm_open() uses to flag a file as a shm fd for special mmap() treatment (FPOSIXSHM) is still supported if any of COMPAT_FREEBSD[4567]. 3) As a better fix for the above I plan to teach the shm_open() and shm_unlink() functions in libc in RELENG_[4567] to use these new system calls if kern.feature.posix_shm is present and enabled so that older dynamically linked binaries will have the same behavior for shm_open() and shm_unlink(). This will leave only old static binaries that using shm_open() and shm_unlink() in the situation that they use different backing store for the same shared memory object. -- John Baldwin