121 # include <sys/ioctl.h>
122
123 #define MAX_PATH (2 * K)
124
125 // for timer info max values which include all bits
126 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
127
128 #define LARGEPAGES_BIT (1 << 6)
129 ////////////////////////////////////////////////////////////////////////////////
130 // global variables
131 julong os::Linux::_physical_memory = 0;
132
133 address os::Linux::_initial_thread_stack_bottom = NULL;
134 uintptr_t os::Linux::_initial_thread_stack_size = 0;
135
136 int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
137 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
138 Mutex* os::Linux::_createThread_lock = NULL;
139 pthread_t os::Linux::_main_thread;
140 int os::Linux::_page_size = -1;
141 bool os::Linux::_is_floating_stack = false;
142 bool os::Linux::_is_NPTL = false;
143 bool os::Linux::_supports_fast_thread_cpu_time = false;
144 const char * os::Linux::_glibc_version = NULL;
145 const char * os::Linux::_libpthread_version = NULL;
146
147 static jlong initial_time_count=0;
148
149 static int clock_tics_per_sec = 100;
150
151 // For diagnostics to print a message once. see run_periodic_checks
152 static sigset_t check_signal_done;
153 static bool check_signals = true;;
154
155 static pid_t _initial_pid = 0;
156
157 /* Signal number used to suspend/resume a thread */
158
159 /* do not use any signal number less than SIGSEGV, see 4355769 */
160 static int SR_signum = SIGUSR2;
4368
4369 init_random(1234567);
4370
4371 ThreadCritical::initialize();
4372
4373 Linux::set_page_size(sysconf(_SC_PAGESIZE));
4374 if (Linux::page_size() == -1) {
4375 fatal(err_msg("os_linux.cpp: os::init: sysconf failed (%s)",
4376 strerror(errno)));
4377 }
4378 init_page_sizes((size_t) Linux::page_size());
4379
4380 Linux::initialize_system_info();
4381
4382 // main_thread points to the aboriginal thread
4383 Linux::_main_thread = pthread_self();
4384
4385 Linux::clock_init();
4386 initial_time_count = os::elapsed_counter();
4387 pthread_mutex_init(&dl_mutex, NULL);
4388 }
4389
4390 // To install functions for atexit system call
4391 extern "C" {
4392 static void perfMemory_exit_helper() {
4393 perfMemory_exit();
4394 }
4395 }
4396
4397 // this is called _after_ the global arguments have been parsed
4398 jint os::init_2(void)
4399 {
4400 Linux::fast_thread_clock_init();
4401
4402 // Allocate a single page and mark it as readable for safepoint polling
4403 address polling_page = (address) ::mmap(NULL, Linux::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
4404 guarantee( polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page" );
4405
4406 os::set_polling_page( polling_page );
4407
4421 #endif
4422 }
4423
4424 os::large_page_init();
4425
4426 // initialize suspend/resume support - must do this before signal_sets_init()
4427 if (SR_initialize() != 0) {
4428 perror("SR_initialize failed");
4429 return JNI_ERR;
4430 }
4431
4432 Linux::signal_sets_init();
4433 Linux::install_signal_handlers();
4434
4435 // Check minimum allowable stack size for thread creation and to initialize
4436 // the java system classes, including StackOverflowError - depends on page
4437 // size. Add a page for compiler2 recursion in main thread.
4438 // Add in 2*BytesPerWord times page size to account for VM stack during
4439 // class initialization depending on 32 or 64 bit VM.
4440 os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
4441 (size_t)(StackYellowPages+StackRedPages+StackShadowPages+
4442 2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::page_size());
4443
4444 size_t threadStackSizeInBytes = ThreadStackSize * K;
4445 if (threadStackSizeInBytes != 0 &&
4446 threadStackSizeInBytes < os::Linux::min_stack_allowed) {
4447 tty->print_cr("\nThe stack size specified is too small, "
4448 "Specify at least %dk",
4449 os::Linux::min_stack_allowed/ K);
4450 return JNI_ERR;
4451 }
4452
4453 // Make the stack size a multiple of the page size so that
4454 // the yellow/red zones can be guarded.
4455 JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes,
4456 vm_page_size()));
4457
4458 Linux::capture_initial_stack(JavaThread::stack_size_at_create());
4459
4460 Linux::libpthread_init();
4461 if (PrintMiscellaneous && (Verbose || WizardMode)) {
4462 tty->print_cr("[HotSpot is running with %s, %s(%s)]\n",
|
121 # include <sys/ioctl.h>
122
123 #define MAX_PATH (2 * K)
124
125 // for timer info max values which include all bits
126 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
127
128 #define LARGEPAGES_BIT (1 << 6)
129 ////////////////////////////////////////////////////////////////////////////////
130 // global variables
131 julong os::Linux::_physical_memory = 0;
132
133 address os::Linux::_initial_thread_stack_bottom = NULL;
134 uintptr_t os::Linux::_initial_thread_stack_size = 0;
135
136 int (*os::Linux::_clock_gettime)(clockid_t, struct timespec *) = NULL;
137 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
138 Mutex* os::Linux::_createThread_lock = NULL;
139 pthread_t os::Linux::_main_thread;
140 int os::Linux::_page_size = -1;
141 const int os::Linux::_vm_default_page_size = (8 * K);
142 bool os::Linux::_is_floating_stack = false;
143 bool os::Linux::_is_NPTL = false;
144 bool os::Linux::_supports_fast_thread_cpu_time = false;
145 const char * os::Linux::_glibc_version = NULL;
146 const char * os::Linux::_libpthread_version = NULL;
147
148 static jlong initial_time_count=0;
149
150 static int clock_tics_per_sec = 100;
151
152 // For diagnostics to print a message once. see run_periodic_checks
153 static sigset_t check_signal_done;
154 static bool check_signals = true;;
155
156 static pid_t _initial_pid = 0;
157
158 /* Signal number used to suspend/resume a thread */
159
160 /* do not use any signal number less than SIGSEGV, see 4355769 */
161 static int SR_signum = SIGUSR2;
4369
4370 init_random(1234567);
4371
4372 ThreadCritical::initialize();
4373
4374 Linux::set_page_size(sysconf(_SC_PAGESIZE));
4375 if (Linux::page_size() == -1) {
4376 fatal(err_msg("os_linux.cpp: os::init: sysconf failed (%s)",
4377 strerror(errno)));
4378 }
4379 init_page_sizes((size_t) Linux::page_size());
4380
4381 Linux::initialize_system_info();
4382
4383 // main_thread points to the aboriginal thread
4384 Linux::_main_thread = pthread_self();
4385
4386 Linux::clock_init();
4387 initial_time_count = os::elapsed_counter();
4388 pthread_mutex_init(&dl_mutex, NULL);
4389
4390 // If the pagesize of the VM is greater than 8K determine the appropriate
4391 // number of initial guard pages. The user can change this with the
4392 // command line arguments, if needed.
4393 if (vm_page_size() > (int)Linux::vm_default_page_size()) {
4394 StackYellowPages = 1;
4395 StackRedPages = 1;
4396 StackShadowPages = round_to((StackShadowPages*Linux::vm_default_page_size()), vm_page_size()) / vm_page_size();
4397 }
4398 }
4399
4400 // To install functions for atexit system call
4401 extern "C" {
4402 static void perfMemory_exit_helper() {
4403 perfMemory_exit();
4404 }
4405 }
4406
4407 // this is called _after_ the global arguments have been parsed
4408 jint os::init_2(void)
4409 {
4410 Linux::fast_thread_clock_init();
4411
4412 // Allocate a single page and mark it as readable for safepoint polling
4413 address polling_page = (address) ::mmap(NULL, Linux::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
4414 guarantee( polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page" );
4415
4416 os::set_polling_page( polling_page );
4417
4431 #endif
4432 }
4433
4434 os::large_page_init();
4435
4436 // initialize suspend/resume support - must do this before signal_sets_init()
4437 if (SR_initialize() != 0) {
4438 perror("SR_initialize failed");
4439 return JNI_ERR;
4440 }
4441
4442 Linux::signal_sets_init();
4443 Linux::install_signal_handlers();
4444
4445 // Check minimum allowable stack size for thread creation and to initialize
4446 // the java system classes, including StackOverflowError - depends on page
4447 // size. Add a page for compiler2 recursion in main thread.
4448 // Add in 2*BytesPerWord times page size to account for VM stack during
4449 // class initialization depending on 32 or 64 bit VM.
4450 os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
4451 (size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
4452 (2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
4453
4454 size_t threadStackSizeInBytes = ThreadStackSize * K;
4455 if (threadStackSizeInBytes != 0 &&
4456 threadStackSizeInBytes < os::Linux::min_stack_allowed) {
4457 tty->print_cr("\nThe stack size specified is too small, "
4458 "Specify at least %dk",
4459 os::Linux::min_stack_allowed/ K);
4460 return JNI_ERR;
4461 }
4462
4463 // Make the stack size a multiple of the page size so that
4464 // the yellow/red zones can be guarded.
4465 JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes,
4466 vm_page_size()));
4467
4468 Linux::capture_initial_stack(JavaThread::stack_size_at_create());
4469
4470 Linux::libpthread_init();
4471 if (PrintMiscellaneous && (Verbose || WizardMode)) {
4472 tty->print_cr("[HotSpot is running with %s, %s(%s)]\n",
|