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
This commit is contained in:
Maxime Henrion 2004-08-03 18:44:27 +00:00
parent 33282bf4aa
commit 9f1b87f106
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133084
8 changed files with 16 additions and 19 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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))

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -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.