mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 00:40:11 +00:00
sys_ppu_thread: reduce global memory stats after thread creation
This commit is contained in:
parent
72d1efa383
commit
dc5cdb3bb4
@ -1577,7 +1577,7 @@ void ppu_load_exec(const ppu_exec_object& elf)
|
||||
mem_size += 0xC000000;
|
||||
}
|
||||
|
||||
g_fxo->init<lv2_memory_container>(mem_size);
|
||||
g_fxo->init<lv2_memory_container>(mem_size)->used += primary_stacksize;
|
||||
|
||||
ppu->cmd_push({ppu_cmd::initialize, 0});
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "SPURecompiler.h"
|
||||
#include "lv2/sys_sync.h"
|
||||
#include "lv2/sys_prx.h"
|
||||
#include "lv2/sys_memory.h"
|
||||
#include "Emu/GDB.h"
|
||||
|
||||
#ifdef LLVM_AVAILABLE
|
||||
@ -747,6 +748,11 @@ ppu_thread::~ppu_thread()
|
||||
{
|
||||
// Deallocate Stack Area
|
||||
vm::dealloc_verbose_nothrow(stack_addr, vm::stack);
|
||||
|
||||
if (const auto dct = g_fxo->get<lv2_memory_container>())
|
||||
{
|
||||
dct->used -= stack_size;
|
||||
}
|
||||
}
|
||||
|
||||
ppu_thread::ppu_thread(const ppu_thread_params& param, std::string_view name, u32 prio, int detached)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "sys_event.h"
|
||||
#include "sys_process.h"
|
||||
#include "sys_mmapper.h"
|
||||
#include "sys_memory.h"
|
||||
|
||||
LOG_CHANNEL(sys_ppu_thread);
|
||||
|
||||
@ -367,10 +368,19 @@ error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_par
|
||||
// Compute actual stack size and allocate
|
||||
const u32 stack_size = ::align<u32>(std::max<u32>(_stacksz, 4096), 4096);
|
||||
|
||||
const auto dct = g_fxo->get<lv2_memory_container>();
|
||||
|
||||
// Try to obtain "physical memory" from the default container
|
||||
if (!dct->take(stack_size))
|
||||
{
|
||||
return CELL_ENOMEM;
|
||||
}
|
||||
|
||||
const vm::addr_t stack_base{vm::alloc(stack_size, vm::stack, 4096)};
|
||||
|
||||
if (!stack_base)
|
||||
{
|
||||
dct->used -= stack_size;
|
||||
return CELL_ENOMEM;
|
||||
}
|
||||
|
||||
@ -408,6 +418,7 @@ error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_par
|
||||
if (!tid)
|
||||
{
|
||||
vm::dealloc(stack_base);
|
||||
dct->used -= stack_size;
|
||||
return CELL_EAGAIN;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user