diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c --- a/sys/kern/subr_lock.c +++ b/sys/kern/subr_lock.c @@ -127,7 +127,8 @@ cpu_spinwait(); la->spin_cnt += la->delay; - la->delay <<= 1; + if ((la->delay & 0x8000) == 0) + la->delay <<= 1; if (__predict_false(la->delay > lc->max)) la->delay = lc->max; } @@ -146,11 +147,14 @@ void lock_delay_default_init(struct lock_delay_config *lc) { + u_int cpu_factor; lc->base = 1; - lc->max = lock_roundup_2(mp_ncpus) * 256; - if (lc->max > 32678) - lc->max = 32678; + cpu_factor = lock_roundup_2(mp_ncpus); + if (cpu_factor * 256 > 32768) + lc->max = 32768; + else + lc->max = cpu_factor * 256; } struct lock_delay_config __read_frequently locks_delay;