changeset 9264:e1b435ce53de

6824605 SUNWtetos test shm_stress_07_02 requires excessive time starting with snv_112
author Roger A. Faulkner <Roger.Faulkner@Sun.COM>
date Thu, 02 Apr 2009 14:09:25 -0700
parents 48d14e1f550f
children 0ddbce3734dc
files usr/src/cmd/sgs/rtld/common/external.c usr/src/cmd/truss/systable.c usr/src/lib/libc/Makefile usr/src/lib/libc/amd64/Makefile usr/src/lib/libc/common/sys/__mmap.s usr/src/lib/libc/common/sys/__munmap.s usr/src/lib/libc/common/sys/mmap.s usr/src/lib/libc/common/sys/munmap.s usr/src/lib/libc/common/sys/syslwp.s usr/src/lib/libc/i386/Makefile.com usr/src/lib/libc/inc/thr_uberdata.h usr/src/lib/libc/port/gen/mmap.c usr/src/lib/libc/port/gen/munmap.c usr/src/lib/libc/port/sys/shmsys.c usr/src/lib/libc/port/threads/scalls.c usr/src/lib/libc/port/threads/synch.c usr/src/lib/libc/sparc/Makefile.com usr/src/lib/libc/sparcv9/Makefile.com usr/src/uts/common/os/sysent.c usr/src/uts/common/sys/lwpchan_impl.h usr/src/uts/common/syscall/lwp_sobj.c
diffstat 21 files changed, 188 insertions(+), 393 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/sgs/rtld/common/external.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/cmd/sgs/rtld/common/external.c	Thu Apr 02 14:09:25 2009 -0700
@@ -546,15 +546,6 @@
 }
 
 /*
- * munmap() calls this.  It is unnecessary in the dynamic linker.
- */
-/* ARGSUSED */
-void
-unregister_locks(caddr_t addr, size_t len)
-{
-}
-
-/*
  * The following functions are cancellation points in libc.
  * They are called from other functions in libc that we extract
  * and use directly.  We don't do cancellation while we are in
--- a/usr/src/cmd/truss/systable.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/cmd/truss/systable.c	Thu Apr 02 14:09:25 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -472,7 +472,7 @@
 {"ntp_adjtime",	1, DEC, NOV, HEX},				/* 249 */
 {"lwp_mutex_unlock", 1, DEC, NOV, HEX},				/* 250 */
 {"lwp_mutex_trylock", 1, DEC, NOV, HEX},			/* 251 */
-{"lwp_mutex_register", 1, DEC, NOV, HEX},			/* 252 */
+{"lwp_mutex_register", 2, DEC, NOV, HEX, HEX},			/* 252 */
 {"cladm",	3, DEC, NOV, CLC, CLF, HEX},			/* 253 */
 {"uucopy",	3, DEC, NOV, HEX, HEX, UNS},			/* 254 */
 {"umount2",	2, DEC, NOV, STG, MTF},				/* 255 */
--- a/usr/src/lib/libc/Makefile	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/Makefile	Thu Apr 02 14:09:25 2009 -0700
@@ -86,7 +86,7 @@
 VARIANT_SUBDIRS64	= $(VARIANTS64:%=$(MACH)_%/$(VARBLD64))
 
 SUBDIRS=	$(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS)
-$(BUILD64)SUBDIRS += $(MACH64)
+$(BUILD64)SUBDIRS += $(MACH64) $(VARIANT_SUBDIRS64)
 
 LIBS =		$(DYNLIB) $(LINTLIB)
 
--- a/usr/src/lib/libc/amd64/Makefile	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/amd64/Makefile	Thu Apr 02 14:09:25 2009 -0700
@@ -140,8 +140,6 @@
 COMSYSOBJS=			\
 	__clock_timer.o		\
 	__getloadavg.o		\
-	__mmap.o		\
-	__munmap.o		\
 	__rusagesys.o		\
 	__signotify.o		\
 	__sigrt.o		\
@@ -227,9 +225,11 @@
 	mincore.o		\
 	mkdir.o			\
 	mknod.o			\
+	mmap.o			\
 	modctl.o		\
 	mount.o			\
 	mprotect.o		\
+	munmap.o		\
 	nice.o			\
 	ntp_adjtime.o		\
 	ntp_gettime.o		\
@@ -471,12 +471,10 @@
 	mktemp.o		\
 	mlock.o			\
 	mlockall.o		\
