mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8017061: os_bsd.cpp contains code for UseSHM and UseHugeTLBFS
Removed the code using unused flags. Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
ae77ef7d7a
commit
0108d754d7
3 changed files with 32 additions and 115 deletions
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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. */ \
|
/* overridden in Arguments::parse_each_vm_init_arg. */ \
|
||||||
product(bool, UseBsdPosixThreadCPUClocks, true, \
|
product(bool, UseBsdPosixThreadCPUClocks, true, \
|
||||||
"enable fast Bsd Posix clocks where available") \
|
"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
|
// Defines Bsd-specific default values. The flags are available on all
|
||||||
|
|
|
@ -70,50 +70,38 @@
|
||||||
#include "utilities/vmError.hpp"
|
#include "utilities/vmError.hpp"
|
||||||
|
|
||||||
// put OS-includes here
|
// 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 <errno.h>
|
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
# include <stdio.h>
|
# include <errno.h>
|
||||||
# include <unistd.h>
|
# include <fcntl.h>
|
||||||
# include <sys/resource.h>
|
# include <inttypes.h>
|
||||||
|
# include <poll.h>
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
|
# include <pwd.h>
|
||||||
|
# include <signal.h>
|
||||||
|
# include <stdint.h>
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <string.h>
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
# include <sys/mman.h>
|
||||||
|
# include <sys/param.h>
|
||||||
|
# include <sys/resource.h>
|
||||||
|
# include <sys/socket.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
|
# include <sys/syscall.h>
|
||||||
|
# include <sys/sysctl.h>
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
# include <sys/times.h>
|
# include <sys/times.h>
|
||||||
# include <sys/utsname.h>
|
# include <sys/types.h>
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <sys/wait.h>
|
# include <sys/wait.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
# include <pwd.h>
|
# include <unistd.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>
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <mach/mach.h> // semaphore_* API
|
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#include <sys/proc_info.h>
|
|
||||||
#include <objc/objc-auto.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAP_ANONYMOUS
|
#ifndef MAP_ANONYMOUS
|
||||||
|
@ -125,8 +113,6 @@
|
||||||
// for timer info max values which include all bits
|
// for timer info max values which include all bits
|
||||||
#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
|
#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
|
||||||
|
|
||||||
#define LARGEPAGES_BIT (1 << 6)
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// global variables
|
// global variables
|
||||||
julong os::Bsd::_physical_memory = 0;
|
julong os::Bsd::_physical_memory = 0;
|
||||||
|
@ -2116,95 +2102,27 @@ void os::large_page_init() {
|
||||||
|
|
||||||
|
|
||||||
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
|
||||||
fatal("This code is not used or maintained.");
|
fatal("os::reserve_memory_special should not be called on BSD.");
|
||||||
|
return NULL;
|
||||||
// "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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::release_memory_special(char* base, size_t bytes) {
|
bool os::release_memory_special(char* base, size_t bytes) {
|
||||||
if (MemTracker::tracking_level() > NMT_minimal) {
|
fatal("os::release_memory_special should not be called on BSD.");
|
||||||
Tracker tkr(Tracker::release);
|
return false;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t os::large_page_size() {
|
size_t os::large_page_size() {
|
||||||
return _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() {
|
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() {
|
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) {
|
char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr, int file_desc) {
|
||||||
|
|
|
@ -537,6 +537,11 @@ static SpecialFlag const special_jvm_flags[] = {
|
||||||
{ "CompilerThreadHintNoPreempt", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
|
{ "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) },
|
{ "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:
|
// --- 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() },
|
{ "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
{ "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
|
{ "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue