Add x86_pause() inline function, containing the "pause" instruction

for i386, and nothing for amd64. Sprinkle it in various spinloops,
as recommended by Intel.
This commit is contained in:
fvdl 2003-05-08 01:04:34 +00:00
parent c2bd5e2fe9
commit 8aca0c88d2
5 changed files with 29 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpufunc.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/* $NetBSD: cpufunc.h,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -50,6 +50,8 @@
#ifdef _KERNEL
extern int cpu_feature;
static __inline void
invlpg(u_int64_t addr)
{
@ -263,6 +265,12 @@ breakpoint(void)
__asm __volatile("int $3");
}
static __inline void
x86_pause(void)
{
/* nothing */
}
#define read_psl() read_rflags()
#define write_psl(x) write_rflags(x)

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.151 2003/04/01 20:54:23 thorpej Exp $ */
/* $NetBSD: pmap.c,v 1.152 2003/05/08 01:04:36 fvdl Exp $ */
/*
*
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.151 2003/04/01 20:54:23 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.152 2003/05/08 01:04:36 fvdl Exp $");
#include "opt_cputype.h"
#include "opt_user_ldt.h"
@ -3318,7 +3318,7 @@ pmap_tlb_shootnow(int32_t cpumask)
panic("TLB IPI rendezvous failed (mask %x)",
self->ci_tlb_ipi_mask);
#else
/* XXX insert pause instruction */
x86_pause();
;
#endif
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpufunc.h,v 1.23 2003/03/04 22:43:09 fvdl Exp $ */
/* $NetBSD: cpufunc.h,v 1.24 2003/05/08 01:04:37 fvdl Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -50,6 +50,8 @@
#ifdef _KERNEL
extern int cpu_feature;
static __inline void
invlpg(u_int addr)
{
@ -264,6 +266,12 @@ breakpoint(void)
__asm __volatile("int $3");
}
static __inline void
x86_pause(void)
{
__asm __volatile("pause");
}
#define read_psl() read_eflags()
#define write_psl(x) write_eflags(x)

View File

@ -1,4 +1,4 @@
/* $NetBSD: lock.h,v 1.1 2003/02/27 00:10:57 fvdl Exp $ */
/* $NetBSD: lock.h,v 1.2 2003/05/08 01:04:34 fvdl Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -47,6 +47,8 @@
#include "opt_lockdebug.h"
#endif
#include <machine/cpufunc.h>
typedef __volatile int __cpu_simple_lock_t;
#define __SIMPLELOCK_LOCKED 1
@ -95,9 +97,8 @@ __cpu_simple_lock(__cpu_simple_lock_t *lockp)
{
while (x86_atomic_testset_i(lockp, __SIMPLELOCK_LOCKED)
== __SIMPLELOCK_LOCKED) {
continue; /* spin */
}
!= __SIMPLELOCK_UNLOCKED)
x86_pause();
__lockbarrier();
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lapic.c,v 1.1 2003/02/26 21:26:12 fvdl Exp $ */
/* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -411,6 +411,8 @@ void lapic_delay(usec)
else
deltat -= otick - tick;
otick = tick;
x86_pause();
}
}