Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/aix/vm/os_aix.hpp
32284 views
/*1* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.2* Copyright 2013 SAP AG. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef OS_AIX_VM_OS_AIX_HPP26#define OS_AIX_VM_OS_AIX_HPP2728// Information about the protection of the page at address '0' on this os.29static bool zero_page_read_protected() { return false; }3031// Class Aix defines the interface to the Aix operating systems.3233class Aix {34friend class os;3536// For signal-chaining37// highest so far (AIX 5.2) is SIGSAK (63)38#define MAXSIGNUM 6339// length of strings included in the libperfstat structures40#define IDENTIFIER_LENGTH 644142static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions43static unsigned int sigs; // mask of signals that have44// preinstalled signal handlers45static bool libjsig_is_loaded; // libjsig that interposes sigaction(),46// __sigaction(), signal() is loaded47static struct sigaction *(*get_signal_action)(int);48static struct sigaction *get_preinstalled_handler(int);49static void save_preinstalled_handler(int, struct sigaction&);5051static void check_signal_handler(int sig);5253// For signal flags diagnostics54static int sigflags[MAXSIGNUM];5556protected:5758static julong _physical_memory;59static pthread_t _main_thread;60static Mutex* _createThread_lock;61static int _page_size;62static int _logical_cpus;6364// -1 = uninitialized, 0 = AIX, 1 = OS/400 (PASE)65static int _on_pase;6667// -1 = uninitialized, otherwise 16 bit number:68// lower 8 bit - minor version69// higher 8 bit - major version70// For AIX, e.g. 0x0601 for AIX 6.171// for OS/400 e.g. 0x0504 for OS/400 V5R472static int _os_version;7374// -1 = uninitialized,75// 0 - SPEC1170 not requested (XPG_SUS_ENV is OFF or not set)76// 1 - SPEC1170 requested (XPG_SUS_ENV is ON)77static int _xpg_sus_mode;7879// -1 = uninitialized,80// 0 - EXTSHM=OFF or not set81// 1 - EXTSHM=ON82static int _extshm;8384// page sizes on AIX.85//86// AIX supports four different page sizes - 4K, 64K, 16MB, 16GB. The latter two87// (16M "large" resp. 16G "huge" pages) require special setup and are normally88// not available.89//90// AIX supports multiple page sizes per process, for:91// - Stack (of the primordial thread, so not relevant for us)92// - Data - data, bss, heap, for us also pthread stacks93// - Text - text code94// - shared memory95//96// Default page sizes can be set via linker options (-bdatapsize, -bstacksize, ...)97// and via environment variable LDR_CNTRL (DATAPSIZE, STACKPSIZE, ...)98//99// For shared memory, page size can be set dynamically via shmctl(). Different shared memory100// regions can have different page sizes.101//102// More information can be found at AIBM info center:103// http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/multiple_page_size_app_support.htm104//105// -----106// We want to support 4K and 64K and, if the machine is set up correctly, 16MB pages.107//108109// page size of the stack of newly created pthreads110// (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib)111static int _stack_page_size;112113// Default shm page size. Read: what page size shared memory will be backed114// with if no page size was set explicitly using shmctl(SHM_PAGESIZE).115// Should be LDR_CNTRL SHMPSIZE.116static size_t _shm_default_page_size;117118// True if sys V shm can be used with 64K pages dynamically.119// (via shmctl(.. SHM_PAGESIZE..). Should be true for AIX 53 and120// newer / PASE V6R1 and newer. (0 or 1, -1 if not initialized)121static int _can_use_64K_pages;122123// True if sys V shm can be used with 16M pages dynamically.124// (via shmctl(.. SHM_PAGESIZE..). Only true on AIX 5.3 and125// newer, if the system was set up to use 16M pages and the126// jvm has enough user rights. (0 or 1, -1 if not initialized)127static int _can_use_16M_pages;128129static julong available_memory();130static julong physical_memory() { return _physical_memory; }131static void initialize_system_info();132133// OS recognitions (PASE/AIX, OS level) call this before calling any134// one of Aix::on_pase(), Aix::os_version().135static void initialize_os_info();136137static int commit_memory_impl(char* addr, size_t bytes, bool exec);138static int commit_memory_impl(char* addr, size_t bytes,139size_t alignment_hint, bool exec);140141// Scan environment for important settings which might effect the142// VM. Trace out settings. Warn about invalid settings and/or143// correct them.144//145// Must run after os::Aix::initialue_os_info().146static void scan_environment();147148// Retrieve information about multipage size support. Will initialize149// _page_size, _stack_page_size, _can_use_64K_pages/_can_use_16M_pages150static void query_multipage_support();151152// Initialize libo4 (on PASE) and libperfstat (on AIX). Call this153// before relying on functions from either lib, e.g. Aix::get_meminfo().154static void initialize_libo4();155static void initialize_libperfstat();156157static bool supports_variable_stack_size();158159public:160static void init_thread_fpu_state();161static pthread_t main_thread(void) { return _main_thread; }162// returns kernel thread id (similar to LWP id on Solaris), which can be163// used to access /proc164static pid_t gettid();165static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }166static Mutex* createThread_lock(void) { return _createThread_lock; }167static void hotspot_sigmask(Thread* thread);168169// Given an address, returns the size of the page backing that address170static size_t query_pagesize(void* p);171172static int page_size(void) {173assert(_page_size != -1, "not initialized");174return _page_size;175}176177// Accessor methods for stack page size which may be different from usual page size.178static int stack_page_size(void) {179assert(_stack_page_size != -1, "not initialized");180return _stack_page_size;181}182183// default shm page size. Read: what page size shared memory184// will be backed with if no page size was set explicitly using shmctl(SHM_PAGESIZE).185// Should be LDR_CNTRL SHMPSIZE.186static int shm_default_page_size(void) {187assert(_shm_default_page_size != -1, "not initialized");188return _shm_default_page_size;189}190191// Return true if sys V shm can be used with 64K pages dynamically192// (via shmctl(.. SHM_PAGESIZE..).193static bool can_use_64K_pages () {194assert(_can_use_64K_pages != -1, "not initialized");195return _can_use_64K_pages == 1 ? true : false;196}197198// Return true if sys V shm can be used with 16M pages dynamically.199// (via shmctl(.. SHM_PAGESIZE..).200static bool can_use_16M_pages () {201assert(_can_use_16M_pages != -1, "not initialized");202return _can_use_16M_pages == 1 ? true : false;203}204205static address ucontext_get_pc(const ucontext_t* uc);206static intptr_t* ucontext_get_sp(ucontext_t* uc);207static intptr_t* ucontext_get_fp(ucontext_t* uc);208// Set PC into context. Needed for continuation after signal.209static void ucontext_set_pc(ucontext_t* uc, address pc);210211// This boolean allows users to forward their own non-matching signals212// to JVM_handle_aix_signal, harmlessly.213static bool signal_handlers_are_installed;214215static int get_our_sigflags(int);216static void set_our_sigflags(int, int);217static void signal_sets_init();218static void install_signal_handlers();219static void set_signal_handler(int, bool);220static bool is_sig_ignored(int sig);221222static sigset_t* unblocked_signals();223static sigset_t* vm_signals();224static sigset_t* allowdebug_blocked_signals();225226// For signal-chaining227static struct sigaction *get_chained_signal_action(int sig);228static bool chained_handler(int sig, siginfo_t* siginfo, void* context);229230// libpthread version string231static void libpthread_init();232233// Minimum stack size a thread can be created with (allowing234// the VM to completely create the thread and enter user code)235static size_t min_stack_allowed;236237// Return default stack size or guard size for the specified thread type238static size_t default_stack_size(os::ThreadType thr_type);239static size_t default_guard_size(os::ThreadType thr_type);240241// Function returns true if we run on OS/400 (pase), false if we run242// on AIX.243static bool on_pase() {244assert(_on_pase != -1, "not initialized");245return _on_pase ? true : false;246}247248// Function returns true if we run on AIX, false if we run on OS/400249// (pase).250static bool on_aix() {251assert(_on_pase != -1, "not initialized");252return _on_pase ? false : true;253}254255// -1 = uninitialized, otherwise 16 bit number:256// lower 8 bit - minor version257// higher 8 bit - major version258// For AIX, e.g. 0x0601 for AIX 6.1259// for OS/400 e.g. 0x0504 for OS/400 V5R4260static int os_version () {261assert(_os_version != -1, "not initialized");262return _os_version;263}264265// Convenience method: returns true if running on AIX 5.3 or older.266static bool on_aix_53_or_older() {267return on_aix() && os_version() <= 0x0503;268}269270// Returns true if we run in SPEC1170 compliant mode (XPG_SUS_ENV=ON).271static bool xpg_sus_mode() {272assert(_xpg_sus_mode != -1, "not initialized");273return _xpg_sus_mode;274}275276// Returns true if EXTSHM=ON.277static bool extshm() {278assert(_extshm != -1, "not initialized");279return _extshm;280}281282// result struct for get_meminfo()283struct meminfo_t {284285// Amount of virtual memory (in units of 4 KB pages)286unsigned long long virt_total;287288// Amount of real memory, in bytes289unsigned long long real_total;290291// Amount of free real memory, in bytes292unsigned long long real_free;293294// Total amount of paging space, in bytes295unsigned long long pgsp_total;296297// Amount of free paging space, in bytes298unsigned long long pgsp_free;299300};301302// Result struct for get_cpuinfo().303struct cpuinfo_t {304char description[IDENTIFIER_LENGTH]; // processor description (type/official name)305u_longlong_t processorHZ; // processor speed in Hz306int ncpus; // number of active logical processors307double loadavg[3]; // (1<<SBITS) times the average number of runnables processes during the last 1, 5 and 15 minutes.308// To calculate the load average, divide the numbers by (1<<SBITS). SBITS is defined in <sys/proc.h>.309char version[20]; // processor version from _system_configuration (sys/systemcfg.h)310};311312// Functions to retrieve memory information on AIX, PASE.313// (on AIX, using libperfstat, on PASE with libo4.so).314// Returns true if ok, false if error.315static bool get_meminfo(meminfo_t* pmi);316317// Function to retrieve cpu information on AIX318// (on AIX, using libperfstat)319// Returns true if ok, false if error.320static bool get_cpuinfo(cpuinfo_t* pci);321322}; // os::Aix class323324325class PlatformEvent : public CHeapObj<mtInternal> {326private:327double CachePad [4]; // increase odds that _mutex is sole occupant of cache line328volatile int _Event;329volatile int _nParked;330pthread_mutex_t _mutex [1];331pthread_cond_t _cond [1];332double PostPad [2];333Thread * _Assoc;334335public: // TODO-FIXME: make dtor private336~PlatformEvent() { guarantee (0, "invariant"); }337338public:339PlatformEvent() {340int status;341status = pthread_cond_init (_cond, NULL);342assert_status(status == 0, status, "cond_init");343status = pthread_mutex_init (_mutex, NULL);344assert_status(status == 0, status, "mutex_init");345_Event = 0;346_nParked = 0;347_Assoc = NULL;348}349350// Use caution with reset() and fired() -- they may require MEMBARs351void reset() { _Event = 0; }352int fired() { return _Event; }353void park ();354void unpark ();355int TryPark ();356int park (jlong millis);357void SetAssociation (Thread * a) { _Assoc = a; }358};359360class PlatformParker : public CHeapObj<mtInternal> {361protected:362pthread_mutex_t _mutex [1];363pthread_cond_t _cond [1];364365public: // TODO-FIXME: make dtor private366~PlatformParker() { guarantee (0, "invariant"); }367368public:369PlatformParker() {370int status;371status = pthread_cond_init (_cond, NULL);372assert_status(status == 0, status, "cond_init");373status = pthread_mutex_init (_mutex, NULL);374assert_status(status == 0, status, "mutex_init");375}376};377378#endif // OS_AIX_VM_OS_AIX_HPP379380381