mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
Logs: add callback for cpu_thread to set cpu_flag::wait
May improve waiting time in critical suspend_all ops.
This commit is contained in:
parent
8ce0819b42
commit
95dbcf2fd7
@ -24,6 +24,8 @@ LOG_CHANNEL(sys_log, "SYS");
|
||||
|
||||
static thread_local u64 s_tls_thread_slot = -1;
|
||||
|
||||
extern thread_local void(*g_tls_log_control)(const char* fmt, u64 progress);
|
||||
|
||||
template <>
|
||||
void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
|
||||
{
|
||||
@ -469,6 +471,26 @@ void cpu_thread::operator()()
|
||||
}
|
||||
});
|
||||
|
||||
g_tls_log_control = [](const char* fmt, u64 progress)
|
||||
{
|
||||
static thread_local bool wait_set = false;
|
||||
|
||||
cpu_thread* _cpu = get_current_cpu_thread();
|
||||
|
||||
if (progress == 0 && !(_cpu->state & cpu_flag::wait))
|
||||
{
|
||||
_cpu->state += cpu_flag::wait + cpu_flag::temp;
|
||||
wait_set = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (progress == umax && std::exchange(wait_set, false))
|
||||
{
|
||||
verify(HERE), !_cpu->check_state();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
static thread_local struct thread_cleanup_t
|
||||
{
|
||||
cpu_thread* _this;
|
||||
@ -494,6 +516,8 @@ void cpu_thread::operator()()
|
||||
|
||||
atomic_storage_futex::set_notify_callback(nullptr);
|
||||
|
||||
g_tls_log_control = [](const char*, u64){};
|
||||
|
||||
g_fxo->get<cpu_counter>()->remove(_this, s_tls_thread_slot);
|
||||
|
||||
_this = nullptr;
|
||||
|
@ -31,6 +31,9 @@ static std::string empty_string()
|
||||
// Thread-specific log prefix provider
|
||||
thread_local std::string(*g_tls_log_prefix)() = &empty_string;
|
||||
|
||||
// Another thread-specific callback
|
||||
thread_local void(*g_tls_log_control)(const char* fmt, u64 progress) = [](const char*, u64){};
|
||||
|
||||
template<>
|
||||
void fmt_class_string<logs::level>::format(std::string& out, u64 arg)
|
||||
{
|
||||
@ -314,6 +317,9 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co
|
||||
// Get timestamp
|
||||
const u64 stamp = get_stamp();
|
||||
|
||||
// Notify start operation
|
||||
g_tls_log_control(fmt, 0);
|
||||
|
||||
// Get text, extract va_args
|
||||
/*constinit thread_local*/ std::string text;
|
||||
/*constinit thread_local*/ std::basic_string<u64> args;
|
||||
@ -361,6 +367,9 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co
|
||||
lis->log(stamp, *this, prefix, text);
|
||||
lis = lis->m_next;
|
||||
}
|
||||
|
||||
// Notify end operation
|
||||
g_tls_log_control(fmt, -1);
|
||||
}
|
||||
|
||||
logs::file_writer::file_writer(const std::string& name, u64 max_size)
|
||||
|
Loading…
x
Reference in New Issue
Block a user