-	mmap.o			\
 	mon.o			\
 	msync.o			\
 	munlock.o		\
 	munlockall.o		\
-	munmap.o		\
 	ndbm.o			\
 	nftw.o			\
 	nlspath_checks.o	\
--- a/usr/src/lib/libc/common/sys/__mmap.s	Thu Apr 02 13:52:34 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright (c) 1988 AT&T	*/
-/*	All Rights Reserved	*/
-
-	.file	"__mmap.s"
-
-#include "SYS.h"
-#include <sys/mman.h>		/* Need _MAP_NEW definition     */
-
-#if !defined(_LARGEFILE_SOURCE)
-
-/*
- * Raw system call, private to libc:
- * caddr_t __mmap(caddr_t addr, size_t len, int prot,
- *	int flags, int fd, off_t off)
- */
-
-	ENTRY(__mmap)
-#if defined(__sparc)
-	/* this depends upon the _MAP_NEW flag being in the top bits */
-	sethi	%hi(_MAP_NEW), %g1
-	or	%g1, %o3, %o3
-#endif
-	SYSTRAP_RVAL1(mmap)
-	SYSCERROR
-	RET
-	SET_SIZE(__mmap)
-
-#else
-
-/*
- * Raw system call, private to libc:
- * caddr_t __mmap64(caddr_t addr, size_t len, int prot,
- *	int flags, int fd, off64_t off)
- */
-
-	ENTRY(__mmap64)
-#if defined(__sparc)
-	/* this depends upon the _MAP_NEW flag being in the top bits */
-	sethi	%hi(_MAP_NEW), %g1
-	or	%g1, %o3, %o3
-#endif
-	SYSTRAP_RVAL1(mmap64)
-	SYSCERROR
-	RET
-	SET_SIZE(__mmap64)
-
-#endif
--- a/usr/src/lib/libc/common/sys/__munmap.s	Thu Apr 02 13:52:34 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright (c) 1988 AT&T	*/
-/*	  All Rights Reserved	*/
-
-	.file	"__munmap.s"
-
-/*
- * Raw system call:
- * int __munmap(caddr_t addr, size_t len)
- */
-
-#include "SYS.h"
-
-	ENTRY(__munmap)
-	SYSTRAP_RVAL1(munmap)
-	SYSCERROR
-	RETC
-	SET_SIZE(__munmap)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libc/common/sys/mmap.s	Thu Apr 02 14:09:25 2009 -0700
@@ -0,0 +1,81 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*	Copyright (c) 1988 AT&T	*/
+/*	All Rights Reserved	*/
+
+	.file	"mmap.s"
+
+#include <sys/asm_linkage.h>
+
+#if !defined(_LARGEFILE_SOURCE)
+	ANSI_PRAGMA_WEAK(mmap,function)
+#else
+	ANSI_PRAGMA_WEAK(mmap64,function)
+#endif
+
+#include "SYS.h"
+#include <sys/mman.h>		/* Need _MAP_NEW definition     */
+
+#if !defined(_LARGEFILE_SOURCE)
+
+/*
+ * C library -- mmap
+ * caddr_t mmap(caddr_t addr, size_t len, int prot,
+ *	int flags, int fd, off_t off)
+ */
+
+	ENTRY(mmap)
+#if defined(__sparc)
+	/* this depends upon the _MAP_NEW flag being in the top bits */
+	sethi	%hi(_MAP_NEW), %g1
+	or	%g1, %o3, %o3
+#endif
+	SYSTRAP_RVAL1(mmap)
+	SYSCERROR
+	RET
+	SET_SIZE(mmap)
+
+#else
+
+/*
+ * C library -- mmap64
+ * caddr_t mmap64(caddr_t addr, size_t len, int prot,
+ *	int flags, int fd, off64_t off)
+ */
+
+	ENTRY(mmap64)
+#if defined(__sparc)
+	/* this depends upon the _MAP_NEW flag being in the top bits */
+	sethi	%hi(_MAP_NEW), %g1
+	or	%g1, %o3, %o3
+#endif
+	SYSTRAP_RVAL1(mmap64)
+	SYSCERROR
+	RET
+	SET_SIZE(mmap64)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libc/common/sys/munmap.s	Thu Apr 02 14:09:25 2009 -0700
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*	Copyright (c) 1988 AT&T	*/
+/*	  All Rights Reserved	*/
+
+	.file	"munmap.s"
+
+/*
+ * C library -- munmap
+ * int munmap(caddr_t addr, size_t len)
+ */
+
+#include <sys/asm_linkage.h>
+
+	ANSI_PRAGMA_WEAK(munmap,function)
+
+#include "SYS.h"
+
+	SYSCALL_RVAL1(munmap)
+	RETC
+	SET_SIZE(munmap)
--- a/usr/src/lib/libc/common/sys/syslwp.s	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/common/sys/syslwp.s	Thu Apr 02 14:09:25 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -225,7 +225,7 @@
 
 /*
  * int
- * ___lwp_mutex_register(lwp_mutex_t *mp)
+ * ___lwp_mutex_register(lwp_mutex_t *mp, lwp_mutex_t **uaddr)
  */
 	ENTRY(___lwp_mutex_register)
 	SYSTRAP_RVAL1(lwp_mutex_register)
