Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm_native: fix overcommit on FreeBSD #10989

Merged
merged 2 commits into from Oct 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions rpcs3/util/vm_native.cpp
Expand Up @@ -15,8 +15,9 @@
#include <sys/types.h>
#endif

#if !defined(__linux__) && !defined(_WIN32)
#if defined(__FreeBSD__)
#include <sys/sysctl.h>
#include <vm/vm_param.h>
#endif

#ifdef __linux__
Expand Down Expand Up @@ -461,21 +462,19 @@ namespace utils
#if defined(__NetBSD__) || defined(__APPLE__)
// Always ON
vm_overcommit = 0;
#elif defined(__FreeBSD__) && defined(VM_OVERCOMMIT)
#elif defined(__FreeBSD__)
int mib[2]{CTL_VM, VM_OVERCOMMIT};
if (::sysctl(mib, 2, &vm_overcommit, &vm_sz, NULL, 0) != 0)
vm_overcommit = -1;
#elif defined(__FreeBSD__) || defined(__DragonFly__)
if (::sysctlbyname("vm.overcommit", &vm_overcommit, &vm_sz, NULL, 0) != 0)
vm_overcommit = -1;
#else
vm_overcommit = -1;
#endif

if ((vm_overcommit & 3) == 0)
{
#ifdef SHM_ANON
ensure(::shm_open(SHM_ANON, O_RDWR, S_IWUSR | S_IRUSR) == 0);
#if defined(__FreeBSD__)
m_file = ::memfd_create_("", 0);
ensure(m_file >= 0);
#else
const std::string name = "/rpcs3-mem2-" + std::to_string(reinterpret_cast<u64>(this));

Expand Down