diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-27 23:23:21 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-27 23:23:21 +0100 |
commit | f2decb666543531b94f528ddb08373961f9a2a30 (patch) | |
tree | 718732be8d0b6fde6176a34ac165fae4f1430202 /Kernel | |
parent | db1448b21a253cf3ac1bd4899da3006eb7e4d58b (diff) | |
download | serenity-f2decb666543531b94f528ddb08373961f9a2a30.zip |
Revert "Kernel: Fix Thread::relock_process leaving critical section"
This reverts commit e9e76b80749c74bc1ef6bd24c30d11103a28a27e.
This was causing a noticeable slowdown, and we're not sure that it was
actually necessary.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Scheduler.cpp | 9 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 3b393c8dda..f4823f443c 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -588,19 +588,16 @@ void Scheduler::invoke_async() void Scheduler::yield_from_critical() { auto& proc = Processor::current(); - auto before_critical = proc.in_critical(); - ASSERT(before_critical); + ASSERT(proc.in_critical()); ASSERT(!proc.in_irq()); yield(); // Flag a context switch u32 prev_flags; - u32 prev_crit = proc.clear_critical(prev_flags, false); + u32 prev_crit = Processor::current().clear_critical(prev_flags, false); // Note, we may now be on a different CPU! - auto& new_proc = Processor::current(); - new_proc.restore_critical(prev_crit, prev_flags); - ASSERT(before_critical == new_proc.in_critical()); + Processor::current().restore_critical(prev_crit, prev_flags); } void Scheduler::notify_finalizer() diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 551acc3f63..79c4392d77 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -305,16 +305,17 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore) // flagged by calling Scheduler::donate_to or Scheduler::yield // above. We have to do it this way because we intentionally // leave the critical section here to be able to switch contexts. - auto critical_before = Processor::current().in_critical(); - ASSERT(critical_before); + u32 prev_flags; + u32 prev_crit = Processor::current().clear_critical(prev_flags, true); + + // CONTEXT SWITCH HAPPENS HERE! - Scheduler::yield_from_critical(); + // NOTE: We may be on a different CPU now! + Processor::current().restore_critical(prev_crit, prev_flags); - ASSERT(Processor::current().in_critical() == critical_before); if (previous_locked != LockMode::Unlocked) { // We've unblocked, relock the process if needed and carry on. RESTORE_LOCK(process().big_lock(), previous_locked, lock_count_to_restore); - ASSERT(Processor::current().in_critical() == critical_before); } } |