Date: Tue, 8 Jan 2008 17:08:22 -0500 From: John Baldwin <jhb@freebsd.org> To: src-committers@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 ... Message-ID: <200801081708.23328.jhb@freebsd.org> In-Reply-To: <200801082158.m08LwGXh035451@repoman.freebsd.org> References: <200801082158.m08LwGXh035451@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801081708.23328.jhb>