--- a/usr/src/lib/libc/i386/Makefile.com	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/i386/Makefile.com	Thu Apr 02 14:09:25 2009 -0700
@@ -145,7 +145,6 @@
 
 # sysobjs that contain large-file interfaces
 COMSYSOBJS64=			\
-	__mmap64.o		\
 	creat64.o		\
 	fstat64.o		\
 	fstatvfs64.o		\
@@ -153,6 +152,7 @@
 	getrlimit64.o		\
 	lseek64.o		\
 	lstat64.o		\
+	mmap64.o		\
 	open64.o		\
 	pread64.o		\
 	pwrite64.o		\
@@ -165,8 +165,6 @@
 COMSYSOBJS=			\
 	__clock_timer.o		\
 	__getloadavg.o		\
-	__mmap.o		\
-	__munmap.o		\
 	__rusagesys.o		\
 	__signotify.o		\
 	__sigrt.o		\
@@ -252,9 +250,11 @@
 	mincore.o		\
 	mkdir.o			\
 	mknod.o			\
+	mmap.o			\
 	modctl.o		\
 	mount.o			\
 	mprotect.o		\
+	munmap.o		\
 	nice.o			\
 	ntp_adjtime.o		\
 	ntp_gettime.o		\
@@ -347,7 +347,6 @@
 	attropen64.o		\
 	ftw64.o			\
 	mkstemp64.o		\
-	mmap64.o		\
 	nftw64.o		\
 	tell64.o		\
 	truncate64.o
@@ -505,12 +504,10 @@
 	mktemp.o		\
 	mlock.o			\
 	mlockall.o		\
-	mmap.o			\
 	mon.o			\
 	msync.o			\
 	munlock.o		\
 	munlockall.o		\
-	munmap.o		\
 	ndbm.o			\
 	nftw.o			\
 	nlspath_checks.o	\
--- a/usr/src/lib/libc/inc/thr_uberdata.h	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/inc/thr_uberdata.h	Thu Apr 02 14:09:25 2009 -0700
@@ -1219,8 +1219,7 @@
 extern	void	remember_lock(mutex_t *);
 extern	void	forget_lock(mutex_t *);
 extern	void	register_lock(mutex_t *);
-extern	void	unregister_locks(caddr_t, size_t);
-extern	void	unregister_all_locks(void);
+extern	void	unregister_locks(void);
 #if defined(__sparc)
 extern	void	_flush_windows(void);
 #else
@@ -1412,7 +1411,7 @@
 /*
  * System call wrappers (direct interfaces to the kernel)
  */
-extern	int	___lwp_mutex_register(mutex_t *);
+extern	int	___lwp_mutex_register(mutex_t *, mutex_t **);
 extern	int	___lwp_mutex_trylock(mutex_t *);
 extern	int	___lwp_mutex_timedlock(mutex_t *, timespec_t *);
 extern	int	___lwp_mutex_unlock(mutex_t *);
