Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_lock.c
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | SYSCTL_INT(_debug_lock_delay, OID_AUTO, restrict_starvation, CTLFLAG_RW, | ||||
&restrict_starvation, 0, ""); | &restrict_starvation, 0, ""); | ||||
void | void | ||||
lock_delay(struct lock_delay_arg *la) | lock_delay(struct lock_delay_arg *la) | ||||
{ | { | ||||
struct lock_delay_config *lc = la->config; | struct lock_delay_config *lc = la->config; | ||||
u_short i; | u_short i; | ||||
la->delay <<= 1; | |||||
if (__predict_false(la->delay > lc->max)) | |||||
la->delay = lc->max; | |||||
for (i = la->delay; i > 0; i--) | for (i = la->delay; i > 0; i--) | ||||
cpu_spinwait(); | cpu_spinwait(); | ||||
la->spin_cnt += la->delay; | la->spin_cnt += la->delay; | ||||
if (__predict_false(la->spin_cnt > starvation_limit)) { | if (__predict_false(la->spin_cnt > starvation_limit)) { | ||||
SDT_PROBE1(lock, , , starvation, la->delay); | SDT_PROBE1(lock, , , starvation, la->delay); | ||||
if (restrict_starvation) | if (restrict_starvation) | ||||
la->delay = lc->base; | la->delay = lc->base; | ||||
} | } | ||||
la->delay <<= 1; | |||||
if (__predict_false(la->delay > lc->max)) | |||||
la->delay = lc->max; | |||||
} | } | ||||
static u_int | static u_int | ||||
lock_roundup_2(u_int val) | lock_roundup_2(u_int val) | ||||
{ | { | ||||
u_int res; | u_int res; | ||||
for (res = 1; res <= val; res <<= 1) | for (res = 1; res <= val; res <<= 1) | ||||
▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines |