Mercurial > illumos > illumos-gate
changeset 13093:431da7fc1d0a
6944589 need pause API
PSARC/2010/293 smt_pause
line wrap: on
line diff
--- a/usr/src/head/synch.h Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/head/synch.h Wed Aug 11 17:59:10 2010 -0400 @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _SYNCH_H @@ -262,6 +261,13 @@ #endif /* __STDC__ */ +/* Pause API */ +#ifdef __STDC__ +void smt_pause(void); +#else /* __STDC__ */ +void smt_pause(); +#endif /* __STDC__ */ + #endif /* _ASM */ #ifdef __cplusplus
--- a/usr/src/lib/libc/amd64/threads/machdep.c Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/amd64/threads/machdep.c Wed Aug 11 17:59:10 2010 -0400 @@ -20,8 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. */ #include "lint.h" @@ -197,3 +196,9 @@ return (0); } + +void +smt_pause(void) +{ + SMT_PAUSE(); +}
--- a/usr/src/lib/libc/capabilities/Makefile.com Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/Makefile.com Wed Aug 11 17:59:10 2010 -0400 @@ -32,3 +32,5 @@ SYMCAP = pics/symcap.o CLOBBERFILES += $(OBJCAP) $(SYMCAP) + +LIBCBASE = $(SRC)/lib/libc
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap1/Makefile.com Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/sun4v-hwcap1/Makefile.com Wed Aug 11 17:59:10 2010 -0400 @@ -28,13 +28,14 @@ include ../../Makefile.com -OBJECTS = memcpy.o memset.o +OBJECTS = memcpy.o memset.o smt_pause.o include $(SRC)/lib/Makefile.lib IFLAGS = -I$(SRC)/uts/$(GEN_PLATFORM) \ -I$(ROOT)/usr/include/v9 + AS_CPPFLAGS += -D__STDC__ -D_ASM -DPIC -D_REENTRANT -D$(MACH) $(IFLAGS) \ -DNIAGARA_IMPL ASFLAGS = -P -K pic
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap1/common/mapfile-cap Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/sun4v-hwcap1/common/mapfile-cap Wed Aug 11 17:59:10 2010 -0400 @@ -37,6 +37,7 @@ memcpy; memmove; memset; + smt_pause; local: *; };
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap1/sparc/Makefile Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/sun4v-hwcap1/sparc/Makefile Wed Aug 11 17:59:10 2010 -0400 @@ -25,10 +25,15 @@ include ../Makefile.com -ASFLAGS += -xarch=v8plus +ASFLAGS += -xarch=v8plus -I$(LIBCBASE)/$(MACH) .KEEP_STATE: -all install: $(SYMCAP) +all install: $(LIBCBASE)/$(MACH)/assym.h $(SYMCAP) + +# We need assym.h, but it won't build directly. smt_pause.o depends on +# assym.h, so building it forces assym.h to be built. +$(LIBCBASE)/$(MACH)/assym.h: + @cd $(LIBCBASE)/$(MACH); $(MAKE) pics/smt_pause.o include ../../Makefile.targ
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap1/sparcv9/Makefile Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/sun4v-hwcap1/sparcv9/Makefile Wed Aug 11 17:59:10 2010 -0400 @@ -27,8 +27,13 @@ include $(SRC)/lib/Makefile.lib.64 AS_CPPFLAGS += -D__sparcv9 -ASFLAGS += -xarch=v9 +ASFLAGS += -xarch=v9 -I$(LIBCBASE)/$(MACH64) + +all install: $(LIBCBASE)/$(MACH64)/assym.h $(SYMCAP) -all install: $(SYMCAP) +# We need assym.h, but it won't build directly. smt_pause.o depends on +# assym.h, so building it forces assym.h to be built. +$(LIBCBASE)/$(MACH64)/assym.h: + @cd $(LIBCBASE)/$(MACH64); $(MAKE) pics/smt_pause.o include ../../Makefile.targ
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap2/Makefile.com Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/sun4v-hwcap2/Makefile.com Wed Aug 11 17:59:10 2010 -0400 @@ -28,7 +28,7 @@ include ../../Makefile.com -OBJECTS = memcpy.o +OBJECTS = memcpy.o smt_pause.o include $(SRC)/lib/Makefile.lib
--- a/usr/src/lib/libc/capabilities/sun4v-hwcap2/common/mapfile-cap Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/capabilities/sun4v-hwcap2/common/mapfile-cap Wed Aug 11 17:59:10 2010 -0400 @@ -35,6 +35,7 @@ _memmove; memcpy; memmove; + smt_pause; local: *; };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/capabilities/sun4v/common/smt_pause.s Wed Aug 11 17:59:10 2010 -0400 @@ -0,0 +1,67 @@ +/* + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + + .file "smt_pause.s" + +/* + * void smt_pause(void) + * + * Do nothing efficiently. + * + */ + +#include <sys/asm_linkage.h> +#include <sys/niagaraasi.h> +#include <sys/asi.h> +#include <sys/stack.h> + +#if defined(NIAGARA_IMPL) +#include "assym.h" +#endif + + ENTRY(smt_pause) +#if defined(NIAGARA2_IMPL) || defined(VFALLS_IMPL) || defined(KT_IMPL) + rd %ccr, %g0 + rd %ccr, %g0 + retl + rd %ccr, %g0 +#else /* NIAGARA2_IMPL */ +#define BANKS (4 * 64) /* 4 cachelines, cover all banks */ + save %sp, -SA(MINFRAME+BANKS), %sp + + ld [%g7 + UL_LWPID], %i3 ! curthread->ul_lwpid + add %fp, STACK_BIAS-BANKS, %i0 + and %i3, 0x3, %i2 ! save last 2 bits + sllx %i2, 0x6, %i1 ! pick a slot + add %i1, %i0, %o0 + + casx [%o0], %g0, %g0 + casx [%o0], %g0, %g0 + casx [%o0], %g0, %g0 + ret + restore +#endif /* NIAGARA2_IMPL */ + SET_SIZE(smt_pause) +
--- a/usr/src/lib/libc/i386/threads/machdep.c Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/i386/threads/machdep.c Wed Aug 11 17:59:10 2010 -0400 @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #include "thr_uberdata.h" @@ -256,3 +255,9 @@ return (0); } + +void +smt_pause(void) +{ + SMT_PAUSE(); +}
--- a/usr/src/lib/libc/inc/thr_uberdata.h Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/inc/thr_uberdata.h Wed Aug 11 17:59:10 2010 -0400 @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _THR_UBERDATA_H @@ -255,7 +254,7 @@ extern void SMT_PAUSE_FUNCTION(void); #define SMT_PAUSE() SMT_PAUSE_FUNCTION() #else -#define SMT_PAUSE() +#define SMT_PAUSE() smt_pause() #endif /* __x86 */ /*
--- a/usr/src/lib/libc/port/mapfile-vers Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/port/mapfile-vers Wed Aug 11 17:59:10 2010 -0400 @@ -219,6 +219,7 @@ sigqueue; sigtimedwait; sigwaitinfo; + smt_pause; strnlen; strsep; symlinkat;
--- a/usr/src/lib/libc/sparc/Makefile.com Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/sparc/Makefile.com Wed Aug 11 17:59:10 2010 -0400 @@ -149,6 +149,7 @@ setjmp.o \ siginfolst.o \ siglongjmp.o \ + smt_pause.o \ sparc_data.o \ strcasecmp.o \ strchr.o \ @@ -1241,6 +1242,7 @@ _stack_grow.o \ asm_subr.o \ setjmp.o \ + smt_pause.o \ tls_get_addr.o \ unwind_frame.o \ vforkx.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/sparc/gen/smt_pause.s Wed Aug 11 17:59:10 2010 -0400 @@ -0,0 +1,60 @@ +/* + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + + .file "smt_pause.s" + +#include <sys/asm_linkage.h> +#include <../assym.h> +#include <sys/stack.h> + +/* + * void smt_pause(void) + * + * Do nothing efficiently. + * We do the dance with the lwpid so that the actual address is spread + * across cache banks thus avoiding hot spots. + * Casx arguments are a no-op, but they force access to L2 cache, which + * takes lots of cycles. + */ + +#ifdef lint +void +smt_pause(void) +{ +} +#else +#define BANKS (4 * 64) /* covers 4 cachelines, all banks */ + ENTRY(smt_pause) + save %sp, -SA(MINFRAME+BANKS), %sp + ld [%g7 + UL_LWPID], %i5 + add %fp, STACK_BIAS-BANKS, %i3 + and %i5, 0x3, %i4 ! save last 2 bits + sll %i4, 0x6, %i2 ! pick a slot + add %i2, %i3, %o0 + casx [%o0], %g0, %g0 + casx [%o0], %g0, %g0 + ret + restore + SET_SIZE(smt_pause) +#endif
--- a/usr/src/lib/libc/sparc/offsets.in Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/sparc/offsets.in Wed Aug 11 17:59:10 2010 -0400 @@ -48,6 +48,7 @@ ul_siglink ul_sigmask ul_unwind_ret + ul_lwpid sigjmp_struct_t sjs_sp
--- a/usr/src/lib/libc/sparcv9/Makefile.com Wed Aug 11 17:11:30 2010 -0500 +++ b/usr/src/lib/libc/sparcv9/Makefile.com Wed Aug 11 17:59:10 2010 -0400 @@ -144,6 +144,7 @@ setjmp.o \ siginfolst.o \ siglongjmp.o \ + smt_pause.o \ sparc_data.o \ strcasecmp.o \ strchr.o \ @@ -1167,6 +1168,7 @@ _stack_grow.o \ asm_subr.o \ setjmp.o \ + smt_pause.o \ tls_get_addr.o \ unwind_frame.o \ vforkx.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/lib/libc/sparcv9/gen/smt_pause.s Wed Aug 11 17:59:10 2010 -0400 @@ -0,0 +1,55 @@ +/* + * 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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + + .file "smt_pause.s" + +#include <sys/asm_linkage.h> +#include <../assym.h> + +/* + * void smt_pause(void) + * + * Do nothing efficiently. + */ + +#ifdef lint +void +smt_pause(void) +{ +} +#else +#define BANKS (4 * 64) + ENTRY(smt_pause) + save %sp, -SA(MINFRAME+BANKS), %sp + ld [%g7 + UL_LWPID], %i3 ! curthread->ul_lwpid + add %fp, STACK_BIAS-BANKS, %i0 + and %i3, 0x3, %i2 ! save last 2 bits + sllx %i2, 0x6, %i1 ! pick a slot + add %i1, %i0, %o0 + casx [%o0], %g0, %g0 + casx [%o0], %g0, %g0 + ret + restore + SET_SIZE(smt_pause) +#endif