--- old/src/hotspot/os/aix/os_aix.cpp 2017-11-03 01:09:25.600797770 -0700 +++ new/src/hotspot/os/aix/os_aix.cpp 2017-11-03 01:09:25.354799714 -0700 @@ -2500,7 +2500,7 @@ result = reserve_mmaped_memory(bytes, requested_addr, 0); if (result != NULL) { - if (replace_existing_mapping_with_dax_file_mapping(result, bytes, file_desc) == NULL) { + if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) { vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); } } --- old/src/hotspot/os/bsd/os_bsd.cpp 2017-11-03 01:09:26.209792956 -0700 +++ new/src/hotspot/os/bsd/os_bsd.cpp 2017-11-03 01:09:25.939795090 -0700 @@ -2355,7 +2355,7 @@ assert(file_desc >= 0, "file_desc is not valid"); char* result = pd_attempt_reserve_memory_at(bytes, requested_addr); if (result != NULL) { - if (replace_existing_mapping_with_dax_file_mapping(result, bytes, file_desc) == NULL) { + if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) { vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); } } --- old/src/hotspot/os/linux/os_linux.cpp 2017-11-03 01:09:26.738788775 -0700 +++ new/src/hotspot/os/linux/os_linux.cpp 2017-11-03 01:09:26.521790490 -0700 @@ -129,6 +129,7 @@ #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) #define LARGEPAGES_BIT (1 << 6) +#define DAX_SHARED_BIT (1 << 8) //////////////////////////////////////////////////////////////////////////////// // global variables julong os::Linux::_physical_memory = 0; @@ -3264,10 +3265,13 @@ // effective only if the bit 2 is cleared) // - (bit 5) hugetlb private memory // - (bit 6) hugetlb shared memory +// - (bit 7) dax private memory +// - (bit 8) dax shared memory // -static void set_coredump_filter(void) { +static void set_coredump_filter(bool largepages, bool dax_shared) { FILE *f; long cdm; + bool filter_changed = false; if ((f = fopen("/proc/self/coredump_filter", "r+")) == NULL) { return; @@ -3280,8 +3284,15 @@ rewind(f); - if ((cdm & LARGEPAGES_BIT) == 0) { + if (largepages && (cdm & LARGEPAGES_BIT) == 0) { cdm |= LARGEPAGES_BIT; + filter_changed = true; + } + if (dax_shared && (cdm & DAX_SHARED_BIT) == 0) { + cdm |= DAX_SHARED_BIT; + filter_changed = true; + } + if (filter_changed) { fprintf(f, "%#lx", cdm); } @@ -3420,7 +3431,7 @@ size_t large_page_size = Linux::setup_large_page_size(); UseLargePages = Linux::setup_large_page_type(large_page_size); - set_coredump_filter(); + set_coredump_filter(true /*largepages*/, false /*dax_shared*/); } #ifndef SHM_HUGETLB @@ -3795,7 +3806,7 @@ assert(file_desc >= 0, "file_desc is not valid"); char* result = pd_attempt_reserve_memory_at(bytes, requested_addr); if (result != NULL) { - if (replace_existing_mapping_with_dax_file_mapping(result, bytes, file_desc) == NULL) { + if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) { vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); } } @@ -4929,6 +4940,9 @@ // initialize thread priority policy prio_init(); + if (!FLAG_IS_DEFAULT(AllocateHeapAt)) { + set_coredump_filter(false /*largepages*/, true /*dax_shared*/); + } return JNI_OK; } --- old/src/hotspot/os/posix/os_posix.cpp 2017-11-03 01:09:27.355783899 -0700 +++ new/src/hotspot/os/posix/os_posix.cpp 2017-11-03 01:09:27.104785882 -0700 @@ -239,7 +239,7 @@ } // Map the given address range to the provided file descriptor. -char* os::map_memory_to_dax_file(char* base, size_t size, int fd) { +char* os::map_memory_to_file(char* base, size_t size, int fd) { assert(fd != -1, "File descriptor is not valid"); // allocate space for the file @@ -267,11 +267,11 @@ return addr; } -char* os::replace_existing_mapping_with_dax_file_mapping(char* base, size_t size, int fd) { +char* os::replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd) { assert(fd != -1, "File descriptor is not valid"); assert(base != NULL, "Base cannot be NULL"); - return map_memory_to_dax_file(base, size, fd); + return map_memory_to_file(base, size, fd); } // Multiple threads can race in this code, and can remap over each other with MAP_FIXED, @@ -328,7 +328,7 @@ if (file_desc != -1) { // After we have an aligned address, we can replace anonymous mapping with file mapping - if (replace_existing_mapping_with_dax_file_mapping(aligned_base, size, file_desc) == NULL) { + if (replace_existing_mapping_with_file_mapping(aligned_base, size, file_desc) == NULL) { vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); } MemTracker::record_virtual_memory_commit((address)aligned_base, size, CALLER_PC); --- old/src/hotspot/os/solaris/os_solaris.cpp 2017-11-03 01:09:27.943779251 -0700 +++ new/src/hotspot/os/solaris/os_solaris.cpp 2017-11-03 01:09:27.674781377 -0700 @@ -2586,7 +2586,7 @@ assert(file_desc >= 0, "file_desc is not valid"); char* result = pd_attempt_reserve_memory_at(bytes, requested_addr); if (result != NULL) { - if (replace_existing_mapping_with_dax_file_mapping(result, bytes, file_desc) == NULL) { + if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) { vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); } } --- old/src/hotspot/os/windows/os_windows.cpp 2017-11-03 01:09:28.596774091 -0700 +++ new/src/hotspot/os/windows/os_windows.cpp 2017-11-03 01:09:28.331776185 -0700 @@ -2914,7 +2914,7 @@ } // If 'base' is not NULL, function will return NULL if it cannot get 'base' -char* os::map_memory_to_dax_file(char* base, size_t size, int fd) { +char* os::map_memory_to_file(char* base, size_t size, int fd) { assert(fd != -1, "File descriptor is not valid"); HANDLE fh = (HANDLE)_get_osfhandle(fd); @@ -2938,12 +2938,12 @@ return (char*)addr; } -char* os::replace_existing_mapping_with_dax_file_mapping(char* base, size_t size, int fd) { +char* os::replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd) { assert(fd != -1, "File descriptor is not valid"); assert(base != NULL, "Base address cannot be NULL"); release_memory(base, size); - return map_memory_to_dax_file(base, size, fd); + return map_memory_to_file(base, size, fd); } // On win32, one cannot release just a part of reserved memory, it's an @@ -3037,7 +3037,7 @@ char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr, int file_desc) { assert(file_desc >= 0, "file_desc is not valid"); - return map_memory_to_dax_file(requested_addr, bytes, file_desc); + return map_memory_to_file(requested_addr, bytes, file_desc); } size_t os::large_page_size() { --- old/src/hotspot/share/runtime/arguments.cpp 2017-11-03 01:09:29.177769499 -0700 +++ new/src/hotspot/share/runtime/arguments.cpp 2017-11-03 01:09:28.953771269 -0700 @@ -2534,7 +2534,7 @@ } #endif if (!FLAG_IS_DEFAULT(AllocateHeapAt)) { - if (!FLAG_IS_DEFAULT(UseNUMAInterleaving) || !FLAG_IS_DEFAULT(UseNUMA)) { + if ((UseNUMAInterleaving && !FLAG_IS_DEFAULT(UseNUMAInterleaving)) || (UseNUMA && !FLAG_IS_DEFAULT(UseNUMA))) { log_warning(arguments) ("NUMA support for Heap depends on the file system when AllocateHeapAt option is used.\n"); } } --- old/src/hotspot/share/runtime/os.cpp 2017-11-03 01:09:29.786764685 -0700 +++ new/src/hotspot/share/runtime/os.cpp 2017-11-03 01:09:29.543766606 -0700 @@ -1678,9 +1678,9 @@ char* result = NULL; if (file_desc != -1) { - // Could have called pd_reserve_memory() followed by replace_existing_mapping_with_dax_file_mapping(), + // Could have called pd_reserve_memory() followed by replace_existing_mapping_with_file_mapping(), // but AIX may use SHM in which case its more trouble to detach the segment and remap memory to the file. - result = os::map_memory_to_dax_file(addr, bytes, file_desc); + result = os::map_memory_to_file(addr, bytes, file_desc); if (result != NULL) { MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC); } --- old/src/hotspot/share/runtime/os.hpp 2017-11-03 01:09:30.347760251 -0700 +++ new/src/hotspot/share/runtime/os.hpp 2017-11-03 01:09:30.090762283 -0700 @@ -341,10 +341,11 @@ // Helper function to create a new file with template jvmheap.XXXXXX. // Returns a valid fd on success or else returns -1 static int create_file_for_heap(const char* dir); - // Map memory to the dax (direct access) file referred by fd - static char* map_memory_to_dax_file(char* base, size_t size, int fd); + // Map memory to the file referred by fd. This function is slightly different from map_memory() + // and is added to be used for implementation of -XX:AllocateHeapAt + static char* map_memory_to_file(char* base, size_t size, int fd); // Replace existing reserved memory with file mapping - static char* replace_existing_mapping_with_dax_file_mapping(char* base, size_t size, int fd); + static char* replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd); static char* map_memory(int fd, const char* file_name, size_t file_offset, char *addr, size_t bytes, bool read_only = false, --- old/test/hotspot/jtreg/gc/TestAllocateHeapAt.java 2017-11-03 01:09:30.901755873 -0700 +++ new/test/hotspot/jtreg/gc/TestAllocateHeapAt.java 2017-11-03 01:09:30.627758038 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, xxx Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,10 +44,10 @@ Collections.addAll(vmOpts, testVmOpts); } String test_dir = System.getProperty("test.dir", "."); - Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt="+test_dir, + Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt=" + test_dir, "-Xlog:gc+heap=info", - "-Xmx50m", - "-Xms50m", + "-Xmx32m", + "-Xms32m", "-version"}); System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));