< prev index next >

src/os/aix/vm/os_aix.hpp

Print this page
rev 9422 : 8143125-Further Developments for AIX


  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   // Length of strings included in the libperfstat structures.
  38 #define IDENTIFIER_LENGTH 64
  39 
  40   static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
  41                                         // __sigaction(), signal() is loaded
  42   static struct sigaction *(*get_signal_action)(int);
  43   static struct sigaction *get_preinstalled_handler(int);
  44   static void save_preinstalled_handler(int, struct sigaction&);
  45 
  46   static void check_signal_handler(int sig);
  47 
  48  protected:
  49 
  50   static julong _physical_memory;
  51   static pthread_t _main_thread;
  52   static Mutex* _createThread_lock;
  53   static int _page_size;
  54   static int _logical_cpus;


  55 
  56   // -1 = uninitialized, 0 = AIX, 1 = OS/400 (PASE)
  57   static int _on_pase;
  58 
  59   // -1 = uninitialized, otherwise 16 bit number:
  60   //  lower 8 bit - minor version
  61   //  higher 8 bit - major version
  62   //  For AIX, e.g. 0x0601 for AIX 6.1
  63   //  for OS/400 e.g. 0x0504 for OS/400 V5R4
  64   static int _os_version;
  65 



  66   // -1 = uninitialized,
  67   //  0 - SPEC1170 not requested (XPG_SUS_ENV is OFF or not set)
  68   //  1 - SPEC1170 requested (XPG_SUS_ENV is ON)
  69   static int _xpg_sus_mode;
  70 
  71   // -1 = uninitialized,
  72   //  0 - EXTSHM=OFF or not set
  73   //  1 - EXTSHM=ON
  74   static int _extshm;
  75 
  76   // page sizes on AIX.
  77   //
  78   //  AIX supports four different page sizes - 4K, 64K, 16MB, 16GB. The latter two
  79   //  (16M "large" resp. 16G "huge" pages) require special setup and are normally
  80   //  not available.
  81   //
  82   //  AIX supports multiple page sizes per process, for:
  83   //  - Stack (of the primordial thread, so not relevant for us)
  84   //  - Data - data, bss, heap, for us also pthread stacks
  85   //  - Text - text code
  86   //  - shared memory
  87   //
  88   //  Default page sizes can be set via linker options (-bdatapsize, -bstacksize, ...)
  89   //  and via environment variable LDR_CNTRL (DATAPSIZE, STACKPSIZE, ...)
  90   //
  91   //  For shared memory, page size can be set dynamically via shmctl(). Different shared memory
  92   //  regions can have different page sizes.
  93   //
  94   //  More information can be found at AIBM info center:
  95   //   http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/multiple_page_size_app_support.htm
  96   //
  97   // -----
  98   //  We want to support 4K and 64K and, if the machine is set up correctly, 16MB pages.
  99   //
 100 
 101   // page size of the stack of newly created pthreads
 102   // (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib)
 103   static int _stack_page_size;
 104 
 105   static julong available_memory();
 106   static julong physical_memory() { return _physical_memory; }
 107   static void initialize_system_info();
 108 
 109   // OS recognitions (PASE/AIX, OS level) call this before calling any
 110   // one of Aix::on_pase(), Aix::os_version().
 111   static void initialize_os_info();
 112 
 113   // Scan environment for important settings which might effect the
 114   // VM. Trace out settings. Warn about invalid settings and/or
 115   // correct them.
 116   //
 117   // Must run after os::Aix::initialue_os_info().
 118   static void scan_environment();
 119 
 120   // Initialize libo4 (on PASE) and libperfstat (on AIX). Call this
 121   // before relying on functions from either lib, e.g. Aix::get_meminfo().
 122   static void initialize_libo4();
 123   static void initialize_libperfstat();
 124 
 125  public:
 126   static void init_thread_fpu_state();
 127   static pthread_t main_thread(void)                                { return _main_thread; }
 128   // returns kernel thread id (similar to LWP id on Solaris), which can be
 129   // used to access /proc
 130   static pid_t gettid();
 131   static void set_createThread_lock(Mutex* lk)                      { _createThread_lock = lk; }
 132   static Mutex* createThread_lock(void)                             { return _createThread_lock; }
 133   static void hotspot_sigmask(Thread* thread);
 134 
 135   // Given an address, returns the size of the page backing that address
 136   static size_t query_pagesize(void* p);
 137 
 138   // Return `true' if the calling thread is the primordial thread. The
 139   // primordial thread is the thread which contains the main function,
 140   // *not* necessarily the thread which initialized the VM by calling
 141   // JNI_CreateJavaVM.
 142   static bool is_primordial_thread(void);
 143 
 144   static int page_size(void) {
 145     assert(_page_size != -1, "not initialized");
 146     return _page_size;
 147   }
 148 
 149   // Accessor methods for stack page size which may be different from usual page size.
 150   static int stack_page_size(void) {


 198     return _on_pase ? true : false;
 199   }
 200 
 201   // Function returns true if we run on AIX, false if we run on OS/400
 202   // (pase).
 203   static bool on_aix() {
 204     assert(_on_pase != -1, "not initialized");
 205     return _on_pase ? false : true;
 206   }
 207 
 208   // -1 = uninitialized, otherwise 16 bit number:
 209   // lower 8 bit - minor version
 210   // higher 8 bit - major version
 211   // For AIX, e.g. 0x0601 for AIX 6.1
 212   // for OS/400 e.g. 0x0504 for OS/400 V5R4
 213   static int os_version () {
 214     assert(_os_version != -1, "not initialized");
 215     return _os_version;
 216   }
 217 








 218   // Convenience method: returns true if running on PASE V5R4 or older.
 219   static bool on_pase_V5R4_or_older() {
 220     return on_pase() && os_version() <= 0x0504;
 221   }
 222 
 223   // Convenience method: returns true if running on AIX 5.3 or older.
 224   static bool on_aix_53_or_older() {
 225     return on_aix() && os_version() <= 0x0503;
 226   }
 227 
 228   // Returns true if we run in SPEC1170 compliant mode (XPG_SUS_ENV=ON).
 229   static bool xpg_sus_mode() {
 230     assert(_xpg_sus_mode != -1, "not initialized");
 231     return _xpg_sus_mode;
 232   }
 233 
 234   // Returns true if EXTSHM=ON.
 235   static bool extshm() {
 236     assert(_extshm != -1, "not initialized");
 237     return _extshm;
 238   }
 239 







 240   // result struct for get_meminfo()
 241   struct meminfo_t {
 242 
 243     // Amount of virtual memory (in units of 4 KB pages)
 244     unsigned long long virt_total;
 245 
 246     // Amount of real memory, in bytes
 247     unsigned long long real_total;
 248 
 249     // Amount of free real memory, in bytes
 250     unsigned long long real_free;
 251 
 252     // Total amount of paging space, in bytes
 253     unsigned long long pgsp_total;
 254 
 255     // Amount of free paging space, in bytes
 256     unsigned long long pgsp_free;
 257 
 258   };
 259 
 260   // Result struct for get_cpuinfo().
 261   struct cpuinfo_t {
 262     char description[IDENTIFIER_LENGTH];  // processor description (type/official name)
 263     u_longlong_t processorHZ;             // processor speed in Hz
 264     int ncpus;                            // number of active logical processors
 265     double loadavg[3];                    // (1<<SBITS) times the average number of runnables processes during the last 1, 5 and 15 minutes.
 266                                           // To calculate the load average, divide the numbers by (1<<SBITS). SBITS is defined in <sys/proc.h>.
 267     char version[20];                     // processor version from _system_configuration (sys/systemcfg.h)
 268   };
 269 
 270   // Functions to retrieve memory information on AIX, PASE.
 271   // (on AIX, using libperfstat, on PASE with libo4.so).
 272   // Returns true if ok, false if error.
 273   static bool get_meminfo(meminfo_t* pmi);
 274 
 275   // Function to retrieve cpu information on AIX
 276   // (on AIX, using libperfstat)
 277   // Returns true if ok, false if error.
 278   static bool get_cpuinfo(cpuinfo_t* pci);












 279 
 280 }; // os::Aix class
 281 
 282 
 283 class PlatformEvent : public CHeapObj<mtInternal> {
 284   private:
 285     double CachePad [4];   // increase odds that _mutex is sole occupant of cache line
 286     volatile int _Event;
 287     volatile int _nParked;
 288     pthread_mutex_t _mutex  [1];
 289     pthread_cond_t  _cond   [1];
 290     double PostPad  [2];
 291     Thread * _Assoc;
 292 
 293   public:       // TODO-FIXME: make dtor private
 294     ~PlatformEvent() { guarantee (0, "invariant"); }
 295 
 296   public:
 297     PlatformEvent() {
 298       int status;
 299       status = pthread_cond_init (_cond, NULL);
 300       assert_status(status == 0, status, "cond_init");




  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   static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
  38                                         // __sigaction(), signal() is loaded
  39   static struct sigaction *(*get_signal_action)(int);
  40   static struct sigaction *get_preinstalled_handler(int);
  41   static void save_preinstalled_handler(int, struct sigaction&);
  42 
  43   static void check_signal_handler(int sig);
  44 
  45  private:
  46 
  47   static julong _physical_memory;
  48   static pthread_t _main_thread;
  49   static Mutex* _createThread_lock;
  50   static int _page_size;
  51 
  52   // Page size of newly created pthreads.
  53   static int _stack_page_size;
  54 
  55   // -1 = uninitialized, 0 = AIX, 1 = OS/400 (PASE)
  56   static int _on_pase;
  57 
  58   // -1 = uninitialized, otherwise 16 bit number:
  59   //  lower 8 bit - minor version
  60   //  higher 8 bit - major version
  61   //  For AIX, e.g. 0x0601 for AIX 6.1
  62   //  for OS/400 e.g. 0x0504 for OS/400 V5R4
  63   static int _os_version;
  64 
  65   // 4 Byte kernel version: Version, Release, Tech Level, Service Pack.
  66   static unsigned int _os_kernel_version;
  67 
  68   // -1 = uninitialized,
  69   //  0 - SPEC1170 not requested (XPG_SUS_ENV is OFF or not set)
  70   //  1 - SPEC1170 requested (XPG_SUS_ENV is ON)
  71   static int _xpg_sus_mode;
  72 
  73   // -1 = uninitialized,
  74   //  0 - EXTSHM=OFF or not set
  75   //  1 - EXTSHM=ON
  76   static int _extshm;
  77 





























  78   static julong available_memory();
  79   static julong physical_memory() { return _physical_memory; }
  80   static void initialize_system_info();
  81 
  82   // OS recognitions (PASE/AIX, OS level) call this before calling any
  83   // one of Aix::on_pase(), Aix::os_version().
  84   static void initialize_os_info();
  85 
  86   // Scan environment for important settings which might effect the
  87   // VM. Trace out settings. Warn about invalid settings and/or
  88   // correct them.
  89   //
  90   // Must run after os::Aix::initialue_os_info().
  91   static void scan_environment();
  92 
  93   // Initialize libo4 (on PASE) and libperfstat (on AIX). Call this
  94   // before relying on functions from either lib, e.g. Aix::get_meminfo().
  95   static void initialize_libo4();
  96   static void initialize_libperfstat();
  97 
  98  public:
  99   static void init_thread_fpu_state();
 100   static pthread_t main_thread(void)                                { return _main_thread; }



 101   static void set_createThread_lock(Mutex* lk)                      { _createThread_lock = lk; }
 102   static Mutex* createThread_lock(void)                             { return _createThread_lock; }
 103   static void hotspot_sigmask(Thread* thread);
 104 
 105   // Given an address, returns the size of the page backing that address
 106   static size_t query_pagesize(void* p);
 107 
 108   // Return `true' if the calling thread is the primordial thread. The
 109   // primordial thread is the thread which contains the main function,
 110   // *not* necessarily the thread which initialized the VM by calling
 111   // JNI_CreateJavaVM.
 112   static bool is_primordial_thread(void);
 113 
 114   static int page_size(void) {
 115     assert(_page_size != -1, "not initialized");
 116     return _page_size;
 117   }
 118 
 119   // Accessor methods for stack page size which may be different from usual page size.
 120   static int stack_page_size(void) {


 168     return _on_pase ? true : false;
 169   }
 170 
 171   // Function returns true if we run on AIX, false if we run on OS/400
 172   // (pase).
 173   static bool on_aix() {
 174     assert(_on_pase != -1, "not initialized");
 175     return _on_pase ? false : true;
 176   }
 177 
 178   // -1 = uninitialized, otherwise 16 bit number:
 179   // lower 8 bit - minor version
 180   // higher 8 bit - major version
 181   // For AIX, e.g. 0x0601 for AIX 6.1
 182   // for OS/400 e.g. 0x0504 for OS/400 V5R4
 183   static int os_version () {
 184     assert(_os_version != -1, "not initialized");
 185     return _os_version;
 186   }
 187 
 188   // Get 4 byte AIX kernel version number:
 189   // highest 2 bytes: Version, Release
 190   // if available: lowest 2 bytes: Tech Level, Service Pack.
 191   static unsigned int os_kernel_version() {
 192     if (_os_kernel_version) return _os_kernel_version;
 193     return os_version() << 16;
 194   }
 195 
 196   // Convenience method: returns true if running on PASE V5R4 or older.
 197   static bool on_pase_V5R4_or_older() {
 198     return on_pase() && os_version() <= 0x0504;
 199   }
 200 
 201   // Convenience method: returns true if running on AIX 5.3 or older.
 202   static bool on_aix_53_or_older() {
 203     return on_aix() && os_version() <= 0x0503;
 204   }
 205 
 206   // Returns true if we run in SPEC1170 compliant mode (XPG_SUS_ENV=ON).
 207   static bool xpg_sus_mode() {
 208     assert(_xpg_sus_mode != -1, "not initialized");
 209     return _xpg_sus_mode;
 210   }
 211 
 212   // Returns true if EXTSHM=ON.
 213   static bool extshm() {
 214     assert(_extshm != -1, "not initialized");
 215     return _extshm;
 216   }
 217 
 218   // Process break recorded at VM startup.
 219   static address get_brk_at_startup();
 220 
 221   // Address closest to process break allocated with os::reserve_memory
 222   // and friends (to see whether we are encrouching upon the process break).
 223   static address get_lowest_allocation_above_brk();
 224 
 225   // result struct for get_meminfo()
 226   struct meminfo_t {
 227 
 228     // Amount of virtual memory (in units of 4 KB pages)
 229     unsigned long long virt_total;
 230 
 231     // Amount of real memory, in bytes
 232     unsigned long long real_total;
 233 
 234     // Amount of free real memory, in bytes
 235     unsigned long long real_free;
 236 
 237     // Total amount of paging space, in bytes
 238     unsigned long long pgsp_total;
 239 
 240     // Amount of free paging space, in bytes
 241     unsigned long long pgsp_free;
 242 
 243   };
 244 










 245   // Functions to retrieve memory information on AIX, PASE.
 246   // (on AIX, using libperfstat, on PASE with libo4.so).
 247   // Returns true if ok, false if error.
 248   static bool get_meminfo(meminfo_t* pmi);
 249 
 250   // PASE: Function to parse a QSYS.LIB path and to extract library name, object name, object type
 251   // e.g. : /QSYS.LIB/TOMLIB.LIB/A.PGM -> TOMLIB, A, *PGM
 252   // Also handles IASP specs (by quietly swallowing them)
 253   // Notes:
 254   //  returned names are always uppercase. Case of input path does not matter.
 255   #define MAX_AS400_OBJNAME_LEN 10
 256   #define MAX_AS400_IASP_NAME_LEN   MAX_AS400_OBJNAME_LEN
 257   #define MAX_AS400_LIB_NAME_LEN    MAX_AS400_OBJNAME_LEN
 258   #define MAX_AS400_OBJTYPE_LEN 10
 259   static bool parse_qsyslib_path(
 260     const char* path,
 261     char lib [MAX_AS400_LIB_NAME_LEN + 1],
 262     char obj [MAX_AS400_OBJNAME_LEN + 1],
 263     char type [MAX_AS400_OBJTYPE_LEN + 1],
 264     int* hint = NULL
 265   );
 266 
 267 };
 268 
 269 
 270 class PlatformEvent : public CHeapObj<mtInternal> {
 271   private:
 272     double CachePad [4];   // increase odds that _mutex is sole occupant of cache line
 273     volatile int _Event;
 274     volatile int _nParked;
 275     pthread_mutex_t _mutex  [1];
 276     pthread_cond_t  _cond   [1];
 277     double PostPad  [2];
 278     Thread * _Assoc;
 279 
 280   public:       // TODO-FIXME: make dtor private
 281     ~PlatformEvent() { guarantee (0, "invariant"); }
 282 
 283   public:
 284     PlatformEvent() {
 285       int status;
 286       status = pthread_cond_init (_cond, NULL);
 287       assert_status(status == 0, status, "cond_init");


< prev index next >