8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
Summary: Removed the code using unused flags.
Reviewed-by: dholmes, coleenp
--- a/src/hotspot/os/bsd/globals_bsd.hpp Fri Oct 26 22:58:04 2018 +0800
+++ b/src/hotspot/os/bsd/globals_bsd.hpp Fri Oct 26 10:47:05 2018 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -46,12 +46,6 @@
/* overridden in Arguments::parse_each_vm_init_arg. */ \
product(bool, UseBsdPosixThreadCPUClocks, true, \
"enable fast Bsd Posix clocks where available") \
- \
- product(bool, UseHugeTLBFS, false, \
- "Use MAP_HUGETLB for large pages") \
- \
- product(bool, UseSHM, false, \
- "Use SYSV shared memory for large pages")
//
// Defines Bsd-specific default values. The flags are available on all
--- a/src/hotspot/os/bsd/os_bsd.cpp Fri Oct 26 22:58:04 2018 +0800
+++ b/src/hotspot/os/bsd/os_bsd.cpp Fri Oct 26 10:47:05 2018 -0500
@@ -70,50 +70,38 @@
#include "utilities/vmError.hpp"
// put OS-includes here
-# include <sys/types.h>
-# include <sys/mman.h>
-# include <sys/stat.h>
-# include <sys/select.h>
-# include <pthread.h>
-# include <signal.h>
+# include <dlfcn.h>
# include <errno.h>
-# include <dlfcn.h>
+# include <fcntl.h>
+# include <inttypes.h>
+# include <poll.h>
+# include <pthread.h>
+# include <pwd.h>
+# include <signal.h>
+# include <stdint.h>
# include <stdio.h>
-# include <unistd.h>
+# include <string.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/param.h>
# include <sys/resource.h>
-# include <pthread.h>
+# include <sys/socket.h>
# include <sys/stat.h>
+# include <sys/syscall.h>
+# include <sys/sysctl.h>
# include <sys/time.h>
# include <sys/times.h>
-# include <sys/utsname.h>
-# include <sys/socket.h>
+# include <sys/types.h>
# include <sys/wait.h>
# include <time.h>
-# include <pwd.h>
-# include <poll.h>
-# include <fcntl.h>
-# include <string.h>
-# include <sys/param.h>
-# include <sys/sysctl.h>
-# include <sys/ipc.h>
-# include <sys/shm.h>
-#ifndef __APPLE__
-# include <link.h>
-#endif
-# include <stdint.h>
-# include <inttypes.h>
-# include <sys/ioctl.h>
-# include <sys/syscall.h>
+# include <unistd.h>
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include <elf.h>
#endif
#ifdef __APPLE__
- #include <mach/mach.h> // semaphore_* API
#include <mach-o/dyld.h>
- #include <sys/proc_info.h>
- #include <objc/objc-auto.h>
#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;
@@ -2116,95 +2102,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) {
--- a/src/hotspot/share/runtime/arguments.cpp Fri Oct 26 22:58:04 2018 +0800
+++ b/src/hotspot/share/runtime/arguments.cpp Fri Oct 26 10:47:05 2018 -0500
@@ -537,6 +537,11 @@
{ "CompilerThreadHintNoPreempt", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
{ "VMThreadHintNoPreempt", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
+#if defined(_ALLBSD_SOURCE)
+ { "UseSHM", JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) },
+ { "UseHugeTLBFS", JDK_Version::undefined(), JDK_Version::jdk(12), JDK_Version::jdk(13) },
+#endif
+
// --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
{ "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
{ "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },