< prev index next >

src/os/aix/vm/os_aix.hpp

Print this page
rev 7960 : 8075506: aix: improve handling of native memory
   1 /*
   2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2013 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef OS_AIX_VM_OS_AIX_HPP
  27 #define OS_AIX_VM_OS_AIX_HPP
  28 
  29 // Information about the protection of the page at address '0' on this os.
  30 static bool zero_page_read_protected() { return false; }
  31 
  32 // Class Aix defines the interface to the Aix operating systems.
  33 
  34 class Aix {
  35   friend class os;
  36 
  37   // For signal-chaining
  38   // highest so far (AIX 5.2) is SIGSAK (63)
  39 #define MAXSIGNUM 63
  40   // length of strings included in the libperfstat structures
  41 #define IDENTIFIER_LENGTH 64
  42 
  43   static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
  44   static unsigned int sigs;             // mask of signals that have
  45                                         // preinstalled signal handlers
  46   static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
  47                                         // __sigaction(), signal() is loaded
  48   static struct sigaction *(*get_signal_action)(int);
  49   static struct sigaction *get_preinstalled_handler(int);
  50   static void save_preinstalled_handler(int, struct sigaction&);
  51 
  52   static void check_signal_handler(int sig);
  53 
  54   // For signal flags diagnostics
  55   static int sigflags[MAXSIGNUM];
  56 
  57  protected:
  58 
  59   static julong _physical_memory;
  60   static pthread_t _main_thread;


  94   //  - Text - text code
  95   //  - shared memory
  96   //
  97   //  Default page sizes can be set via linker options (-bdatapsize, -bstacksize, ...)
  98   //  and via environment variable LDR_CNTRL (DATAPSIZE, STACKPSIZE, ...)
  99   //
 100   //  For shared memory, page size can be set dynamically via shmctl(). Different shared memory
 101   //  regions can have different page sizes.
 102   //
 103   //  More information can be found at AIBM info center:
 104   //   http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/multiple_page_size_app_support.htm
 105   //
 106   // -----
 107   //  We want to support 4K and 64K and, if the machine is set up correctly, 16MB pages.
 108   //
 109 
 110   // page size of the stack of newly created pthreads
 111   // (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib)
 112   static int _stack_page_size;
 113 
 114   // Default shm page size. Read: what page size shared memory will be backed
 115   // with if no page size was set explicitly using shmctl(SHM_PAGESIZE).
 116   // Should be LDR_CNTRL SHMPSIZE.
 117   static size_t _shm_default_page_size;
 118 
 119   // True if sys V shm can be used with 64K pages dynamically.
 120   // (via shmctl(.. SHM_PAGESIZE..). Should be true for AIX 53 and
 121   // newer / PASE V6R1 and newer. (0 or 1, -1 if not initialized)
 122   static int _can_use_64K_pages;
 123 
 124   // True if sys V shm can be used with 16M pages dynamically.
 125   // (via shmctl(.. SHM_PAGESIZE..). Only true on AIX 5.3 and
 126   // newer, if the system was set up to use 16M pages and the
 127   // jvm has enough user rights. (0 or 1, -1 if not initialized)
 128   static int _can_use_16M_pages;
 129 
 130   static julong available_memory();
 131   static julong physical_memory() { return _physical_memory; }
 132   static void initialize_system_info();
 133 
 134   // OS recognitions (PASE/AIX, OS level) call this before calling any
 135   // one of Aix::on_pase(), Aix::os_version().
 136   static void initialize_os_info();
 137 
 138   static int commit_memory_impl(char* addr, size_t bytes, bool exec);
 139   static int commit_memory_impl(char* addr, size_t bytes,
 140                                 size_t alignment_hint, bool exec);
 141 
 142   // Scan environment for important settings which might effect the
 143   // VM. Trace out settings. Warn about invalid settings and/or
 144   // correct them.
 145   //
 146   // Must run after os::Aix::initialue_os_info().
 147   static void scan_environment();
 148 
 149   // Retrieve information about multipage size support. Will initialize
 150   // _page_size, _stack_page_size, _can_use_64K_pages/_can_use_16M_pages
 151   static void query_multipage_support();
 152 
 153   // Initialize libo4 (on PASE) and libperfstat (on AIX). Call this
 154   // before relying on functions from either lib, e.g. Aix::get_meminfo().
 155   static void initialize_libo4();
 156   static void initialize_libperfstat();
 157 
 158   static bool supports_variable_stack_size();
 159 
 160  public:
 161   static void init_thread_fpu_state();
 162   static pthread_t main_thread(void)                                { return _main_thread; }
 163   // returns kernel thread id (similar to LWP id on Solaris), which can be
 164   // used to access /proc
 165   static pid_t gettid();
 166   static void set_createThread_lock(Mutex* lk)                      { _createThread_lock = lk; }
 167   static Mutex* createThread_lock(void)                             { return _createThread_lock; }
 168   static void hotspot_sigmask(Thread* thread);
 169 
 170   // Given an address, returns the size of the page backing that address
 171   static size_t query_pagesize(void* p);
 172 
 173   // Return `true' if the calling thread is the primordial thread. The
 174   // primordial thread is the thread which contains the main function,
 175   // *not* necessarily the thread which initialized the VM by calling
 176   // JNI_CreateJavaVM.
 177   static bool is_primordial_thread(void);
 178 
 179   static int page_size(void) {
 180     assert(_page_size != -1, "not initialized");
 181     return _page_size;
 182   }
 183 
 184   // Accessor methods for stack page size which may be different from usual page size.
 185   static int stack_page_size(void) {
 186     assert(_stack_page_size != -1, "not initialized");
 187     return _stack_page_size;
 188   }
 189 
 190   // default shm page size. Read: what page size shared memory
 191   // will be backed with if no page size was set explicitly using shmctl(SHM_PAGESIZE).
 192   // Should be LDR_CNTRL SHMPSIZE.
 193   static int shm_default_page_size(void) {
 194     assert(_shm_default_page_size != -1, "not initialized");
 195     return _shm_default_page_size;
 196   }
 197 
 198   // Return true if sys V shm can be used with 64K pages dynamically
 199   // (via shmctl(.. SHM_PAGESIZE..).
 200   static bool can_use_64K_pages () {
 201     assert(_can_use_64K_pages != -1,  "not initialized");
 202     return _can_use_64K_pages == 1 ? true : false;
 203   }
 204 
 205   // Return true if sys V shm can be used with 16M pages dynamically.
 206   // (via shmctl(.. SHM_PAGESIZE..).
 207   static bool can_use_16M_pages () {
 208     assert(_can_use_16M_pages != -1,  "not initialized");
 209     return _can_use_16M_pages == 1 ? true : false;
 210   }
 211 
 212   static address   ucontext_get_pc(const ucontext_t* uc);
 213   static intptr_t* ucontext_get_sp(ucontext_t* uc);
 214   static intptr_t* ucontext_get_fp(ucontext_t* uc);
 215   // Set PC into context. Needed for continuation after signal.
 216   static void ucontext_set_pc(ucontext_t* uc, address pc);
 217 
 218   // This boolean allows users to forward their own non-matching signals
 219   // to JVM_handle_aix_signal, harmlessly.
 220   static bool signal_handlers_are_installed;
 221 
 222   static int get_our_sigflags(int);
 223   static void set_our_sigflags(int, int);
 224   static void signal_sets_init();
 225   static void install_signal_handlers();
 226   static void set_signal_handler(int, bool);
 227   static bool is_sig_ignored(int sig);
 228 
 229   static sigset_t* unblocked_signals();
 230   static sigset_t* vm_signals();


 250   static bool on_pase() {
 251     assert(_on_pase != -1, "not initialized");
 252     return _on_pase ? true : false;
 253   }
 254 
 255   // Function returns true if we run on AIX, false if we run on OS/400
 256   // (pase).
 257   static bool on_aix() {
 258     assert(_on_pase != -1, "not initialized");
 259     return _on_pase ? false : true;
 260   }
 261 
 262   // -1 = uninitialized, otherwise 16 bit number:
 263   // lower 8 bit - minor version
 264   // higher 8 bit - major version
 265   // For AIX, e.g. 0x0601 for AIX 6.1
 266   // for OS/400 e.g. 0x0504 for OS/400 V5R4
 267   static int os_version () {
 268     assert(_os_version != -1, "not initialized");
 269     return _os_version;





 270   }
 271 
 272   // Convenience method: returns true if running on AIX 5.3 or older.
 273   static bool on_aix_53_or_older() {
 274     return on_aix() && os_version() <= 0x0503;
 275   }
 276 
 277   // Returns true if we run in SPEC1170 compliant mode (XPG_SUS_ENV=ON).
 278   static bool xpg_sus_mode() {
 279     assert(_xpg_sus_mode != -1, "not initialized");
 280     return _xpg_sus_mode;
 281   }
 282 
 283   // Returns true if EXTSHM=ON.
 284   static bool extshm() {
 285     assert(_extshm != -1, "not initialized");
 286     return _extshm;
 287   }
 288 
 289   // result struct for get_meminfo()


   1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2013, 2015 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef OS_AIX_VM_OS_AIX_HPP
  27 #define OS_AIX_VM_OS_AIX_HPP
  28 
  29 // Information about the protection of the page at address '0' on this os.
  30 static bool zero_page_read_protected() { return false; }
  31 
  32 // Class Aix defines the interface to the Aix operating systems.
  33 
  34 class Aix {
  35   friend class os;
  36 
  37   // For signal-chaining
  38   // highest so far (AIX 5.2 - 6.1) is SIGSAK (63)
  39 #define MAXSIGNUM 63
  40   // Length of strings included in the libperfstat structures.
  41 #define IDENTIFIER_LENGTH 64
  42 
  43   static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
  44   static unsigned int sigs;             // mask of signals that have
  45                                         // preinstalled signal handlers
  46   static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
  47                                         // __sigaction(), signal() is loaded
  48   static struct sigaction *(*get_signal_action)(int);
  49   static struct sigaction *get_preinstalled_handler(int);
  50   static void save_preinstalled_handler(int, struct sigaction&);
  51 
  52   static void check_signal_handler(int sig);
  53 
  54   // For signal flags diagnostics
  55   static int sigflags[MAXSIGNUM];
  56 
  57  protected:
  58 
  59   static julong _physical_memory;
  60   static pthread_t _main_thread;


  94   //  - Text - text code
  95   //  - shared memory
  96   //
  97   //  Default page sizes can be set via linker options (-bdatapsize, -bstacksize, ...)
  98   //  and via environment variable LDR_CNTRL (DATAPSIZE, STACKPSIZE, ...)
  99   //
 100   //  For shared memory, page size can be set dynamically via shmctl(). Different shared memory
 101   //  regions can have different page sizes.
 102   //
 103   //  More information can be found at AIBM info center:
 104   //   http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/multiple_page_size_app_support.htm
 105   //
 106   // -----
 107   //  We want to support 4K and 64K and, if the machine is set up correctly, 16MB pages.
 108   //
 109 
 110   // page size of the stack of newly created pthreads
 111   // (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib)
 112   static int _stack_page_size;
 113 
















 114   static julong available_memory();
 115   static julong physical_memory() { return _physical_memory; }
 116   static void initialize_system_info();
 117 
 118   // OS recognitions (PASE/AIX, OS level) call this before calling any
 119   // one of Aix::on_pase(), Aix::os_version().
 120   static void initialize_os_info();
 121 




 122   // Scan environment for important settings which might effect the
 123   // VM. Trace out settings. Warn about invalid settings and/or
 124   // correct them.
 125   //
 126   // Must run after os::Aix::initialue_os_info().
 127   static void scan_environment();
 128 




 129   // Initialize libo4 (on PASE) and libperfstat (on AIX). Call this
 130   // before relying on functions from either lib, e.g. Aix::get_meminfo().
 131   static void initialize_libo4();
 132   static void initialize_libperfstat();
 133 
 134   static bool supports_variable_stack_size();
 135 
 136  public:
 137   static void init_thread_fpu_state();
 138   static pthread_t main_thread(void)                                { return _main_thread; }
 139   // returns kernel thread id (similar to LWP id on Solaris), which can be
 140   // used to access /proc
 141   static pid_t gettid();
 142   static void set_createThread_lock(Mutex* lk)                      { _createThread_lock = lk; }
 143   static Mutex* createThread_lock(void)                             { return _createThread_lock; }
 144   static void hotspot_sigmask(Thread* thread);
 145 
 146   // Given an address, returns the size of the page backing that address
 147   static size_t query_pagesize(void* p);
 148 
 149   // Return `true' if the calling thread is the primordial thread. The
 150   // primordial thread is the thread which contains the main function,
 151   // *not* necessarily the thread which initialized the VM by calling
 152   // JNI_CreateJavaVM.
 153   static bool is_primordial_thread(void);
 154 
 155   static int page_size(void) {
 156     assert(_page_size != -1, "not initialized");
 157     return _page_size;
 158   }
 159 
 160   // Accessor methods for stack page size which may be different from usual page size.
 161   static int stack_page_size(void) {
 162     assert(_stack_page_size != -1, "not initialized");
 163     return _stack_page_size;
 164   }
 165 
 166   // This is used to scale stack space (guard pages etc.). The name is somehow misleading.
 167   static int vm_default_page_size(void ) { return 8*K; }



















 168 
 169   static address   ucontext_get_pc(const ucontext_t* uc);
 170   static intptr_t* ucontext_get_sp(ucontext_t* uc);
 171   static intptr_t* ucontext_get_fp(ucontext_t* uc);
 172   // Set PC into context. Needed for continuation after signal.
 173   static void ucontext_set_pc(ucontext_t* uc, address pc);
 174 
 175   // This boolean allows users to forward their own non-matching signals
 176   // to JVM_handle_aix_signal, harmlessly.
 177   static bool signal_handlers_are_installed;
 178 
 179   static int get_our_sigflags(int);
 180   static void set_our_sigflags(int, int);
 181   static void signal_sets_init();
 182   static void install_signal_handlers();
 183   static void set_signal_handler(int, bool);
 184   static bool is_sig_ignored(int sig);
 185 
 186   static sigset_t* unblocked_signals();
 187   static sigset_t* vm_signals();


 207   static bool on_pase() {
 208     assert(_on_pase != -1, "not initialized");
 209     return _on_pase ? true : false;
 210   }
 211 
 212   // Function returns true if we run on AIX, false if we run on OS/400
 213   // (pase).
 214   static bool on_aix() {
 215     assert(_on_pase != -1, "not initialized");
 216     return _on_pase ? false : true;
 217   }
 218 
 219   // -1 = uninitialized, otherwise 16 bit number:
 220   // lower 8 bit - minor version
 221   // higher 8 bit - major version
 222   // For AIX, e.g. 0x0601 for AIX 6.1
 223   // for OS/400 e.g. 0x0504 for OS/400 V5R4
 224   static int os_version () {
 225     assert(_os_version != -1, "not initialized");
 226     return _os_version;
 227   }
 228 
 229   // Convenience method: returns true if running on PASE V5R4 or older.
 230   static bool on_pase_V5R4_or_older() {
 231     return on_pase() && os_version() <= 0x0504;
 232   }
 233 
 234   // Convenience method: returns true if running on AIX 5.3 or older.
 235   static bool on_aix_53_or_older() {
 236     return on_aix() && os_version() <= 0x0503;
 237   }
 238 
 239   // Returns true if we run in SPEC1170 compliant mode (XPG_SUS_ENV=ON).
 240   static bool xpg_sus_mode() {
 241     assert(_xpg_sus_mode != -1, "not initialized");
 242     return _xpg_sus_mode;
 243   }
 244 
 245   // Returns true if EXTSHM=ON.
 246   static bool extshm() {
 247     assert(_extshm != -1, "not initialized");
 248     return _extshm;
 249   }
 250 
 251   // result struct for get_meminfo()


< prev index next >