mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
vm_native: bypass rpcs3_vm creation if overcommit is enabled (Linux)
Unfortunately, different systems need different approach here.
This commit is contained in:
parent
cb0929d933
commit
6f874be41b
@ -428,13 +428,30 @@ namespace utils
|
|||||||
|
|
||||||
m_handle = ensure(::CreateFileMappingW(f.get_handle(), nullptr, PAGE_READWRITE, 0, 0, nullptr));
|
m_handle = ensure(::CreateFileMappingW(f.get_handle(), nullptr, PAGE_READWRITE, 0, 0, nullptr));
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
// TODO: check overcommit configuration of other supported platforms to bypass rpcs3_vm creation
|
||||||
|
#ifdef __linux__
|
||||||
|
if (const char c = fs::file("/proc/sys/vm/overcommit_memory").read<char>(); c == '0' || c == '1')
|
||||||
|
{
|
||||||
|
// Simply use memfd for overcommit memory
|
||||||
|
m_file = ::memfd_create_("", 0);
|
||||||
|
ensure(m_file >= 0);
|
||||||
|
ensure(::ftruncate(m_file, m_size) >= 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Reading /proc/sys/vm/overcommit_memory: %c", c);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!storage.empty())
|
if (!storage.empty())
|
||||||
{
|
{
|
||||||
m_file = ::open(storage.c_str(), O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
|
m_file = ::open(storage.c_str(), O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_file = ::open((fs::get_cache_dir() + "rpcs3_vm").c_str(), O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
|
m_file = ::open((fs::get_cache_dir() + "rpcs3_vm_sparse.tmp").c_str(), O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure(m_file >= 0);
|
ensure(m_file >= 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user