Add a KPI for the delay while spinning on a spin lock.

Replace a call to DELAY(1) with a new cpu_lock_delay() KPI.  Currently
cpu_lock_delay() is defined to DELAY(1) on all platforms.  However,
platforms with a DELAY() implementation that uses spin locks should
implement a custom cpu_lock_delay() doesn't use locks.

Reviewed by:	kib
MFC after:	3 days
This commit is contained in:
John Baldwin 2018-11-05 21:34:17 +00:00
parent b25c717954
commit 4cbbb74888
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340164
9 changed files with 9 additions and 1 deletions

View File

@ -50,6 +50,7 @@
#define cpu_getstack(td) ((td)->td_frame->tf_rsp)
#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap))
#define cpu_spinwait() ia32_pause()
#define cpu_lock_delay() DELAY(1)
#define TRAPF_USERMODE(framep) \
(ISPL((framep)->tf_cs) == SEL_UPL)

View File

@ -61,6 +61,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 cpu_lock_delay() DELAY(1)
#define ARM_NVEC 8
#define ARM_VEC_ALL 0xffffffff

View File

@ -51,6 +51,7 @@
#define cpu_getstack(td) ((td)->td_frame->tf_sp)
#define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp))
#define cpu_spinwait() __asm __volatile("yield" ::: "memory")
#define cpu_lock_delay() DELAY(1)
/* Extract CPU affinity levels 0-3 */
#define CPU_AFF0(mpidr) (u_int)(((mpidr) >> 0) & 0xff)

View File

@ -50,6 +50,7 @@
#define cpu_getstack(td) ((td)->td_frame->tf_esp)
#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap))
#define cpu_spinwait() ia32_pause()
#define cpu_lock_delay() DELAY(1)
#define TRAPF_USERMODE(framep) \
((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM))

View File

@ -1206,7 +1206,7 @@ _mtx_lock_indefinite_check(struct mtx *m, struct lock_delay_arg *ldap)
ldap->spin_cnt++;
if (ldap->spin_cnt < 60000000 || kdb_active || panicstr != NULL)
DELAY(1);
cpu_lock_delay();
else {
td = mtx_owner(m);

View File

@ -71,6 +71,7 @@
#define cpu_getstack(td) ((td)->td_frame->sp)
#define cpu_setstack(td, nsp) ((td)->td_frame->sp = (nsp))
#define cpu_spinwait() /* nothing */
#define cpu_lock_delay() DELAY(1)
/*
* A machine-independent interface to the CPU's counter.

View File

@ -128,6 +128,7 @@ get_cyclecount(void)
#define cpu_getstack(td) ((td)->td_frame->fixreg[1])
#define cpu_spinwait() __asm __volatile("or 27,27,27") /* yield */
#define cpu_lock_delay() DELAY(1)
extern char btext[];
extern char etext[];

View File

@ -46,6 +46,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 */
#define cpu_lock_delay() DELAY(1)
#ifdef _KERNEL

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 */
#define cpu_lock_delay() DELAY(1)
#ifdef _KERNEL