mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12: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
2 changed files with 33 additions and 0 deletions
|
@ -24,6 +24,8 @@ LOG_CHANNEL(sys_log, "SYS");
|
||||||
|
|
||||||
static thread_local u64 s_tls_thread_slot = -1;
|
static thread_local u64 s_tls_thread_slot = -1;
|
||||||
|
|
||||||
|
extern thread_local void(*g_tls_log_control)(const char* fmt, u64 progress);
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
|
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
|
static thread_local struct thread_cleanup_t
|
||||||
{
|
{
|
||||||
cpu_thread* _this;
|
cpu_thread* _this;
|
||||||
|
@ -494,6 +516,8 @@ void cpu_thread::operator()()
|
||||||
|
|
||||||
atomic_storage_futex::set_notify_callback(nullptr);
|
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);
|
g_fxo->get<cpu_counter>()->remove(_this, s_tls_thread_slot);
|
||||||
|
|
||||||
_this = nullptr;
|
_this = nullptr;
|
||||||
|
|
|
@ -31,6 +31,9 @@ static std::string empty_string()
|
||||||
// Thread-specific log prefix provider
|
// Thread-specific log prefix provider
|
||||||
thread_local std::string(*g_tls_log_prefix)() = &empty_string;
|
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<>
|
template<>
|
||||||
void fmt_class_string<logs::level>::format(std::string& out, u64 arg)
|
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
|
// Get timestamp
|
||||||
const u64 stamp = get_stamp();
|
const u64 stamp = get_stamp();
|
||||||
|
|
||||||
|
// Notify start operation
|
||||||
|
g_tls_log_control(fmt, 0);
|
||||||
|
|
||||||
// Get text, extract va_args
|
// Get text, extract va_args
|
||||||
/*constinit thread_local*/ std::string text;
|
/*constinit thread_local*/ std::string text;
|
||||||
/*constinit thread_local*/ std::basic_string<u64> args;
|
/*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->log(stamp, *this, prefix, text);
|
||||||
lis = lis->m_next;
|
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)
|
logs::file_writer::file_writer(const std::string& name, u64 max_size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue