summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormux <mux@FreeBSD.org>2004-08-03 18:44:27 +0000
committermux <mux@FreeBSD.org>2004-08-03 18:44:27 +0000
commit35780dc21adda12f4e93177415556e6698e017e4 (patch)
treede3272d2386247caa65d7fbb3bf4c7418c6ebc1b /sys
parent81234cca4a890862a2410bb1de1a553a60c285a6 (diff)
downloadFreeBSD-src-35780dc21adda12f4e93177415556e6698e017e4.zip
FreeBSD-src-35780dc21adda12f4e93177415556e6698e017e4.tar.gz
Instead of calling ia32_pause() conditionally on __i386__ or __amd64__
being defined, define and use a new MD macro, cpu_spinwait(). It only expands to something on i386 and amd64, so the compiled code should be identical. Name of the macro found by: jhb Reviewed by: jhb
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/include/cpu.h1
-rw-r--r--sys/amd64/include/cpu.h5
-rw-r--r--sys/arm/include/cpu.h1
-rw-r--r--sys/i386/include/cpu.h5
-rw-r--r--sys/ia64/include/cpu.h1
-rw-r--r--sys/kern/kern_mutex.c20
-rw-r--r--sys/powerpc/include/cpu.h1
-rw-r--r--sys/sparc64/include/cpu.h1
8 files changed, 16 insertions, 19 deletions
diff --git a/sys/alpha/include/cpu.h b/sys/alpha/include/cpu.h
index 9db2b9a..64dc773b2 100644
--- a/sys/alpha/include/cpu.h
+++ b/sys/alpha/include/cpu.h
@@ -93,6 +93,7 @@ struct clockframe {
#ifdef _KERNEL
#define cpu_getstack(td) (alpha_pal_rdusp())
+#define cpu_spinwait() /* nothing */
#define get_cyclecount alpha_rpcc
void cpu_halt(void);
diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h
index f8a2ee3..f069d2e 100644
--- a/sys/amd64/include/cpu.h
+++ b/sys/amd64/include/cpu.h
@@ -50,9 +50,10 @@
#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */
#define cpu_exec(p) /* nothing */
-#define cpu_swapin(p) /* nothing */
+#define cpu_swapin(p) /* nothing */
#define cpu_getstack(td) ((td)->td_frame->tf_rsp)
-#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap))
+#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap))
+#define cpu_spinwait() ia32_pause()
#define TRAPF_USERMODE(framep) \
(ISPL((framep)->tf_cs) == SEL_UPL)
diff --git a/sys/arm/include/cpu.h b/sys/arm/include/cpu.h
index 2130618..417a2fe 100644
--- a/sys/arm/include/cpu.h
+++ b/sys/arm/include/cpu.h
@@ -32,6 +32,7 @@ get_cyclecount(void)
#define cpu_getstack(td) ((td)->td_frame->tf_usr_sp)
#define cpu_setstack(td, sp) ((td)->td_frame->tf_usr_sp = (sp))
+#define cpu_spinwait() /* nothing */
#define ARM_NVEC 8
#define ARM_VEC_ALL 0xffffffff
diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h
index ad5665b..fb1017f 100644
--- a/sys/i386/include/cpu.h
+++ b/sys/i386/include/cpu.h
@@ -50,9 +50,10 @@
#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */
#define cpu_exec(p) /* nothing */
-#define cpu_swapin(p) /* nothing */
+#define cpu_swapin(p) /* nothing */
#define cpu_getstack(td) ((td)->td_frame->tf_esp)
-#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap))
+#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap))
+#define cpu_spinwait() ia32_pause()
#define TRAPF_USERMODE(framep) \
((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM))
diff --git a/sys/ia64/include/cpu.h b/sys/ia64/include/cpu.h
index f6f6b5c..c7a4603 100644
--- a/sys/ia64/include/cpu.h
+++ b/sys/ia64/include/cpu.h
@@ -86,6 +86,7 @@ struct clockframe {
/* Used by signaling code. */
#define cpu_getstack(td) ((td)->td_frame->tf_special.sp)
+#define cpu_spinwait() /* nothing */
void cpu_halt(void);
void cpu_reset(void);
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 507df8a..7b66186 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -465,9 +465,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
*/
if (v == MTX_UNOWNED) {
turnstile_release(&m->mtx_object);
-#if defined(__i386__) || defined(__amd64__)
- ia32_pause();
-#endif
+ cpu_spinwait();
continue;
}
@@ -497,9 +495,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
!atomic_cmpset_ptr(&m->mtx_lock, (void *)v,
(void *)(v | MTX_CONTESTED))) {
turnstile_release(&m->mtx_object);
-#if defined(__i386__) || defined(__amd64__)
- ia32_pause();
-#endif
+ cpu_spinwait();
continue;
}
@@ -516,9 +512,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
#endif
turnstile_release(&m->mtx_object);
while (mtx_owner(m) == owner && TD_IS_RUNNING(owner)) {
-#if defined(__i386__) || defined(__amd64__)
- ia32_pause();
-#endif
+ cpu_spinwait();
}
continue;
}
@@ -583,9 +577,7 @@ _mtx_lock_spin(struct mtx *m, int opts, const char *file, int line)
critical_exit();
while (m->mtx_lock != MTX_UNOWNED) {
if (i++ < 10000000) {
-#if defined(__i386__) || defined(__amd64__)
- ia32_pause();
-#endif
+ cpu_spinwait();
continue;
}
if (i < 60000000)
@@ -599,9 +591,7 @@ _mtx_lock_spin(struct mtx *m, int opts, const char *file, int line)
#endif
panic("spin lock held too long");
}
-#if defined(__i386__) || defined(__amd64__)
- ia32_pause();
-#endif
+ cpu_spinwait();
}
critical_enter();
}
diff --git a/sys/powerpc/include/cpu.h b/sys/powerpc/include/cpu.h
index 4e4119c..abe7ef4 100644
--- a/sys/powerpc/include/cpu.h
+++ b/sys/powerpc/include/cpu.h
@@ -89,6 +89,7 @@ get_cyclecount(void)
}
#define cpu_getstack(td) ((td)->td_frame->fixreg[1])
+#define cpu_spinwait() /* nothing */
void cpu_halt(void);
void cpu_reset(void);
diff --git a/sys/sparc64/include/cpu.h b/sys/sparc64/include/cpu.h
index b00280d..4dfe1e9 100644
--- a/sys/sparc64/include/cpu.h
+++ b/sys/sparc64/include/cpu.h
@@ -48,6 +48,7 @@
#define cpu_getstack(td) ((td)->td_frame->tf_sp)
#define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp))
+#define cpu_spinwait() /* nothing */
/*
* CTL_MACHDEP definitions.
OpenPOWER on IntegriCloud