diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-03-13 18:42:17 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-03-13 18:42:17 +0000 |
commit | 3e5b5bc3ed49a190d3e1a0c4d6f34eb2d06f1a6d (patch) | |
tree | 9a434d8dd5b63cf8a75fce95e7e3411a7d86d27d /sys | |
parent | ae3b292153b1def841f9d662e5aa039ae42aa3c3 (diff) |
time-bind and lower power in lock spinning and a couple of other ipi loops by using pause insn; brad@ ok tedu@ ok and feedback krw@ testing
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/i386/lapic.c | 15 | ||||
-rw-r--r-- | sys/arch/i386/i386/pmap.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/include/lock.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/isa/npx.c | 19 |
4 files changed, 25 insertions, 27 deletions
diff --git a/sys/arch/i386/i386/lapic.c b/sys/arch/i386/i386/lapic.c index 4053df12805..77bb270c8b6 100644 --- a/sys/arch/i386/i386/lapic.c +++ b/sys/arch/i386/i386/lapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lapic.c,v 1.6 2006/03/10 21:09:22 mickey Exp $ */ +/* $OpenBSD: lapic.c,v 1.7 2006/03/13 18:42:16 mickey Exp $ */ /* $NetBSD: lapic.c,v 1.1.2.8 2000/02/23 06:10:50 sommerfeld Exp $ */ /*- @@ -441,25 +441,28 @@ i386_ipi_init(target) { unsigned j; - if ((target & LAPIC_DEST_MASK) == 0) { + if ((target & LAPIC_DEST_MASK) == 0) i82489_writereg(LAPIC_ICRHI, target << LAPIC_ID_SHIFT); - } i82489_writereg(LAPIC_ICRLO, (target & LAPIC_DEST_MASK) | LAPIC_DLMODE_INIT | LAPIC_LVL_ASSERT ); - for (j = 100000; j > 0; j--) + for (j = 100000; j > 0; j--) { + __asm __volatile("pause": : :"memory"); if ((i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY) == 0) break; + } delay(10000); i82489_writereg(LAPIC_ICRLO, (target & LAPIC_DEST_MASK) | LAPIC_DLMODE_INIT | LAPIC_LVL_TRIG | LAPIC_LVL_DEASSERT); - for (j = 100000; j > 0; j--) + for (j = 100000; j > 0; j--) { + __asm __volatile("pause": : :"memory"); if ((i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY) == 0) break; + } return (i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY)?EBUSY:0; } @@ -479,7 +482,7 @@ i386_ipi(vec,target,dl) for (j = 100000; j > 0 && (i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY); j--) - ; + SPINLOCK_SPIN_HOOK; return (i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY) ? EBUSY : 0; } diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 425926da4d5..765b2b9d233 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.90 2006/03/12 21:28:54 tom Exp $ */ +/* $OpenBSD: pmap.c,v 1.91 2006/03/13 18:42:16 mickey Exp $ */ /* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */ /* @@ -3595,15 +3595,14 @@ pmap_tlb_shootnow(int32_t cpumask) (1U << ci->ci_cpuid)); } - while (self->ci_tlb_ipi_mask != 0) + while (self->ci_tlb_ipi_mask != 0) { + SPINLOCK_SPIN_HOOK; #ifdef DIAGNOSTIC if (count++ > 100000000) panic("%s: TLB IPI rendezvous failed (mask 0x%x)", self->ci_dev.dv_xname, self->ci_tlb_ipi_mask); -#else - /* XXX insert pause instruction */ - ; #endif + } #endif } diff --git a/sys/arch/i386/include/lock.h b/sys/arch/i386/include/lock.h index a647999a532..fe0578a3139 100644 --- a/sys/arch/i386/include/lock.h +++ b/sys/arch/i386/include/lock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lock.h,v 1.2 2004/06/13 21:49:16 niklas Exp $ */ +/* $OpenBSD: lock.h,v 1.3 2006/03/13 18:42:16 mickey Exp $ */ /* $NetBSD: lock.h,v 1.1.2.2 2000/05/03 14:40:55 sommerfeld Exp $ */ /*- @@ -59,6 +59,8 @@ typedef __volatile int __cpu_simple_lock_t; #define __lockbarrier() __asm __volatile("": : :"memory") +#define SPINLOCK_SPIN_HOOK __asm __volatile("pause": : :"memory") + #ifdef LOCKDEBUG extern void __cpu_simple_lock_init(__cpu_simple_lock_t *); @@ -90,9 +92,8 @@ static __inline void __cpu_simple_lock(__cpu_simple_lock_t *lockp) { while (i386_atomic_testset_i(lockp, __SIMPLELOCK_LOCKED) - == __SIMPLELOCK_LOCKED) { - continue; /* spin */ - } + == __SIMPLELOCK_LOCKED) + SPINLOCK_SPIN_HOOK; __lockbarrier(); } diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c index 9b26e2ba4af..3fd0102dcbf 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npx.c,v 1.37 2005/06/06 14:25:20 mickey Exp $ */ +/* $OpenBSD: npx.c,v 1.38 2006/03/13 18:42:16 mickey Exp $ */ /* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */ #if 0 @@ -823,22 +823,17 @@ npxsave_proc(struct proc *p, int save) #ifdef DIAGNOSTIC spincount = 0; #endif - while (p->p_addr->u_pcb.pcb_fpcpu != NULL) + while (p->p_addr->u_pcb.pcb_fpcpu != NULL) { + SPINLOCK_SPIN_HOOK; #ifdef DIAGNOSTIC - { - spincount++; - if (spincount > 100000000) { - panic("fp_save ipi didn't"); - } - } -#else - __splbarrier(); /* XXX replace by generic barrier */ - ; + if (spincount++ > 100000000) + panic("%s: fp_save ipi didn't (%s)", + ci->ci_dev.dv_xname, oci->ci_dev.dv_xname); #endif + } } #else KASSERT(ci->ci_fpcurproc == p); npxsave_cpu(ci, save); #endif } - |