Remove check_state() inside thread notifiatios

This was a flawed concept due to risk of deadlocks.
Worst case some we will focus o performanc regressins indvidually as we should and not accept this bug.
This commit is contained in:
Elad Ashkenazi 2024-06-28 00:03:15 +03:00
parent 71524271e9
commit c71edc0719
4 changed files with 1 additions and 51 deletions

View file

@ -557,29 +557,6 @@ void cpu_thread::operator()()
// Register thread in g_cpu_array
s_cpu_counter++;
atomic_wait_engine::set_notify_callback(g_use_rtm || get_class() != thread_class::ppu ? nullptr : +[](const void*, u64 progress)
{
static thread_local bool wait_set = false;
cpu_thread* _cpu = get_current_cpu_thread();
// Wait flag isn't set asynchronously so this should be thread-safe
if (progress == 0 && _cpu->state.none_of(cpu_flag::wait + cpu_flag::temp))
{
// Operation just started and syscall is imminent
_cpu->state += cpu_flag::wait + cpu_flag::temp;
wait_set = true;
return;
}
if (progress == umax && std::exchange(wait_set, false))
{
// Operation finished: need to clean wait flag
ensure(!_cpu->check_state());
return;
}
});
static thread_local struct thread_cleanup_t
{
cpu_thread* _this = nullptr;
@ -598,8 +575,6 @@ void cpu_thread::operator()()
ptr->compare_and_swap(_this, nullptr);
}
atomic_wait_engine::set_notify_callback(nullptr);
g_tls_log_control = [](const char*, u64){};
if (s_tls_thread_slot != umax)