< prev index next >

src/os/aix/vm/os_aix.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2014 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.


 393     guarantee(p != NULL, "malloc failed");
 394     data_page_size = os::Aix::query_pagesize(p);
 395     ::free(p);
 396   }
 397 
 398   // query default shm page size (LDR_CNTRL SHMPSIZE)
 399   {
 400     const int shmid = ::shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR | S_IWUSR);
 401     guarantee(shmid != -1, "shmget failed");
 402     void* p = ::shmat(shmid, NULL, 0);
 403     ::shmctl(shmid, IPC_RMID, NULL);
 404     guarantee(p != (void*) -1, "shmat failed");
 405     _shm_default_page_size = os::Aix::query_pagesize(p);
 406     ::shmdt(p);
 407   }
 408 
 409   // before querying the stack page size, make sure we are not running as primordial
 410   // thread (because primordial thread's stack may have different page size than
 411   // pthread thread stacks). Running a VM on the primordial thread won't work for a
 412   // number of reasons so we may just as well guarantee it here
 413   guarantee(!os::Aix::is_primordial_thread(), "Must not be called for primordial thread");
 414 
 415   // query stack page size
 416   {
 417     int dummy = 0;
 418     _stack_page_size = os::Aix::query_pagesize(&dummy);
 419     // everything else would surprise me and should be looked into
 420     guarantee(_stack_page_size == SIZE_4K || _stack_page_size == SIZE_64K, "Wrong page size");
 421     // also, just for completeness: pthread stacks are allocated from C heap, so
 422     // stack page size should be the same as data page size
 423     guarantee(_stack_page_size == data_page_size, "stack page size should be the same as data page size");
 424   }
 425 
 426   // EXTSHM is bad: among other things, it prevents setting pagesize dynamically
 427   // for system V shm.
 428   if (Aix::extshm()) {
 429     if (Verbose) {
 430       fprintf(stderr, "EXTSHM is active - will disable large page support.\n"
 431                       "Please make sure EXTSHM is OFF for large page support.\n");
 432     }
 433     g_multipage_error = ERROR_MP_EXTSHM_ACTIVE;


3818 
3819   // debug trace
3820   if (Verbose) {
3821     fprintf(stderr, "os::vm_page_size 0x%llX\n", os::vm_page_size());
3822     fprintf(stderr, "os::large_page_size 0x%llX\n", os::large_page_size());
3823     fprintf(stderr, "os::_page_sizes = ( ");
3824     for (int i = 0; _page_sizes[i]; i ++) {
3825       fprintf(stderr, " %s ", describe_pagesize(_page_sizes[i]));
3826     }
3827     fprintf(stderr, ")\n");
3828   }
3829 
3830   _initial_pid = getpid();
3831 
3832   clock_tics_per_sec = sysconf(_SC_CLK_TCK);
3833 
3834   init_random(1234567);
3835 
3836   ThreadCritical::initialize();
3837 
3838   // Main_thread points to the aboriginal thread.
3839   Aix::_main_thread = pthread_self();
3840 
3841   initial_time_count = os::elapsed_counter();
3842   pthread_mutex_init(&dl_mutex, NULL);
3843 }
3844 
3845 // This is called _after_ the global arguments have been parsed.
3846 jint os::init_2(void) {
3847 
3848   trcVerbose("processor count: %d", os::_processor_count);
3849   trcVerbose("physical memory: %lu", Aix::_physical_memory);
3850 
3851   // Initially build up the loaded dll map.
3852   LoadedLibraries::reload();
3853 
3854   const int page_size = Aix::page_size();
3855   const int map_size = page_size;
3856 
3857   address map_address = (address) MAP_FAILED;
3858   const int prot  = PROT_READ;


4494   char filename[MAX_PATH];
4495   if (PauseAtStartupFile && PauseAtStartupFile[0]) {
4496     jio_snprintf(filename, MAX_PATH, PauseAtStartupFile);
4497   } else {
4498     jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
4499   }
4500 
4501   int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
4502   if (fd != -1) {
4503     struct stat buf;
4504     ::close(fd);
4505     while (::stat(filename, &buf) == 0) {
4506       (void)::poll(NULL, 0, 100);
4507     }
4508   } else {
4509     jio_fprintf(stderr,
4510       "Could not open pause file '%s', continuing immediately.\n", filename);
4511   }
4512 }
4513 
4514 bool os::Aix::is_primordial_thread() {
4515   if (pthread_self() == (pthread_t)1) {
4516     return true;
4517   } else {
4518     return false;
4519   }
4520 }
4521 
4522 // OS recognitions (PASE/AIX, OS level) call this before calling any
4523 // one of Aix::on_pase(), Aix::os_version() static
4524 void os::Aix::initialize_os_info() {
4525 
4526   assert(_on_pase == -1 && _os_version == -1, "already called.");
4527 
4528   struct utsname uts;
4529   memset(&uts, 0, sizeof(uts));
4530   strcpy(uts.sysname, "?");
4531   if (::uname(&uts) == -1) {
4532     trc("uname failed (%d)", errno);
4533     guarantee(0, "Could not determine whether we run on AIX or PASE");
4534   } else {


   1 /*
   2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2014 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.


 393     guarantee(p != NULL, "malloc failed");
 394     data_page_size = os::Aix::query_pagesize(p);
 395     ::free(p);
 396   }
 397 
 398   // query default shm page size (LDR_CNTRL SHMPSIZE)
 399   {
 400     const int shmid = ::shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR | S_IWUSR);
 401     guarantee(shmid != -1, "shmget failed");
 402     void* p = ::shmat(shmid, NULL, 0);
 403     ::shmctl(shmid, IPC_RMID, NULL);
 404     guarantee(p != (void*) -1, "shmat failed");
 405     _shm_default_page_size = os::Aix::query_pagesize(p);
 406     ::shmdt(p);
 407   }
 408 
 409   // before querying the stack page size, make sure we are not running as primordial
 410   // thread (because primordial thread's stack may have different page size than
 411   // pthread thread stacks). Running a VM on the primordial thread won't work for a
 412   // number of reasons so we may just as well guarantee it here
 413   guarantee(!os::is_primordial_thread(), "Must not be called for primordial thread");
 414 
 415   // query stack page size
 416   {
 417     int dummy = 0;
 418     _stack_page_size = os::Aix::query_pagesize(&dummy);
 419     // everything else would surprise me and should be looked into
 420     guarantee(_stack_page_size == SIZE_4K || _stack_page_size == SIZE_64K, "Wrong page size");
 421     // also, just for completeness: pthread stacks are allocated from C heap, so
 422     // stack page size should be the same as data page size
 423     guarantee(_stack_page_size == data_page_size, "stack page size should be the same as data page size");
 424   }
 425 
 426   // EXTSHM is bad: among other things, it prevents setting pagesize dynamically
 427   // for system V shm.
 428   if (Aix::extshm()) {
 429     if (Verbose) {
 430       fprintf(stderr, "EXTSHM is active - will disable large page support.\n"
 431                       "Please make sure EXTSHM is OFF for large page support.\n");
 432     }
 433     g_multipage_error = ERROR_MP_EXTSHM_ACTIVE;


3818 
3819   // debug trace
3820   if (Verbose) {
3821     fprintf(stderr, "os::vm_page_size 0x%llX\n", os::vm_page_size());
3822     fprintf(stderr, "os::large_page_size 0x%llX\n", os::large_page_size());
3823     fprintf(stderr, "os::_page_sizes = ( ");
3824     for (int i = 0; _page_sizes[i]; i ++) {
3825       fprintf(stderr, " %s ", describe_pagesize(_page_sizes[i]));
3826     }
3827     fprintf(stderr, ")\n");
3828   }
3829 
3830   _initial_pid = getpid();
3831 
3832   clock_tics_per_sec = sysconf(_SC_CLK_TCK);
3833 
3834   init_random(1234567);
3835 
3836   ThreadCritical::initialize();
3837 
3838   // _main_thread points to the thread that created/loaded the JVM.
3839   Aix::_main_thread = pthread_self();
3840 
3841   initial_time_count = os::elapsed_counter();
3842   pthread_mutex_init(&dl_mutex, NULL);
3843 }
3844 
3845 // This is called _after_ the global arguments have been parsed.
3846 jint os::init_2(void) {
3847 
3848   trcVerbose("processor count: %d", os::_processor_count);
3849   trcVerbose("physical memory: %lu", Aix::_physical_memory);
3850 
3851   // Initially build up the loaded dll map.
3852   LoadedLibraries::reload();
3853 
3854   const int page_size = Aix::page_size();
3855   const int map_size = page_size;
3856 
3857   address map_address = (address) MAP_FAILED;
3858   const int prot  = PROT_READ;


4494   char filename[MAX_PATH];
4495   if (PauseAtStartupFile && PauseAtStartupFile[0]) {
4496     jio_snprintf(filename, MAX_PATH, PauseAtStartupFile);
4497   } else {
4498     jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
4499   }
4500 
4501   int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
4502   if (fd != -1) {
4503     struct stat buf;
4504     ::close(fd);
4505     while (::stat(filename, &buf) == 0) {
4506       (void)::poll(NULL, 0, 100);
4507     }
4508   } else {
4509     jio_fprintf(stderr,
4510       "Could not open pause file '%s', continuing immediately.\n", filename);
4511   }
4512 }
4513 
4514 bool os::is_primordial_thread(void) {
4515   if (pthread_self() == (pthread_t)1) {
4516     return true;
4517   } else {
4518     return false;
4519   }
4520 }
4521 
4522 // OS recognitions (PASE/AIX, OS level) call this before calling any
4523 // one of Aix::on_pase(), Aix::os_version() static
4524 void os::Aix::initialize_os_info() {
4525 
4526   assert(_on_pase == -1 && _os_version == -1, "already called.");
4527 
4528   struct utsname uts;
4529   memset(&uts, 0, sizeof(uts));
4530   strcpy(uts.sysname, "?");
4531   if (::uname(&uts) == -1) {
4532     trc("uname failed (%d)", errno);
4533     guarantee(0, "Could not determine whether we run on AIX or PASE");
4534   } else {


< prev index next >