Skip to content

Commit

Permalink
Fix preformance regression on TSX path
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Apr 28, 2020
1 parent 7da8ba5 commit 5fb53ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,11 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr)

for (u64 count = 0; g_use_rtm; [&]()
{
if (ppu.is_paused())
{
ppu.check_state();
}

if (++count < 20) [[likely]]
{
busy_wait(300);
Expand All @@ -1049,21 +1054,14 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr)

if (ppu.rtime & 127)
{
if (!(ppu.state & cpu_flag::wait))
{
ppu.state += cpu_flag::wait;
}

continue;
}

ppu.rdata = data;

if (vm::reservation_acquire(addr, sizeof(T)) == ppu.rtime) [[likely]]
{
ppu.test_stopped();

if (count >= 10) [[unlikely]]
if (count >= 15) [[unlikely]]
{
ppu_log.error("%s took too long: %u", sizeof(T) == 4 ? "LWARX" : "LDARX", count);
}
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,9 +1737,9 @@ bool spu_thread::process_mfc_cmd()

for (u64 i = 0;; [&]()
{
if (ntime & 127 && g_use_rtm && !(state & cpu_flag::wait))
if (is_paused())
{
state += cpu_flag::wait;
check_state();
}

if (++i < 25) [[likely]]
Expand All @@ -1766,7 +1766,7 @@ bool spu_thread::process_mfc_cmd()
ntime != time0)
{
// Reservation data has been modified recently
if (time0 & 127) i += 12, ntime = time0;
if (time0 & 127) i += 12;
continue;
}

Expand Down

0 comments on commit 5fb53ef

Please sign in to comment.