summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Subv2017-07-22 19:37:26 -0500
committerGravatar Subv2017-09-15 14:26:15 -0500
commitb178089251200bd0309afcbcb06b43e7c82dc3bc (patch)
tree89b9c4927800dd6f7d2e12f9e025503131cac937 /src/core/hle/kernel/thread.cpp
parentKernel/Memory: Changed GetPhysicalPointer so that it doesn't go through the c... (diff)
downloadyuzu-b178089251200bd0309afcbcb06b43e7c82dc3bc.tar.gz
yuzu-b178089251200bd0309afcbcb06b43e7c82dc3bc.tar.xz
yuzu-b178089251200bd0309afcbcb06b43e7c82dc3bc.zip
Kernel/Threads: Don't clear the CPU instruction cache when performing a context switch from an idle thread into a thread in the same process.
We were unnecessarily clearing the cache when going from Process A -> Idle -> Process A, this caused extreme performance regressions.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index b7f094f46..f77c39d18 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -171,6 +171,8 @@ static void SwitchContext(Thread* new_thread) {
171 // Cancel any outstanding wakeup events for this thread 171 // Cancel any outstanding wakeup events for this thread
172 CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle); 172 CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle);
173 173
174 auto previous_process = Kernel::g_current_process;
175
174 current_thread = new_thread; 176 current_thread = new_thread;
175 177
176 ready_queue.remove(new_thread->current_priority, new_thread); 178 ready_queue.remove(new_thread->current_priority, new_thread);
@@ -179,7 +181,7 @@ static void SwitchContext(Thread* new_thread) {
179 Core::CPU().LoadContext(new_thread->context); 181 Core::CPU().LoadContext(new_thread->context);
180 Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); 182 Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
181 183
182 if (!previous_thread || previous_thread->owner_process != current_thread->owner_process) { 184 if (previous_process != current_thread->owner_process) {
183 Kernel::g_current_process = current_thread->owner_process; 185 Kernel::g_current_process = current_thread->owner_process;
184 Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table; 186 Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
185 // We have switched processes and thus, page tables, clear the instruction cache so we 187 // We have switched processes and thus, page tables, clear the instruction cache so we