diff options
author | mux <mux@FreeBSD.org> | 2004-08-03 18:44:27 +0000 |
---|---|---|
committer | mux <mux@FreeBSD.org> | 2004-08-03 18:44:27 +0000 |
commit | 35780dc21adda12f4e93177415556e6698e017e4 (patch) | |
tree | de3272d2386247caa65d7fbb3bf4c7418c6ebc1b /sys/kern/kern_mutex.c | |
parent | 81234cca4a890862a2410bb1de1a553a60c285a6 (diff) | |
download | FreeBSD-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/kern/kern_mutex.c')
-rw-r--r-- | sys/kern/kern_mutex.c | 20 |
1 files changed, 5 insertions, 15 deletions
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(); } |