--- a/usr/src/lib/libc/port/gen/mmap.c	Thu Apr 02 13:52:34 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include "lint.h"
-#include <sys/feature_tests.h>
-#include <sys/mman.h>
-
-extern void unregister_locks(caddr_t, size_t);
-
-#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
-
-extern caddr_t __mmap64(caddr_t, size_t, int, int, int, off64_t);
-
-#pragma weak _mmap64 = mmap64
-caddr_t
-mmap64(caddr_t addr, size_t len, int prot, int flags, int fildes, off64_t off)
-{
-	if (flags & MAP_FIXED)
-		unregister_locks(addr, len);
-	return (__mmap64(addr, len, prot, flags, fildes, off));
-}
-
-#else
-
-extern caddr_t __mmap(caddr_t, size_t, int, int, int, off_t);
-
-#pragma weak _mmap = mmap
-caddr_t
-mmap(caddr_t addr, size_t len, int prot, int flags, int fildes, off_t off)
-{
-	if (flags & MAP_FIXED)
-		unregister_locks(addr, len);
-	return (__mmap(addr, len, prot, flags, fildes, off));
-}
-
-#endif
--- a/usr/src/lib/libc/port/gen/munmap.c	Thu Apr 02 13:52:34 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma weak _munmap = munmap
-
-#include "lint.h"
-#include <sys/mman.h>
-
-extern void unregister_locks(caddr_t, size_t);
-extern int __munmap(caddr_t, size_t);
-
-int
-munmap(caddr_t addr, size_t len)
-{
-	unregister_locks(addr, len);
-	return (__munmap(addr, len));
-}
--- a/usr/src/lib/libc/port/sys/shmsys.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/port/sys/shmsys.c	Thu Apr 02 14:09:25 2009 -0700
@@ -35,7 +35,6 @@
 #pragma weak _shmids = shmids
 
 #include "lint.h"
-#include "thr_uberdata.h"
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/ipc_impl.h>
@@ -44,92 +43,16 @@
 #include <sys/syscall.h>
 #include <errno.h>
 
-/*
- * List of all shared memory segments.
- * We need this to keep track of the sizes so that we can unregister
- * any robust locks that are contained in a segment that is detached.
- */
-static struct shm_size {
-	void		*shm_addr;
-	size_t		shm_size;
-	struct shm_size	*shm_next;
-} *shm_list = NULL;
-
-static mutex_t shm_lock = DEFAULTMUTEX;		/* protects shm_list */
-
-extern void unregister_locks(caddr_t, size_t);
-
-/*
- * Add a shared memory address and size to the remembered list.
- */
-static void
-add_shm_size(void *addr, size_t size)
-{
-	struct shm_size **list;
-	struct shm_size *elem;
-
-	lmutex_lock(&shm_lock);
-
-	for (list = &shm_list; (elem = *list) != NULL; list = &elem->shm_next) {
-		if (elem->shm_addr == addr) {	/* won't happen? */
-			elem->shm_size = size;
-			lmutex_unlock(&shm_lock);
-			return;
-		}
-	}
-	elem = lmalloc(sizeof (*elem));
-	elem->shm_addr = addr;
-	elem->shm_size = size;
-	elem->shm_next = NULL;
-	*list = elem;
-
-	lmutex_unlock(&shm_lock);
-}
-
-/*
- * Delete the shared memory address from the remembered list
- * and unregister all of the robust locks contained therein.
- */
-static void
-delete_shm_size(void *addr)
-{
-	struct shm_size **list;
-	struct shm_size *elem;
-	size_t size = 0;
-
-	lmutex_lock(&shm_lock);
-
-	for (list = &shm_list; (elem = *list) != NULL; list = &elem->shm_next) {
-		if (elem->shm_addr == addr) {
-			size = elem->shm_size;
-			*list = elem->shm_next;
-			lfree(elem, sizeof (*elem));
-			break;
-		}
-	}
-
-	lmutex_unlock(&shm_lock);
-
-	if (size != 0)
-		unregister_locks(addr, size);
-}
-
 void *
 shmat(int shmid, const void *shmaddr, int shmflg)
 {
 	sysret_t rval;
 	int error;
-	void *addr;
-	struct shmid_ds shmds;
 
 	error = __systemcall(&rval, SYS_shmsys, SHMAT, shmid, shmaddr, shmflg);
-	addr = (void *)rval.sys_rval1;
-	if (error) {
+	if (error)
 		(void) __set_errno(error);
-	} else if (shmctl(shmid, IPC_STAT, &shmds) == 0) {
-		add_shm_size(addr, shmds.shm_segsz);
-	}
-	return (addr);
+	return ((void *)rval.sys_rval1);
 }
 
 int
@@ -155,10 +78,7 @@
 int
 shmdt(char *shmaddr)
 {
-	int rval = syscall(SYS_shmsys, SHMDT, shmaddr);
-	if (rval == 0)
-		delete_shm_size(shmaddr);
-	return (rval);
+	return (syscall(SYS_shmsys, SHMDT, shmaddr));
 }
 
 int
