From 644fa4bf7bcec09a5469f42837c1e1f6d7517a03 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 12 Jul 2022 13:47:05 -0400 Subject: [PATCH] kernel/scheduler: Reset the invoke_scheduler flag on reschedule. There is nowhere else that unsets it (or makes sense to unset it), we have to do it here, or otherwise it will never be unset. This has actually been broken since the new scheduler was merged many years ago; the old scheduler (which had more complex logic here) unset this flag correctly. This oversight mostly did not cause obvious problems: while the scheduler would be invoked unnecessarily on every single interrupt, that would be a minor performance downturn at most. But there is one other effect: since we can only reenable interrupts after invoking the scheduler, "post_interrupt_callback"s of threads were not invoked most of the time. The main user of "post_interrupt_callback"s is the profiler, which uses them to trigger buffer flushes back to userland. Since they were not invoked, the buffer would quickly fill up and then no more results would be recorded. Thus, this fixes #16345. --- src/system/kernel/scheduler/scheduler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/system/kernel/scheduler/scheduler.cpp b/src/system/kernel/scheduler/scheduler.cpp index 0c69aa6c7c..9ecb4e3e15 100644 --- a/src/system/kernel/scheduler/scheduler.cpp +++ b/src/system/kernel/scheduler/scheduler.cpp @@ -319,6 +319,7 @@ reschedule(int32 nextState) SCHEDULER_ENTER_FUNCTION(); int32 thisCPU = smp_get_current_cpu(); + gCPU[thisCPU].invoke_scheduler = false; CPUEntry* cpu = CPUEntry::GetCPU(thisCPU); CoreEntry* core = CoreEntry::GetCore(thisCPU);