From 9c5108c1ca9b8748bf8af85007fe189e2fe82bd3 Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 13 Sep 2022 21:16:44 +0300 Subject: [PATCH] CPU preemption control: Add one more debug variable --- rpcs3/Emu/Cell/lv2/lv2.cpp | 3 +++ rpcs3/Emu/RSX/RSXThread.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 8c78738f50..d37a8f9caf 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -1211,6 +1211,7 @@ static std::deque g_to_sleep; static atomic_t s_yield_frequency = 0; static atomic_t s_max_allowed_yield_tsc = 0; static u64 s_last_yield_tsc = 0; +atomic_t g_lv2_preempts_taken = 0; namespace cpu_counter { @@ -1676,6 +1677,7 @@ void lv2_obj::schedule_all(u64 current_time) { cpu->state += cpu_flag::preempt; s_last_yield_tsc = tsc; + g_lv2_preempts_taken.release(g_lv2_preempts_taken.load() + 1); // Has a minor race but performance is more important rsx::set_rsx_yield_flag(); } } @@ -1768,6 +1770,7 @@ void lv2_obj::set_yield_frequency(u64 freq, u64 max_allowed_tsc) { s_yield_frequency.release(freq); s_max_allowed_yield_tsc.release(max_allowed_tsc); + g_lv2_preempts_taken.release(0); } bool lv2_obj::wait_timeout(u64 usec, ppu_thread* cpu, bool scale, bool is_usleep) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index ba6b38d309..ba97252390 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -42,6 +42,7 @@ rsx::frame_capture_data frame_capture; extern CellGcmOffsetTable offsetTable; extern thread_local std::string(*g_tls_log_prefix)(); +extern atomic_t g_lv2_preempts_taken; LOG_CHANNEL(perf_log, "PERF"); @@ -3645,7 +3646,7 @@ namespace rsx lower_preemption_count(); } - perf_log.trace("CPU preemption control: reeval=%d, preempt_count=%d, fails=%d, hard=%d, avg_frame_time=%d, highered=%d, lowered=%d", can_reevaluate, preempt_count, fails, hard_fails, avg_frame_time, highered_delay, lowered_delay); + perf_log.trace("CPU preemption control: reeval=%d, preempt_count=%d, fails=%d, hard=%d, avg_frame_time=%d, highered=%d, lowered=%d, taken=%u", can_reevaluate, preempt_count, fails, hard_fails, avg_frame_time, highered_delay, lowered_delay, ::g_lv2_preempts_taken.load()); if (hard_measures_taken) {