runloop: service the bhqueue before taking kernel lock
@@ -141,19 +141,16 @@ NOTRACE void __attribute__((noreturn)) runloop_internal()
queue_length(bhqueue), queue_length(runqueue), queue_length(thread_queue),
idle_cpu_mask, ci->have_kernel_lock);
ci->state = cpu_kernel;
+ while ((t = dequeue(bhqueue)) != INVALID_ADDRESS)
+ run_thunk(t, cpu_kernel);
+
if (kern_try_lock()) {
/* invoke expired timer callbacks */
ci->state = cpu_kernel;
timer_service(runloop_timers, now(CLOCK_ID_MONOTONIC));
- /* serve bhqueue and runqueue to completion */
- while ((t = dequeue(bhqueue)) != INVALID_ADDRESS) {
- run_thunk(t, cpu_kernel);
- }
-
- while ((t = dequeue(runqueue)) != INVALID_ADDRESS) {
+ while ((t = dequeue(runqueue)) != INVALID_ADDRESS)
run_thunk(t, cpu_kernel);
- }
/* should be a list of per-runloop checks - also low-pri background */
mm_service();
