--- old/src/hotspot/os/bsd/os_bsd.cpp 2018-10-22 11:22:11.000000000 -0500 +++ new/src/hotspot/os/bsd/os_bsd.cpp 2018-10-22 11:22:11.000000000 -0500 @@ -70,50 +70,38 @@ #include "utilities/vmError.hpp" // put OS-includes here -# include -# include -# include -# include +# include +# include +# include +# include +# include # include +# include # include -# include -# include +# include # include -# include +# include +# include +# include +# include # include -# include +# include # include +# include +# include # include # include -# include -# include +# include # include # include -# include -# include -# include -# include -# include -# include -# include -# include -#ifndef __APPLE__ -# include -#endif -# include -# include -# include -# include +# include #if defined(__FreeBSD__) || defined(__NetBSD__) #include #endif #ifdef __APPLE__ - #include // semaphore_* API #include - #include - #include #endif #ifndef MAP_ANONYMOUS @@ -125,8 +113,6 @@ // for timer info max values which include all bits #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) -#define LARGEPAGES_BIT (1 << 6) - //////////////////////////////////////////////////////////////////////////////// // global variables julong os::Bsd::_physical_memory = 0; @@ -2118,95 +2104,27 @@ char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) { - fatal("This code is not used or maintained."); - - // "exec" is passed in but not used. Creating the shared image for - // the code cache doesn't have an SHM_X executable permission to check. - assert(UseLargePages && UseSHM, "only for SHM large pages"); - - key_t key = IPC_PRIVATE; - char *addr; - - bool warn_on_failure = UseLargePages && - (!FLAG_IS_DEFAULT(UseLargePages) || - !FLAG_IS_DEFAULT(LargePageSizeInBytes)); - - // Create a large shared memory region to attach to based on size. - // Currently, size is the total size of the heap - int shmid = shmget(key, bytes, IPC_CREAT|SHM_R|SHM_W); - if (shmid == -1) { - // Possible reasons for shmget failure: - // 1. shmmax is too small for Java heap. - // > check shmmax value: cat /proc/sys/kernel/shmmax - // > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax - // 2. not enough large page memory. - // > check available large pages: cat /proc/meminfo - // > increase amount of large pages: - // echo new_value > /proc/sys/vm/nr_hugepages - // Note 1: different Bsd may use different name for this property, - // e.g. on Redhat AS-3 it is "hugetlb_pool". - // Note 2: it's possible there's enough physical memory available but - // they are so fragmented after a long run that they can't - // coalesce into large pages. Try to reserve large pages when - // the system is still "fresh". - if (warn_on_failure) { - warning("Failed to reserve shared memory (errno = %d).", errno); - } - return NULL; - } - - // attach to the region - addr = (char*)shmat(shmid, req_addr, 0); - int err = errno; - - // Remove shmid. If shmat() is successful, the actual shared memory segment - // will be deleted when it's detached by shmdt() or when the process - // terminates. If shmat() is not successful this will remove the shared - // segment immediately. - shmctl(shmid, IPC_RMID, NULL); - - if ((intptr_t)addr == -1) { - if (warn_on_failure) { - warning("Failed to attach shared memory (errno = %d).", err); - } - return NULL; - } - - // The memory is committed - MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, CALLER_PC); - - return addr; + fatal("os::reserve_memory_special should not be called on BSD."); + return NULL; } bool os::release_memory_special(char* base, size_t bytes) { - if (MemTracker::tracking_level() > NMT_minimal) { - Tracker tkr(Tracker::release); - // detaching the SHM segment will also delete it, see reserve_memory_special() - int rslt = shmdt(base); - if (rslt == 0) { - tkr.record((address)base, bytes); - return true; - } else { - return false; - } - } else { - return shmdt(base) == 0; - } + fatal("os::release_memory_special should not be called on BSD."); + return false; } size_t os::large_page_size() { return _large_page_size; } -// HugeTLBFS allows application to commit large page memory on demand; -// with SysV SHM the entire memory region must be allocated as shared -// memory. bool os::can_commit_large_page_memory() { - return UseHugeTLBFS; + // Does not matter, we do not support huge pages. + return false; } bool os::can_execute_large_page_memory() { - return UseHugeTLBFS; + // Does not matter, we do not support huge pages. + return false; } char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr, int file_desc) {