1*e2c5185aSChristopher Kiick/* 2*e2c5185aSChristopher Kiick * CDDL HEADER START 3*e2c5185aSChristopher Kiick * 4*e2c5185aSChristopher Kiick * The contents of this file are subject to the terms of the 5*e2c5185aSChristopher Kiick * Common Development and Distribution License (the "License"). 6*e2c5185aSChristopher Kiick * You may not use this file except in compliance with the License. 7*e2c5185aSChristopher Kiick * 8*e2c5185aSChristopher Kiick * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*e2c5185aSChristopher Kiick * or http://www.opensolaris.org/os/licensing. 10*e2c5185aSChristopher Kiick * See the License for the specific language governing permissions 11*e2c5185aSChristopher Kiick * and limitations under the License. 12*e2c5185aSChristopher Kiick * 13*e2c5185aSChristopher Kiick * When distributing Covered Code, include this CDDL HEADER in each 14*e2c5185aSChristopher Kiick * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*e2c5185aSChristopher Kiick * If applicable, add the following below this CDDL HEADER, with the 16*e2c5185aSChristopher Kiick * fields enclosed by brackets "[]" replaced with your own identifying 17*e2c5185aSChristopher Kiick * information: Portions Copyright [yyyy] [name of copyright owner] 18*e2c5185aSChristopher Kiick * 19*e2c5185aSChristopher Kiick * CDDL HEADER END 20*e2c5185aSChristopher Kiick */ 21*e2c5185aSChristopher Kiick/* 22*e2c5185aSChristopher Kiick * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 23*e2c5185aSChristopher Kiick */ 24*e2c5185aSChristopher Kiick 25*e2c5185aSChristopher Kiick .file "smt_pause.s" 26*e2c5185aSChristopher Kiick 27*e2c5185aSChristopher Kiick#include <sys/asm_linkage.h> 28*e2c5185aSChristopher Kiick#include <../assym.h> 29*e2c5185aSChristopher Kiick#include <sys/stack.h> 30*e2c5185aSChristopher Kiick 31*e2c5185aSChristopher Kiick/* 32*e2c5185aSChristopher Kiick * void smt_pause(void) 33*e2c5185aSChristopher Kiick * 34*e2c5185aSChristopher Kiick * Do nothing efficiently. 35*e2c5185aSChristopher Kiick * We do the dance with the lwpid so that the actual address is spread 36*e2c5185aSChristopher Kiick * across cache banks thus avoiding hot spots. 37*e2c5185aSChristopher Kiick * Casx arguments are a no-op, but they force access to L2 cache, which 38*e2c5185aSChristopher Kiick * takes lots of cycles. 39*e2c5185aSChristopher Kiick */ 40*e2c5185aSChristopher Kiick 41*e2c5185aSChristopher Kiick#ifdef lint 42*e2c5185aSChristopher Kiickvoid 43*e2c5185aSChristopher Kiicksmt_pause(void) 44*e2c5185aSChristopher Kiick{ 45*e2c5185aSChristopher Kiick} 46*e2c5185aSChristopher Kiick#else 47*e2c5185aSChristopher Kiick#define BANKS (4 * 64) /* covers 4 cachelines, all banks */ 48*e2c5185aSChristopher Kiick ENTRY(smt_pause) 49*e2c5185aSChristopher Kiick save %sp, -SA(MINFRAME+BANKS), %sp 50*e2c5185aSChristopher Kiick ld [%g7 + UL_LWPID], %i5 51*e2c5185aSChristopher Kiick add %fp, STACK_BIAS-BANKS, %i3 52*e2c5185aSChristopher Kiick and %i5, 0x3, %i4 ! save last 2 bits 53*e2c5185aSChristopher Kiick sll %i4, 0x6, %i2 ! pick a slot 54*e2c5185aSChristopher Kiick add %i2, %i3, %o0 55*e2c5185aSChristopher Kiick casx [%o0], %g0, %g0 56*e2c5185aSChristopher Kiick casx [%o0], %g0, %g0 57*e2c5185aSChristopher Kiick ret 58*e2c5185aSChristopher Kiick restore 59*e2c5185aSChristopher Kiick SET_SIZE(smt_pause) 60*e2c5185aSChristopher Kiick#endif 61