< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page
rev 49420 : 8199717: Avoid calculating primordial thread stack bounds on VM startup
Reviewed-by: dholmes, rehn, stuefe


 135 julong os::Linux::_physical_memory = 0;
 136 
 137 address   os::Linux::_initial_thread_stack_bottom = NULL;
 138 uintptr_t os::Linux::_initial_thread_stack_size   = 0;
 139 
 140 int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
 141 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
 142 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
 143 Mutex* os::Linux::_createThread_lock = NULL;
 144 pthread_t os::Linux::_main_thread;
 145 int os::Linux::_page_size = -1;
 146 bool os::Linux::_supports_fast_thread_cpu_time = false;
 147 uint32_t os::Linux::_os_version = 0;
 148 const char * os::Linux::_glibc_version = NULL;
 149 const char * os::Linux::_libpthread_version = NULL;
 150 
 151 static jlong initial_time_count=0;
 152 
 153 static int clock_tics_per_sec = 100;
 154 







 155 // For diagnostics to print a message once. see run_periodic_checks
 156 static sigset_t check_signal_done;
 157 static bool check_signals = true;
 158 
 159 // Signal number used to suspend/resume a thread
 160 
 161 // do not use any signal number less than SIGSEGV, see 4355769
 162 static int SR_signum = SIGUSR2;
 163 sigset_t SR_sigset;
 164 
 165 // utility functions
 166 
 167 static int SR_initialize();
 168 
 169 julong os::available_memory() {
 170   return Linux::available_memory();
 171 }
 172 
 173 julong os::Linux::available_memory() {
 174   // values in struct sysinfo are "unsigned long"


 900 
 901 #ifdef ASSERT
 902   sigset_t current;
 903   sigemptyset(&current);
 904   pthread_sigmask(SIG_SETMASK, NULL, &current);
 905   assert(!sigismember(&current, SR_signum), "SR signal should not be blocked!");
 906 #endif
 907 
 908   // Restore caller's signal mask
 909   sigset_t sigmask = osthread->caller_sigmask();
 910   pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
 911 
 912   delete osthread;
 913 }
 914 
 915 //////////////////////////////////////////////////////////////////////////////
 916 // primordial thread
 917 
 918 // Check if current thread is the primordial thread, similar to Solaris thr_main.
 919 bool os::is_primordial_thread(void) {



 920   char dummy;
 921   // If called before init complete, thread stack bottom will be null.
 922   // Can be called if fatal error occurs before initialization.
 923   if (os::Linux::initial_thread_stack_bottom() == NULL) return false;
 924   assert(os::Linux::initial_thread_stack_bottom() != NULL &&
 925          os::Linux::initial_thread_stack_size()   != 0,
 926          "os::init did not locate primordial thread's stack region");
 927   if ((address)&dummy >= os::Linux::initial_thread_stack_bottom() &&
 928       (address)&dummy < os::Linux::initial_thread_stack_bottom() +
 929                         os::Linux::initial_thread_stack_size()) {
 930     return true;
 931   } else {
 932     return false;
 933   }
 934 }
 935 
 936 // Find the virtual memory area that contains addr
 937 static bool find_vma(address addr, address* vma_low, address* vma_high) {
 938   FILE *fp = fopen("/proc/self/maps", "r");
 939   if (fp) {


4919 // this is called _after_ the global arguments have been parsed
4920 jint os::init_2(void) {
4921 
4922   os::Posix::init_2();
4923 
4924   Linux::fast_thread_clock_init();
4925 
4926   // initialize suspend/resume support - must do this before signal_sets_init()
4927   if (SR_initialize() != 0) {
4928     perror("SR_initialize failed");
4929     return JNI_ERR;
4930   }
4931 
4932   Linux::signal_sets_init();
4933   Linux::install_signal_handlers();
4934 
4935   // Check and sets minimum stack sizes against command line options
4936   if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
4937     return JNI_ERR;
4938   }



4939   Linux::capture_initial_stack(JavaThread::stack_size_at_create());

4940 
4941 #if defined(IA32)
4942   workaround_expand_exec_shield_cs_limit();
4943 #endif
4944 
4945   Linux::libpthread_init();
4946   Linux::sched_getcpu_init();
4947   log_info(os)("HotSpot is running with %s, %s",
4948                Linux::glibc_version(), Linux::libpthread_version());
4949 
4950   if (UseNUMA) {
4951     if (!Linux::libnuma_init()) {
4952       UseNUMA = false;
4953     } else {
4954       if ((Linux::numa_max_node() < 1)) {
4955         // There's only one node(they start from 0), disable NUMA.
4956         UseNUMA = false;
4957       }
4958     }
4959 




 135 julong os::Linux::_physical_memory = 0;
 136 
 137 address   os::Linux::_initial_thread_stack_bottom = NULL;
 138 uintptr_t os::Linux::_initial_thread_stack_size   = 0;
 139 
 140 int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
 141 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
 142 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
 143 Mutex* os::Linux::_createThread_lock = NULL;
 144 pthread_t os::Linux::_main_thread;
 145 int os::Linux::_page_size = -1;
 146 bool os::Linux::_supports_fast_thread_cpu_time = false;
 147 uint32_t os::Linux::_os_version = 0;
 148 const char * os::Linux::_glibc_version = NULL;
 149 const char * os::Linux::_libpthread_version = NULL;
 150 
 151 static jlong initial_time_count=0;
 152 
 153 static int clock_tics_per_sec = 100;
 154 
 155 // If the VM might have been created on the primordial thread, we need to resolve the
 156 // primordial thread stack bounds and check if the current thread might be the
 157 // primordial thread in places. If we know that the primordial thread is never used,
 158 // such as when the VM was created by one of the standard java launchers, we can
 159 // avoid this
 160 static bool suppress_primordial_thread_resolution = false;
 161 
 162 // For diagnostics to print a message once. see run_periodic_checks
 163 static sigset_t check_signal_done;
 164 static bool check_signals = true;
 165 
 166 // Signal number used to suspend/resume a thread
 167 
 168 // do not use any signal number less than SIGSEGV, see 4355769
 169 static int SR_signum = SIGUSR2;
 170 sigset_t SR_sigset;
 171 
 172 // utility functions
 173 
 174 static int SR_initialize();
 175 
 176 julong os::available_memory() {
 177   return Linux::available_memory();
 178 }
 179 
 180 julong os::Linux::available_memory() {
 181   // values in struct sysinfo are "unsigned long"


 907 
 908 #ifdef ASSERT
 909   sigset_t current;
 910   sigemptyset(&current);
 911   pthread_sigmask(SIG_SETMASK, NULL, &current);
 912   assert(!sigismember(&current, SR_signum), "SR signal should not be blocked!");
 913 #endif
 914 
 915   // Restore caller's signal mask
 916   sigset_t sigmask = osthread->caller_sigmask();
 917   pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
 918 
 919   delete osthread;
 920 }
 921 
 922 //////////////////////////////////////////////////////////////////////////////
 923 // primordial thread
 924 
 925 // Check if current thread is the primordial thread, similar to Solaris thr_main.
 926 bool os::is_primordial_thread(void) {
 927   if (suppress_primordial_thread_resolution) {
 928     return false;
 929   }
 930   char dummy;
 931   // If called before init complete, thread stack bottom will be null.
 932   // Can be called if fatal error occurs before initialization.
 933   if (os::Linux::initial_thread_stack_bottom() == NULL) return false;
 934   assert(os::Linux::initial_thread_stack_bottom() != NULL &&
 935          os::Linux::initial_thread_stack_size()   != 0,
 936          "os::init did not locate primordial thread's stack region");
 937   if ((address)&dummy >= os::Linux::initial_thread_stack_bottom() &&
 938       (address)&dummy < os::Linux::initial_thread_stack_bottom() +
 939                         os::Linux::initial_thread_stack_size()) {
 940     return true;
 941   } else {
 942     return false;
 943   }
 944 }
 945 
 946 // Find the virtual memory area that contains addr
 947 static bool find_vma(address addr, address* vma_low, address* vma_high) {
 948   FILE *fp = fopen("/proc/self/maps", "r");
 949   if (fp) {


4929 // this is called _after_ the global arguments have been parsed
4930 jint os::init_2(void) {
4931 
4932   os::Posix::init_2();
4933 
4934   Linux::fast_thread_clock_init();
4935 
4936   // initialize suspend/resume support - must do this before signal_sets_init()
4937   if (SR_initialize() != 0) {
4938     perror("SR_initialize failed");
4939     return JNI_ERR;
4940   }
4941 
4942   Linux::signal_sets_init();
4943   Linux::install_signal_handlers();
4944 
4945   // Check and sets minimum stack sizes against command line options
4946   if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
4947     return JNI_ERR;
4948   }
4949 
4950   suppress_primordial_thread_resolution = Arguments::created_by_java_launcher();
4951   if (!suppress_primordial_thread_resolution) {
4952     Linux::capture_initial_stack(JavaThread::stack_size_at_create());
4953   }
4954 
4955 #if defined(IA32)
4956   workaround_expand_exec_shield_cs_limit();
4957 #endif
4958 
4959   Linux::libpthread_init();
4960   Linux::sched_getcpu_init();
4961   log_info(os)("HotSpot is running with %s, %s",
4962                Linux::glibc_version(), Linux::libpthread_version());
4963 
4964   if (UseNUMA) {
4965     if (!Linux::libnuma_init()) {
4966       UseNUMA = false;
4967     } else {
4968       if ((Linux::numa_max_node() < 1)) {
4969         // There's only one node(they start from 0), disable NUMA.
4970         UseNUMA = false;
4971       }
4972     }
4973 


< prev index next >