--- a/usr/src/lib/libc/port/threads/scalls.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/port/threads/scalls.c	Thu Apr 02 14:09:25 2009 -0700
@@ -243,7 +243,7 @@
 		self->ul_siginfo.si_signo = 0;
 		udp->pid = getpid();
 		/* reset the library's data structures to reflect one thread */
-		unregister_all_locks();
+		unregister_locks();
 		postfork1_child();
 		restore_signals(self);
 		(void) mutex_unlock(&udp->fork_lock);
@@ -321,7 +321,7 @@
 		self->ul_cursig = 0;
 		self->ul_siginfo.si_signo = 0;
 		udp->pid = getpid();
-		unregister_all_locks();
+		unregister_locks();
 		continue_fork(1);
 	} else {
 		continue_fork(0);
--- a/usr/src/lib/libc/port/threads/synch.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/port/threads/synch.c	Thu Apr 02 14:09:25 2009 -0700
@@ -1985,12 +1985,12 @@
 	 * The lock has never been registered.
 	 * Add it to the table and register it now.
 	 */
-	if (invalid != NULL) {
+	if ((rlp = invalid) != NULL) {
 		/*
 		 * Reuse the invalid entry we found above.
 		 * The linkages are still correct.
 		 */
-		invalid->robust_lock = mp;
+		rlp->robust_lock = mp;
 		membar_producer();
 	} else {
 		/*
@@ -2008,45 +2008,7 @@
 
 	lmutex_unlock(&udp->tdb_hash_lock);
 
-	(void) ___lwp_mutex_register(mp);
-}
-
-/*
- * This is called from mmap(), munmap() and shmdt() to unregister
- * all robust locks contained in the mapping that is going away.
- * We don't delete the entries in the hash table, since the hash table
- * is constrained never to shrink; we just invalidate the addresses.
- */
-void
-unregister_locks(caddr_t addr, size_t len)
-{
-	static size_t pagesize = 0;
-	uberdata_t *udp = curthread->ul_uberdata;
-	robust_t *rlp;
-	caddr_t eaddr;
-	caddr_t maddr;
-
-	/*
-	 * Round up len to a multiple of pagesize.
-	 */
-	if (pagesize == 0)	/* do this once */
-		pagesize = _sysconf(_SC_PAGESIZE);
-	eaddr = addr + ((len + pagesize - 1) & -pagesize);
-
-	lmutex_lock(&udp->tdb_hash_lock);
-
-	/*
-	 * Do this by traversing the global list, not the hash table.
-	 * The hash table is large (32K buckets) and sparsely populated.
-	 * The global list contains all of the registered entries.
-	 */
-	for (rlp = udp->robustlist; rlp != NULL; rlp = rlp->robust_list) {
-		maddr = (caddr_t)rlp->robust_lock;
-		if (addr <= maddr && maddr < eaddr)
-			rlp->robust_lock = INVALID_ADDR;
-	}
-
-	lmutex_unlock(&udp->tdb_hash_lock);
+	(void) ___lwp_mutex_register(mp, &rlp->robust_lock);
 }
 
 /*
@@ -2055,7 +2017,7 @@
  * No locks are needed because all other threads are suspended or gone.
  */
 void
-unregister_all_locks(void)
+unregister_locks(void)
 {
 	uberdata_t *udp = curthread->ul_uberdata;
 	robust_t **table;
@@ -2064,7 +2026,6 @@
 
 	/*
 	 * Do this first, before calling lfree().
-	 * lfree() may call munmap(), which calls unregister_locks().
 	 */
 	table = udp->robustlocks;
 	udp->robustlocks = NULL;
@@ -2072,7 +2033,7 @@
 	udp->robustlist = NULL;
 
 	/*
-	 * As above, do this by traversing the global list, not the hash table.
+	 * Do this by traversing the global list, not the hash table.
 	 */
 	while (rlp != NULL) {
 		next = rlp->robust_list;
--- a/usr/src/lib/libc/sparc/Makefile.com	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/sparc/Makefile.com	Thu Apr 02 14:09:25 2009 -0700
@@ -155,7 +155,6 @@
 
 # sysobjs that contain large-file interfaces
 COMSYSOBJS64=			\
-	__mmap64.o		\
 	creat64.o		\
 	fstat64.o		\
 	fstatvfs64.o		\
@@ -163,6 +162,7 @@
 	getrlimit64.o		\
 	lseek64.o		\
 	lstat64.o		\
+	mmap64.o		\
 	open64.o		\
 	pread64.o		\
 	pwrite64.o		\
@@ -175,8 +175,6 @@
 COMSYSOBJS=			\
 	__clock_timer.o		\
 	__getloadavg.o		\
-	__mmap.o		\
-	__munmap.o		\
 	__rusagesys.o		\
 	__signotify.o		\
 	__sigrt.o		\
@@ -261,10 +259,12 @@
 	mincore.o		\
 	mkdir.o			\
 	mknod.o			\
+	mmap.o			\
 	mmapobjsys.o		\
 	modctl.o		\
 	mount.o			\
 	mprotect.o		\
+	munmap.o		\
 	nice.o			\
 	ntp_adjtime.o		\
 	ntp_gettime.o		\
@@ -348,7 +348,6 @@
 	attropen64.o		\
 	ftw64.o			\
 	mkstemp64.o		\
-	mmap64.o		\
 	nftw64.o		\
 	tell64.o		\
 	truncate64.o
@@ -522,12 +521,10 @@
 	mktemp.o		\
 	mlock.o			\
 	mlockall.o		\
-	mmap.o			\
 	mon.o			\
 	msync.o			\
 	munlock.o		\
 	munlockall.o		\
-	munmap.o		\
 	ndbm.o			\
 	nftw.o			\
 	nlspath_checks.o	\
--- a/usr/src/lib/libc/sparcv9/Makefile.com	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/lib/libc/sparcv9/Makefile.com	Thu Apr 02 14:09:25 2009 -0700
@@ -157,8 +157,6 @@
 COMSYSOBJS=			\
 	__clock_timer.o		\
 	__getloadavg.o		\
-	__mmap.o		\
-	__munmap.o		\
 	__rusagesys.o		\
 	__signotify.o		\
 	__sigrt.o		\
@@ -243,10 +241,12 @@
 	mincore.o		\
 	mkdir.o			\
 	mknod.o			\
+	mmap.o			\
 	mmapobjsys.o		\
 	modctl.o		\
 	mount.o			\
 	mprotect.o		\
+	munmap.o		\
 	nice.o			\
 	ntp_adjtime.o		\
 	ntp_gettime.o		\
@@ -482,12 +482,10 @@
 	mktemp.o		\
 	mlock.o			\
 	mlockall.o		\
-	mmap.o			\
 	mon.o			\
 	msync.o			\
 	munlock.o		\
 	munlockall.o		\
-	munmap.o		\
 	ndbm.o			\
 	nftw.o			\
 	nlspath_checks.o	\
--- a/usr/src/uts/common/os/sysent.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/uts/common/os/sysent.c	Thu Apr 02 14:09:25 2009 -0700
@@ -21,7 +21,7 @@
 
 /* ONC_PLUS EXTRACT START */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -772,7 +772,7 @@
 	/* 249 */ SYSENT_CI("ntp_adjtime",	ntp_adjtime,	1),
 	/* 250 */ SYSENT_CI("lwp_mutex_unlock",	lwp_mutex_unlock,	1),
 	/* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock,	1),
-	/* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register,	1),
+	/* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register,	2),
 	/* 253 */ SYSENT_CI("cladm",		cladm,		3),
 	/* 254 */ SYSENT_CI("uucopy",		uucopy,		3),
 	/* 255 */ SYSENT_CI("umount2",		umount2,	2)
@@ -1118,7 +1118,7 @@
 	/* 249 */ SYSENT_CI("ntp_adjtime",	ntp_adjtime,	1),
 	/* 250 */ SYSENT_CI("lwp_mutex_unlock",	lwp_mutex_unlock,	1),
 	/* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock,	1),
-	/* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register,	1),
+	/* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register,	2),
 	/* 253 */ SYSENT_CI("cladm",		cladm,		3),
 	/* 254 */ SYSENT_CI("uucopy",		uucopy,		3),
 	/* 255 */ SYSENT_CI("umount2",		umount2,	2)
--- a/usr/src/uts/common/sys/lwpchan_impl.h	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/uts/common/sys/lwpchan_impl.h	Thu Apr 02 14:09:25 2009 -0700
@@ -20,15 +20,13 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 #ifndef	_SYS_LCHAN_IMPL_H
 #define	_SYS_LCHAN_IMPL_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -46,6 +44,7 @@
  */
 typedef struct lwpchan_entry {
 	caddr_t lwpchan_addr;		/* virtual address */
+	caddr_t lwpchan_uaddr;		/* address of lock registration */
 	uint16_t lwpchan_type;		/* sync object type field */
 	uint16_t lwpchan_pool;		/* LWPCHAN_CVPOOL/LWPCHAN_MPPOOL */
 	lwpchan_t lwpchan_lwpchan;	/* unique logical address */
--- a/usr/src/uts/common/syscall/lwp_sobj.c	Thu Apr 02 13:52:34 2009 -0700
+++ b/usr/src/uts/common/syscall/lwp_sobj.c	Thu Apr 02 14:09:25 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -66,6 +66,7 @@
 static void lwp_unsleep(kthread_t *t);
 static void lwp_change_pri(kthread_t *t, pri_t pri, pri_t *t_prip);
 static void lwp_mutex_cleanup(lwpchan_entry_t *ent, uint16_t lockflg);
+static void lwp_mutex_unregister(void *uaddr);
 
 extern int lwp_cond_signal(lwp_cond_t *cv);
 
@@ -185,6 +186,12 @@
 				if (ent->lwpchan_pool == LWPCHAN_MPPOOL &&
 				    (ent->lwpchan_type & USYNC_PROCESS_ROBUST))
 					lwp_mutex_cleanup(ent, LOCK_UNMAPPED);
+				/*
+				 * If there is a user-level robust lock
+				 * registration, mark it as invalid.
+				 */
+				if ((addr = ent->lwpchan_uaddr) != NULL)
+					lwp_mutex_unregister(addr);
 				kmem_free(ent, sizeof (*ent));
 				atomic_add_32(&lcp->lwpchan_entries, -1);
 			} else {
@@ -395,7 +402,7 @@
  * a virtual address to lwpchan mapping into the cache.
  */
 static int
-lwpchan_get_mapping(struct as *as, caddr_t addr,
+lwpchan_get_mapping(struct as *as, caddr_t addr, caddr_t uaddr,
 	int type, lwpchan_t *lwpchan, int pool)
 {
 	proc_t *p = curproc;
@@ -453,6 +460,7 @@
 		goto top;
 	}
 	ent->lwpchan_addr = addr;
+	ent->lwpchan_uaddr = uaddr;
 	ent->lwpchan_type = (uint16_t)type;
 	ent->lwpchan_pool = (uint16_t)pool;
 	ent->lwpchan_lwpchan = *lwpchan;
@@ -484,7 +492,7 @@
 		return (1);
 	}
 
-	return (lwpchan_get_mapping(as, addr, type, lwpchan, pool));
+	return (lwpchan_get_mapping(as, addr, NULL, type, lwpchan, pool));
 }
 
 static void
@@ -2958,7 +2966,7 @@
  * Register a process-shared robust mutex in the lwpchan cache.
  */
 int
-lwp_mutex_register(lwp_mutex_t *lp)
+lwp_mutex_register(lwp_mutex_t *lp, caddr_t uaddr)
 {
 	int error = 0;
 	volatile int watched;
@@ -2984,8 +2992,8 @@
 		if ((type & (USYNC_PROCESS|LOCK_ROBUST))
 		    != (USYNC_PROCESS|LOCK_ROBUST)) {
 			error = EINVAL;
-		} else if (!get_lwpchan(curproc->p_as, (caddr_t)lp, type,
-		    &lwpchan, LWPCHAN_MPPOOL)) {
+		} else if (!lwpchan_get_mapping(curproc->p_as, (caddr_t)lp,
+		    uaddr, type, &lwpchan, LWPCHAN_MPPOOL)) {
 			error = EFAULT;
 		}
 	}
@@ -2997,6 +3005,22 @@
 	return (0);
 }
 
+/*
+ * There is a user-level robust lock registration in libc.
+ * Mark it as invalid by storing -1 into the location of the pointer.
+ */
+static void
+lwp_mutex_unregister(void *uaddr)
+{
+	if (get_udatamodel() == DATAMODEL_NATIVE) {
+		(void) sulword(uaddr, (ulong_t)-1);
+#ifdef _SYSCALL32_IMPL
+	} else {
+		(void) suword32(uaddr, (uint32_t)-1);
+#endif
+	}
+}
+
 int
 lwp_mutex_trylock(lwp_mutex_t *lp)
 {