mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
kernel-explorer: Implement PPU scheduler state information
This commit is contained in:
parent
a7d0c4fb1e
commit
dcfd29c2d9
6 changed files with 84 additions and 14 deletions
|
@ -97,6 +97,27 @@ void fmt_class_string<ppu_join_status>::format(std::string& out, u64 arg)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void fmt_class_string<ppu_thread_status>::format(std::string& out, u64 arg)
|
||||||
|
{
|
||||||
|
format_enum(out, arg, [](ppu_thread_status s)
|
||||||
|
{
|
||||||
|
switch (s)
|
||||||
|
{
|
||||||
|
case PPU_THREAD_STATUS_IDLE: return "IDLE";
|
||||||
|
case PPU_THREAD_STATUS_RUNNABLE: return "RUN";
|
||||||
|
case PPU_THREAD_STATUS_ONPROC: return "ONPROC";
|
||||||
|
case PPU_THREAD_STATUS_SLEEP: return "SLEEP";
|
||||||
|
case PPU_THREAD_STATUS_STOP: return "STOP";
|
||||||
|
case PPU_THREAD_STATUS_ZOMBIE: return "Zombie";
|
||||||
|
case PPU_THREAD_STATUS_DELETED: return "Deleted";
|
||||||
|
case PPU_THREAD_STATUS_UNKNOWN: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return unknown;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const ppu_decoder<ppu_interpreter_precise> g_ppu_interpreter_precise;
|
const ppu_decoder<ppu_interpreter_precise> g_ppu_interpreter_precise;
|
||||||
const ppu_decoder<ppu_interpreter_fast> g_ppu_interpreter_fast;
|
const ppu_decoder<ppu_interpreter_fast> g_ppu_interpreter_fast;
|
||||||
const ppu_decoder<ppu_itype> g_ppu_itype;
|
const ppu_decoder<ppu_itype> g_ppu_itype;
|
||||||
|
|
|
@ -34,6 +34,18 @@ enum class ppu_join_status : u32
|
||||||
max = 4, // Values above it indicate PPU id of joining thread
|
max = 4, // Values above it indicate PPU id of joining thread
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ppu_thread_status : u32
|
||||||
|
{
|
||||||
|
PPU_THREAD_STATUS_IDLE,
|
||||||
|
PPU_THREAD_STATUS_RUNNABLE,
|
||||||
|
PPU_THREAD_STATUS_ONPROC,
|
||||||
|
PPU_THREAD_STATUS_SLEEP,
|
||||||
|
PPU_THREAD_STATUS_STOP,
|
||||||
|
PPU_THREAD_STATUS_ZOMBIE,
|
||||||
|
PPU_THREAD_STATUS_DELETED,
|
||||||
|
PPU_THREAD_STATUS_UNKNOWN,
|
||||||
|
};
|
||||||
|
|
||||||
// Formatting helper
|
// Formatting helper
|
||||||
enum class ppu_syscall_code : u64
|
enum class ppu_syscall_code : u64
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
#include "sys_uart.h"
|
#include "sys_uart.h"
|
||||||
#include "sys_crypto_engine.h"
|
#include "sys_crypto_engine.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
extern std::string ppu_get_syscall_name(u64 code);
|
extern std::string ppu_get_syscall_name(u64 code);
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -1387,3 +1389,41 @@ void lv2_obj::schedule_all()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppu_thread_status lv2_obj::ppu_state(ppu_thread* ppu, bool lock_idm)
|
||||||
|
{
|
||||||
|
std::optional<reader_lock> opt_lock;
|
||||||
|
|
||||||
|
if (lock_idm)
|
||||||
|
{
|
||||||
|
opt_lock.emplace(id_manager::g_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ppu->state & cpu_flag::stop)
|
||||||
|
{
|
||||||
|
return PPU_THREAD_STATUS_IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (ppu->joiner)
|
||||||
|
{
|
||||||
|
case ppu_join_status::zombie: return PPU_THREAD_STATUS_ZOMBIE;
|
||||||
|
case ppu_join_status::exited: return PPU_THREAD_STATUS_DELETED;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
reader_lock lock(g_mutex);
|
||||||
|
|
||||||
|
const auto it = std::find(g_ppu.begin(), g_ppu.end(), ppu);
|
||||||
|
|
||||||
|
if (it == g_ppu.end())
|
||||||
|
{
|
||||||
|
return PPU_THREAD_STATUS_SLEEP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it - g_ppu.begin() >= g_cfg.core.ppu_threads)
|
||||||
|
{
|
||||||
|
return PPU_THREAD_STATUS_RUNNABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PPU_THREAD_STATUS_ONPROC;
|
||||||
|
}
|
||||||
|
|
|
@ -41,18 +41,6 @@ struct sys_ppu_thread_icontext_t
|
||||||
be_t<u64> pc;
|
be_t<u64> pc;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum : u32
|
|
||||||
{
|
|
||||||
PPU_THREAD_STATUS_IDLE,
|
|
||||||
PPU_THREAD_STATUS_RUNNABLE,
|
|
||||||
PPU_THREAD_STATUS_ONPROC,
|
|
||||||
PPU_THREAD_STATUS_SLEEP,
|
|
||||||
PPU_THREAD_STATUS_STOP,
|
|
||||||
PPU_THREAD_STATUS_ZOMBIE,
|
|
||||||
PPU_THREAD_STATUS_DELETED,
|
|
||||||
PPU_THREAD_STATUS_UNKNOWN,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Syscalls
|
// Syscalls
|
||||||
|
|
||||||
void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode);
|
void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode);
|
||||||
|
|
|
@ -60,6 +60,8 @@ enum
|
||||||
SYS_SYNC_ATTR_ADAPTIVE_MASK = 0xf000,
|
SYS_SYNC_ATTR_ADAPTIVE_MASK = 0xf000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ppu_thread_status : u32;
|
||||||
|
|
||||||
// Base class for some kernel objects (shared set of 8192 objects).
|
// Base class for some kernel objects (shared set of 8192 objects).
|
||||||
struct lv2_obj
|
struct lv2_obj
|
||||||
{
|
{
|
||||||
|
@ -185,6 +187,8 @@ public:
|
||||||
g_to_awake.clear();
|
g_to_awake.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ppu_thread_status ppu_state(ppu_thread* ppu, bool lock_idm = true);
|
||||||
|
|
||||||
static inline void append(cpu_thread* const thread)
|
static inline void append(cpu_thread* const thread)
|
||||||
{
|
{
|
||||||
g_to_awake.emplace_back(thread);
|
g_to_awake.emplace_back(thread);
|
||||||
|
|
|
@ -553,8 +553,13 @@ void kernel_explorer::Update()
|
||||||
idm::select<named_thread<ppu_thread>>([&](u32 id, ppu_thread& ppu)
|
idm::select<named_thread<ppu_thread>>([&](u32 id, ppu_thread& ppu)
|
||||||
{
|
{
|
||||||
const auto func = ppu.last_function;
|
const auto func = ppu.last_function;
|
||||||
add_leaf(find_node(root, additional_nodes::ppu_threads), qstr(fmt::format(u8"PPU 0x%07x: “%s”, PRIO: %d, Joiner: %s, State: %s, %s func: “%s”", id, *ppu.ppu_tname.load(), +ppu.prio, ppu.joiner.load(), ppu.state.load()
|
const ppu_thread_status status = lv2_obj::ppu_state(&ppu, false);
|
||||||
|
|
||||||
|
if (status != PPU_THREAD_STATUS_DELETED)
|
||||||
|
{
|
||||||
|
add_leaf(find_node(root, additional_nodes::ppu_threads), qstr(fmt::format(u8"PPU 0x%07x: “%s”, PRIO: %d, Joiner: %s, Status: %s, State: %s, %s func: “%s”", id, *ppu.ppu_tname.load(), +ppu.prio, ppu.joiner.load(), status, ppu.state.load()
|
||||||
, ppu.current_function ? "In" : "Last", func ? func : "")));
|
, ppu.current_function ? "In" : "Last", func ? func : "")));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
idm::select<named_thread<spu_thread>>([&](u32 /*id*/, spu_thread& spu)
|
idm::select<named_thread<spu_thread>>([&](u32 /*id*/, spu_thread& spu)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue