Skip to content

Commit 0f1c448

Browse files
committed
8354922: ZGC: Use MAP_FIXED_NOREPLACE when reserving memory
Reviewed-by: aboldtch, eosterlund
1 parent 9eeb86d commit 0f1c448

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/hotspot/os/linux/gc/z/zSyscall_linux.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#define MPOL_F_ADDR (1<<1)
3636
#endif
3737

38+
#ifndef MAP_FIXED_NOREPLACE
39+
#define MAP_FIXED_NOREPLACE 0x100000
40+
#endif
41+
3842
class ZSyscall : public AllStatic {
3943
public:
4044
static int memfd_create(const char* name, unsigned int flags);

src/hotspot/os/posix/gc/z/zVirtualMemoryManager_posix.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "gc/z/zAddress.inline.hpp"
2525
#include "gc/z/zVirtualMemoryManager.hpp"
2626
#include "logging/log.hpp"
27+
#ifdef LINUX
28+
#include "gc/z/zSyscall_linux.hpp"
29+
#endif
2730

2831
#include <sys/mman.h>
2932

@@ -32,7 +35,9 @@ void ZVirtualMemoryReserver::pd_register_callbacks(ZVirtualMemoryRegistry* regis
3235
}
3336

3437
bool ZVirtualMemoryReserver::pd_reserve(zaddress_unsafe addr, size_t size) {
35-
void* const res = mmap((void*)untype(addr), size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
38+
const int flags = MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE LINUX_ONLY(|MAP_FIXED_NOREPLACE);
39+
40+
void* const res = mmap((void*)untype(addr), size, PROT_NONE, flags, -1, 0);
3641
if (res == MAP_FAILED) {
3742
// Failed to reserve memory
3843
return false;

0 commit comments

Comments
 (0)