-/* $OpenBSD: lock_machdep.c,v 1.5 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.6 2017/05/29 14:19:49 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
#include <machine/atomic.h>
#include <machine/cpu.h>
-#include <machine/lock.h>
#if defined(MP_LOCKDEBUG)
#ifndef DDB
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_count != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
if (!CPU_IS_PRIMARY(curcpu()))
nticks += nticks;
while (mpl->mpl_count != 0 && --nticks > 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (nticks == 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);
-/* $OpenBSD: machdep.c,v 1.180 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.181 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */
/*-
#ifndef NO_IEEE
#include <machine/ieeefp.h>
#endif
-#ifdef MULTIPROCESSOR
-#include <machine/lock.h>
-#endif
#include <dev/pci/pcivar.h>
alpha_pal_swpipl(s);
while (p->p_addr->u_pcb.pcb_fpcpu != NULL)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
KASSERT(ci->ci_fpcurproc == p);
fpusave_cpu(ci, save);
-/* $OpenBSD: mutex.c,v 1.17 2017/04/20 13:57:29 visa Exp $ */
+/* $OpenBSD: mutex.c,v 1.18 2017/05/29 14:19:49 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
#include <sys/atomic.h>
#include <machine/intr.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <ddb/db_output.h>
__mtx_enter(struct mutex *mtx)
{
while (__mtx_enter_try(mtx) == 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
int
-/* $OpenBSD: cpu.h,v 1.57 2016/03/30 15:39:46 afresh1 Exp $ */
+/* $OpenBSD: cpu.h,v 1.58 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
void cpu_pause_resume_all(int);
void cpu_unidle(struct cpu_info *);
+/*
+ * On the Alpha, interprocessor interrupts come in at device priority
+ * level. This can cause some problems while waiting for r/w spinlocks
+ * from a high'ish priority level: IPIs that come in will not be processed.
+ * This can lead to deadlock.
+ *
+ * This hook allows IPIs to be processed while a spinlock's interlock
+ * is released.
+ */
+#define CPU_BUSY_CYCLE() \
+do { \
+ struct cpu_info *__ci = curcpu(); \
+ int __s; \
+ \
+ if (__ci->ci_ipis != 0) { \
+ __s = splipi(); \
+ alpha_ipi_process_with_frame(__ci); \
+ splx(__s); \
+ } \
+} while (0)
+
#else /* ! MULTIPROCESSOR */
#define curcpu() (&cpu_info_primary)
#define CPU_IS_PRIMARY(ci) 1
#define cpu_unidle(ci) do { /* nothing */ } while (0)
+#define CPU_BUSY_CYCLE() do {} while (0)
#endif /* MULTIPROCESSOR */
-#define CPU_BUSY_CYCLE() do {} while (0)
#define curproc curcpu()->ci_curproc
#define fpcurproc curcpu()->ci_fpcurproc
-/* $OpenBSD: lock.h,v 1.9 2015/02/11 03:56:00 dlg Exp $ */
+/* $OpenBSD: lock.h,v 1.10 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: lock.h,v 1.16 2001/12/17 23:34:57 thorpej Exp $ */
/*-
#ifndef _MACHINE_LOCK_H_
#define _MACHINE_LOCK_H_
-#if defined(MULTIPROCESSOR)
-/*
- * On the Alpha, interprocessor interrupts come in at device priority
- * level. This can cause some problems while waiting for r/w spinlocks
- * from a high'ish priority level: IPIs that come in will not be processed.
- * This can lead to deadlock.
- *
- * This hook allows IPIs to be processed while a spinlock's interlock
- * is released.
- */
-#define SPINLOCK_SPIN_HOOK \
-do { \
- struct cpu_info *__ci = curcpu(); \
- int __s; \
- \
- if (__ci->ci_ipis != 0) { \
- __s = splipi(); \
- alpha_ipi_process_with_frame(__ci); \
- splx(__s); \
- } \
-} while (0)
-#endif /* MULTIPROCESSOR */
-
#endif /* _MACHINE_LOCK_H_ */
-/* $OpenBSD: fpu.c,v 1.34 2017/04/27 06:16:39 mlarkin Exp $ */
+/* $OpenBSD: fpu.c,v 1.35 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
#include <machine/trap.h>
#include <machine/specialreg.h>
#include <machine/fpu.h>
-#include <machine/lock.h>
#include <dev/isa/isavar.h>
x86_send_ipi(oci,
save ? X86_IPI_SYNCH_FPU : X86_IPI_FLUSH_FPU);
while (p->p_addr->u_pcb.pcb_fpcpu != NULL)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
#else
KASSERT(ci->ci_fpcurproc == p);
-/* $OpenBSD: lapic.c,v 1.46 2017/05/25 03:54:10 visa Exp $ */
+/* $OpenBSD: lapic.c,v 1.47 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */
/*-
#include <machine/codepatch.h>
#include <machine/cpu.h>
#include <machine/cpufunc.h>
-#include <machine/lock.h>
#include <machine/pmap.h>
#include <machine/vmparam.h>
#include <machine/mpbiosvar.h>
deltat -= otick - tick;
otick = tick;
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
}
-/* $OpenBSD: lock_machdep.c,v 1.15 2017/05/28 08:47:19 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.16 2017/05/29 14:19:49 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
#include <sys/witness.h>
#include <sys/_lock.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <ddb/db_output.h>
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_ticket != me)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_ticket != me) {
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (--nticks <= 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);
-/* $OpenBSD: pmap.c,v 1.103 2017/01/02 07:41:18 tedu Exp $ */
+/* $OpenBSD: pmap.c,v 1.104 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */
/*
#include <uvm/uvm.h>
-#include <machine/lock.h>
#include <machine/cpu.h>
#include <machine/specialreg.h>
#ifdef MULTIPROCESSOR
while (atomic_cas_ulong(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
tlb_shoot_addr1 = va;
CPU_INFO_FOREACH(cii, ci) {
while (atomic_cas_ulong(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
tlb_shoot_addr1 = sva;
tlb_shoot_addr2 = eva;
while (atomic_cas_ulong(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
CPU_INFO_FOREACH(cii, ci) {
pmap_tlb_shootwait(void)
{
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
#else
-/* $OpenBSD: lock.h,v 1.12 2017/05/25 03:50:10 visa Exp $ */
+/* $OpenBSD: lock.h,v 1.13 2017/05/29 14:19:49 mpi Exp $ */
/* public domain */
#ifndef _MACHINE_LOCK_H_
#define _MACHINE_LOCK_H_
-#define SPINLOCK_SPIN_HOOK __asm volatile("pause": : :"memory")
-
#endif /* _MACHINE_LOCK_H_ */
-/* $OpenBSD: lock_machdep.c,v 1.10 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.11 2017/05/29 14:19:49 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
#include <machine/atomic.h>
#include <machine/intr.h>
#include <machine/psl.h>
+#include <machine/cpu.h>
#include <ddb/db_output.h>
extern int __mp_lock_spinout;
#endif
-#define SPINLOCK_SPIN_HOOK /**/
-
static __inline void
__mp_lock_spin(struct __mp_lock *mpl)
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_count != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_count != 0 && --nticks > 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (nticks == 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);
-/* $OpenBSD: lock_machdep.c,v 1.24 2017/05/28 08:47:19 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.25 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: lock_machdep.c,v 1.1.2.3 2000/05/03 14:40:30 sommerfeld Exp $ */
/*-
#include <sys/witness.h>
#include <sys/_lock.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <ddb/db_output.h>
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_ticket != me)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_ticket != me) {
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (--nticks <= 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);
-/* $OpenBSD: pmap.c,v 1.195 2016/10/21 06:20:58 mlarkin Exp $ */
+/* $OpenBSD: pmap.c,v 1.196 2017/05/29 14:19:49 mpi Exp $ */
/* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */
/*
#include <uvm/uvm.h>
-#include <machine/lock.h>
#include <machine/cpu.h>
#include <machine/specialreg.h>
#include <machine/gdt.h>
while (atomic_cas_uint(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
tlb_shoot_addr1 = va;
CPU_INFO_FOREACH(cii, ci) {
while (atomic_cas_uint(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
tlb_shoot_addr1 = sva;
tlb_shoot_addr2 = eva;
while (atomic_cas_uint(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
CPU_INFO_FOREACH(cii, ci) {
while (atomic_cas_uint(&tlb_shoot_wait, 0, wait) != 0) {
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
CPU_INFO_FOREACH(cii, ci) {
pmap_tlb_shootwait(void)
{
while (tlb_shoot_wait != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
#else
-/* $OpenBSD: lock.h,v 1.12 2016/04/03 11:05:26 jsg Exp $ */
+/* $OpenBSD: lock.h,v 1.13 2017/05/29 14:19:49 mpi Exp $ */
/* public domain */
#ifndef _MACHINE_LOCK_H_
#define _MACHINE_LOCK_H_
-#define SPINLOCK_SPIN_HOOK __asm volatile("pause": : :"memory")
-
#endif /* _MACHINE_LOCK_H_ */
-/* $OpenBSD: npx.c,v 1.61 2015/02/11 05:54:48 dlg Exp $ */
+/* $OpenBSD: npx.c,v 1.62 2017/05/29 14:19:50 mpi Exp $ */
/* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */
#if 0
#include <machine/trap.h>
#include <machine/specialreg.h>
#include <machine/i8259.h>
-#include <machine/lock.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
i386_send_ipi(oci,
save ? I386_IPI_SYNCH_FPU : I386_IPI_FLUSH_FPU);
while (p->p_addr->u_pcb.pcb_fpcpu != NULL)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
}
#else
KASSERT(ci->ci_fpcurproc == p);
-/* $OpenBSD: machdep.c,v 1.124 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.125 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
#include <machine/cmmu.h>
#include <machine/cpu.h>
#include <machine/kcore.h>
-#include <machine/lock.h>
#include <machine/reg.h>
#include <machine/trap.h>
#include <machine/m88100.h>
-/* $OpenBSD: m8820x_machdep.c,v 1.61 2013/11/16 18:45:20 miod Exp $ */
+/* $OpenBSD: m8820x_machdep.c,v 1.62 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2004, 2007, 2010, 2011, 2013, Miodrag Vallat.
*
#include <machine/asm_macro.h>
#include <machine/cmmu.h>
#include <machine/cpu.h>
-#include <machine/lock.h>
#include <machine/m8820x.h>
#include <machine/psl.h>
-/* $OpenBSD: m88k_machdep.c,v 1.67 2017/03/19 10:57:29 miod Exp $ */
+/* $OpenBSD: m88k_machdep.c,v 1.68 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
#include <machine/asm.h>
#include <machine/asm_macro.h>
#include <machine/atomic.h>
-#include <machine/lock.h>
#include <machine/cmmu.h>
#include <machine/cpu.h>
#include <machine/reg.h>
-/* $OpenBSD: mplock.c,v 1.5 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: mplock.c,v 1.6 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
#include <sys/systm.h>
#include <machine/asm_macro.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <ddb/db_output.h>
extern int __mp_lock_spinout;
#endif
-#define SPINLOCK_SPIN_HOOK do { /* nothing */ } while (0)
-
static __inline void
__mp_lock_spin(struct __mp_lock *mpl)
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_count != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_count != 0 && nticks-- > 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (nticks == 0) {
db_printf("__mp_lock(0x%x): lock spun out", mpl);
-/* $OpenBSD: lock_machdep.c,v 1.4 2017/05/19 00:52:49 visa Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.5 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
#include <sys/atomic.h>
#include <machine/cpu.h>
-#include <machine/lock.h>
#include <ddb/db_output.h>
extern int __mp_lock_spinout;
#endif
-#define SPINLOCK_SPIN_HOOK /**/
-
static __inline void
__mp_lock_spin(struct __mp_lock *mpl)
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_count != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_count != 0 && --nticks > 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (nticks == 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);
-/* $OpenBSD: lock.h,v 1.7 2015/08/14 06:14:19 dlg Exp $ */
+/* $OpenBSD: lock.h,v 1.8 2017/05/29 14:19:50 mpi Exp $ */
/* $NetBSD: lock.h,v 1.8 2005/12/28 19:09:29 perry Exp $ */
/*-
#ifndef _POWERPC_LOCK_H_
#define _POWERPC_LOCK_H_
-#define SPINLOCK_SPIN_HOOK do { } while (0)
-
#endif /* _POWERPC_LOCK_H_ */
-/* $OpenBSD: lock_machdep.c,v 1.5 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.6 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
#include <sys/systm.h>
#include <sys/atomic.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <machine/psl.h>
#include <ddb/db_output.h>
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_count != 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_count != 0 && --nticks > 0)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (nticks == 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);
-/* $OpenBSD: mutex.c,v 1.5 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: mutex.c,v 1.6 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
#include <sys/atomic.h>
#include <machine/intr.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <ddb/db_output.h>
#endif
while (__mtx_enter_try(mtx) == 0) {
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#if defined(MP_LOCKDEBUG)
if (--nticks == 0) {
-/* $OpenBSD: cpu.h,v 1.90 2017/04/20 10:03:40 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.91 2017/05/29 14:19:50 mpi Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
#define curpcb __curcpu->ci_cpcb
#define fpproc __curcpu->ci_fpproc
-#define CPU_BUSY_CYCLE() do {} while (0)
+/*
+ * On processors with multiple threads we force a thread switch.
+ *
+ * On UltraSPARC T2 and its successors, the optimal way to do this
+ * seems to be to do three nop reads of %ccr. This works on
+ * UltraSPARC T1 as well, even though three nop casx operations seem
+ * to be slightly more optimal. Since these instructions are
+ * effectively nops, executing them on earlier non-CMT processors is
+ * harmless, so we make this the default.
+ *
+ * On SPARC T4 and later, we can use the processor-specific pause
+ * instruction.
+ *
+ * On SPARC64 VI and its successors we execute the processor-specific
+ * sleep instruction.
+ */
+#define CPU_BUSY_CYCLE() \
+do { \
+ __asm volatile( \
+ "999: rd %%ccr, %%g0 \n" \
+ " rd %%ccr, %%g0 \n" \
+ " rd %%ccr, %%g0 \n" \
+ " .section .sun4v_pause_patch, \"ax\" \n" \
+ " .word 999b \n" \
+ " .word 0xb7802080 ! pause 128 \n" \
+ " .word 999b + 4 \n" \
+ " nop \n" \
+ " .word 999b + 8 \n" \
+ " nop \n" \
+ " .previous \n" \
+ " .section .sun4u_mtp_patch, \"ax\" \n" \
+ " .word 999b \n" \
+ " .word 0x81b01060 ! sleep \n" \
+ " .word 999b + 4 \n" \
+ " nop \n" \
+ " .word 999b + 8 \n" \
+ " nop \n" \
+ " .previous \n" \
+ : : : "memory"); \
+} while (0)
/*
* Arguments to hardclock, softclock and gatherstats encapsulate the
-/* $OpenBSD: lock.h,v 1.11 2017/05/27 15:11:03 mpi Exp $ */
+/* $OpenBSD: lock.h,v 1.12 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org>
*
#ifndef _MACHINE_LOCK_H_
#define _MACHINE_LOCK_H_
-#ifdef _KERNEL
-
-/*
- * On processors with multiple threads we force a thread switch.
- *
- * On UltraSPARC T2 and its successors, the optimal way to do this
- * seems to be to do three nop reads of %ccr. This works on
- * UltraSPARC T1 as well, even though three nop casx operations seem
- * to be slightly more optimal. Since these instructions are
- * effectively nops, executing them on earlier non-CMT processors is
- * harmless, so we make this the default.
- *
- * On SPARC T4 and later, we can use the processor-specific pause
- * instruction.
- *
- * On SPARC64 VI and its successors we execute the processor-specific
- * sleep instruction.
- */
-#define SPINLOCK_SPIN_HOOK \
-do { \
- __asm volatile( \
- "999: rd %%ccr, %%g0 \n" \
- " rd %%ccr, %%g0 \n" \
- " rd %%ccr, %%g0 \n" \
- " .section .sun4v_pause_patch, \"ax\" \n" \
- " .word 999b \n" \
- " .word 0xb7802080 ! pause 128 \n" \
- " .word 999b + 4 \n" \
- " nop \n" \
- " .word 999b + 8 \n" \
- " nop \n" \
- " .previous \n" \
- " .section .sun4u_mtp_patch, \"ax\" \n" \
- " .word 999b \n" \
- " .word 0x81b01060 ! sleep \n" \
- " .word 999b + 4 \n" \
- " nop \n" \
- " .word 999b + 8 \n" \
- " nop \n" \
- " .previous \n" \
- : : : "memory"); \
-} while (0)
-
-
-#endif /* _KERNEL */
#endif /* _MACHINE_LOCK_H_ */
-/* $OpenBSD: lock_machdep.c,v 1.16 2017/05/27 15:11:03 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.17 2017/05/29 14:19:50 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
#include <sys/param.h>
#include <sys/systm.h>
-#include <machine/lock.h>
+#include <machine/cpu.h>
#include <machine/psl.h>
#include <ddb/db_output.h>
{
#ifndef MP_LOCKDEBUG
while (mpl->mpl_ticket != me)
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
#else
int nticks = __mp_lock_spinout;
while (mpl->mpl_ticket != me) {
- SPINLOCK_SPIN_HOOK;
+ CPU_BUSY_CYCLE();
if (--nticks <= 0) {
db_printf("__mp_lock(%p): lock spun out", mpl);