diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 332f161d5f40..16ff5b0dc7e4 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -216,6 +216,7 @@ _kernel_lock(int nlocks) 0); if (__predict_true(__cpu_simple_lock_try(kernel_lock))) { + kernel_lock_holder = curcpu(); ci->ci_biglock_count = nlocks; l->l_blcnt = nlocks; LOCKDEBUG_LOCKED(kernel_lock_dodebug, kernel_lock, NULL, @@ -255,8 +256,10 @@ _kernel_lock(int nlocks) ipi_msg_t msg = { .func = kernel_lock_trace_ipi, }; + kpreempt_disable(); ipi_unicast(&msg, kernel_lock_holder); ipi_wait(&msg); + kpreempt_enable(); if (start_init_exec) _KERNEL_LOCK_ABORT("spinout"); }