From 9d9e18f6147760f2502401ea0b0d4b3524f051c8 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 15 Sep 2022 08:02:20 +0300 Subject: [PATCH] CPU preemption control: don't yield if we can't stop --- rpcs3/Emu/CPU/CPUThread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 6c445c284e..e824214264 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -736,7 +736,7 @@ bool cpu_thread::check_state() noexcept if (!is_stopped(flags) && flags.none_of(cpu_flag::ret)) { // Check pause flags which hold thread inside check_state (ignore suspend/debug flags on cpu_flag::temp) - if (flags & (cpu_flag::pause + cpu_flag::memory + cpu_flag::yield + cpu_flag::preempt) || (cpu_can_stop && flags & (cpu_flag::dbg_global_pause + cpu_flag::dbg_pause + cpu_flag::suspend))) + if (flags & (cpu_flag::pause + cpu_flag::memory) || (cpu_can_stop && flags & (cpu_flag::dbg_global_pause + cpu_flag::dbg_pause + cpu_flag::suspend + cpu_flag::yield + cpu_flag::preempt))) { if (!(flags & cpu_flag::wait)) { @@ -744,7 +744,7 @@ bool cpu_thread::check_state() noexcept store = true; } - if (flags & (cpu_flag::yield + cpu_flag::preempt)) + if (flags & (cpu_flag::yield + cpu_flag::preempt) && cpu_can_stop) { flags -= (cpu_flag::yield + cpu_flag::preempt); store = true; @@ -779,7 +779,7 @@ bool cpu_thread::check_state() noexcept return store; }).first; - if (state0 & cpu_flag::preempt) + if (state0 & cpu_flag::preempt && cpu_can_stop) { if (cpu_flag::wait - state0) { @@ -899,7 +899,7 @@ bool cpu_thread::check_state() noexcept continue; } - if (state0 & cpu_flag::yield && cpu_flag::wait - state0) + if (state0 & cpu_flag::yield && cpu_flag::wait - state0 && cpu_can_stop) { if (auto spu = try_get()) {