Browse Source
[core] don't keep trying to allocate HostMemory buffer
remotes/1785372757367212240/tmp_refs/heads/variable-page-size
Exverge
4 weeks ago
No known key found for this signature in database
GPG Key ID: DAD399BCC5FB77E4
2 changed files with
8 additions and
2 deletions
-
src/common/host_memory.cpp
-
src/common/virtual_buffer.cpp
|
|
|
@ -177,7 +177,7 @@ public: |
|
|
|
|
|
|
|
if (res == 0) { |
|
|
|
LOG_WARNING(HW_Memory, "Failed to check memory region: {}", GetLastError()); |
|
|
|
continue; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
auto start_aligned = AlignUp(reinterpret_cast<SIZE_T>(info.BaseAddress), HugePageSize); |
|
|
|
@ -187,6 +187,11 @@ public: |
|
|
|
if (info.RegionSize - (start_aligned - reinterpret_cast<SIZE_T>(info.BaseAddress)) >= virtual_size) { |
|
|
|
virtual_base = static_cast<u8*>(pfn_VirtualAlloc2 |
|
|
|
(process, reinterpret_cast<PVOID>(start_aligned), virtual_size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS, nullptr, 0)); |
|
|
|
if (virtual_base) { |
|
|
|
break; |
|
|
|
} else { |
|
|
|
LOG_WARNING(HW_Memory, "Failed to allocate buffer at {:#x}, trying at at new address", start_aligned); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -22,12 +22,13 @@ void* AllocateMemoryPages(std::size_t size) noexcept { |
|
|
|
// Probably failing to reserve is less likely than failing to commit
|
|
|
|
base = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); |
|
|
|
} |
|
|
|
ASSERT_MSG(base, "Failed to allocate {} pages, error {}", size, GetLastError()); |
|
|
|
#else
|
|
|
|
void* base = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); |
|
|
|
if (base == MAP_FAILED) |
|
|
|
base = nullptr; |
|
|
|
ASSERT_MSG(base, "Failed to allocate {} pages, error {}", size, strerror(errno)); |
|
|
|
#endif
|
|
|
|
ASSERT(base); |
|
|
|
return base; |
|
|
|
} |
|
|
|
|
|
|
|
|