mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-21 07:45:11 +00:00
8354922: ZGC: Use MAP_FIXED_NOREPLACE when reserving memory
Reviewed-by: aboldtch, eosterlund
This commit is contained in:
parent
9eeb86d972
commit
0f1c448ca1
@ -35,6 +35,10 @@
|
||||
#define MPOL_F_ADDR (1<<1)
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FIXED_NOREPLACE
|
||||
#define MAP_FIXED_NOREPLACE 0x100000
|
||||
#endif
|
||||
|
||||
class ZSyscall : public AllStatic {
|
||||
public:
|
||||
static int memfd_create(const char* name, unsigned int flags);
|
||||
|
||||
@ -24,6 +24,9 @@
|
||||
#include "gc/z/zAddress.inline.hpp"
|
||||
#include "gc/z/zVirtualMemoryManager.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#ifdef LINUX
|
||||
#include "gc/z/zSyscall_linux.hpp"
|
||||
#endif
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
@ -32,7 +35,9 @@ void ZVirtualMemoryReserver::pd_register_callbacks(ZVirtualMemoryRegistry* regis
|
||||
}
|
||||
|
||||
bool ZVirtualMemoryReserver::pd_reserve(zaddress_unsafe addr, size_t size) {
|
||||
void* const res = mmap((void*)untype(addr), size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
|
||||
const int flags = MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE LINUX_ONLY(|MAP_FIXED_NOREPLACE);
|
||||
|
||||
void* const res = mmap((void*)untype(addr), size, PROT_NONE, flags, -1, 0);
|
||||
if (res == MAP_FAILED) {
|
||||
// Failed to reserve memory
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user