< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page




  85 # include <pthread.h>
  86 # include <signal.h>
  87 # include <errno.h>
  88 # include <dlfcn.h>
  89 # include <stdio.h>
  90 # include <unistd.h>
  91 # include <sys/resource.h>
  92 # include <pthread.h>
  93 # include <sys/stat.h>
  94 # include <sys/time.h>
  95 # include <sys/times.h>
  96 # include <sys/utsname.h>
  97 # include <sys/socket.h>
  98 # include <sys/wait.h>
  99 # include <pwd.h>
 100 # include <poll.h>
 101 # include <fcntl.h>
 102 # include <string.h>
 103 # include <syscall.h>
 104 # include <sys/sysinfo.h>
 105 # include <gnu/libc-version.h>
 106 # include <sys/ipc.h>
 107 # include <sys/shm.h>
 108 # include <link.h>
 109 # include <stdint.h>
 110 # include <inttypes.h>
 111 # include <sys/ioctl.h>
 112 
 113 #ifndef _GNU_SOURCE
 114   #define _GNU_SOURCE
 115   #include <sched.h>
 116   #undef _GNU_SOURCE
 117 #else
 118   #include <sched.h>
 119 #endif
 120 
 121 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
 122 // getrusage() is prepared to handle the associated failure.
 123 #ifndef RUSAGE_THREAD
 124   #define RUSAGE_THREAD   (1)               /* only the calling thread */
 125 #endif


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


 588     if (thread->is_VM_thread()) {
 589       // Only the VM thread handles BREAK_SIGNAL ...
 590       pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL);
 591     } else {
 592       // ... all other threads block BREAK_SIGNAL
 593       pthread_sigmask(SIG_BLOCK, vm_signals(), NULL);
 594     }
 595   }
 596 }
 597 
 598 //////////////////////////////////////////////////////////////////////////////
 599 // detecting pthread library
 600 
 601 void os::Linux::libpthread_init() {
 602   // Save glibc and pthread version strings.
 603 #if !defined(_CS_GNU_LIBC_VERSION) || \
 604     !defined(_CS_GNU_LIBPTHREAD_VERSION)
 605   #error "glibc too old (< 2.3.2)"
 606 #endif
 607 
 608   size_t n = confstr(_CS_GNU_LIBC_VERSION, NULL, 0);
 609   assert(n > 0, "cannot retrieve glibc version");
 610   char *str = (char *)malloc(n, mtInternal);
 611   confstr(_CS_GNU_LIBC_VERSION, str, n);
 612   os::Linux::set_glibc_version(str);



 613 
 614   n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
 615   assert(n > 0, "cannot retrieve pthread version");
 616   str = (char *)malloc(n, mtInternal);
 617   confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
 618   os::Linux::set_libpthread_version(str);

 619 }
 620 
 621 /////////////////////////////////////////////////////////////////////////////
 622 // thread stack expansion
 623 
 624 // os::Linux::manually_expand_stack() takes care of expanding the thread
 625 // stack. Note that this is normally not needed: pthread stacks allocate
 626 // thread stack using mmap() without MAP_NORESERVE, so the stack is already
 627 // committed. Therefore it is not necessary to expand the stack manually.
 628 //
 629 // Manually expanding the stack was historically needed on LinuxThreads
 630 // thread stacks, which were allocated with mmap(MAP_GROWSDOWN). Nowadays
 631 // it is kept to deal with very rare corner cases:
 632 //
 633 // For one, user may run the VM on an own implementation of threads
 634 // whose stacks are - like the old LinuxThreads - implemented using
 635 // mmap(MAP_GROWSDOWN).
 636 //
 637 // Also, this coding may be needed if the VM is running on the primordial
 638 // thread. Normally we avoid running on the primordial thread; however,


2968 void os::Linux::sched_getcpu_init() {
2969   // sched_getcpu() should be in libc.
2970   set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
2971                                   dlsym(RTLD_DEFAULT, "sched_getcpu")));
2972 
2973   // If it's not, try a direct syscall.
2974   if (sched_getcpu() == -1) {
2975     set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
2976                                     (void*)&sched_getcpu_syscall));
2977   }
2978 
2979   if (sched_getcpu() == -1) {
2980     vm_exit_during_initialization("getcpu(2) system call not supported by kernel");
2981   }
2982 }
2983 
2984 // Something to do with the numa-aware allocator needs these symbols
2985 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
2986 extern "C" JNIEXPORT void numa_error(char *where) { }
2987 




















2988 // Handle request to load libnuma symbol version 1.1 (API v1). If it fails
2989 // load symbol from base version instead.
2990 void* os::Linux::libnuma_dlsym(void* handle, const char *name) {
2991   void *f = dlvsym(handle, name, "libnuma_1.1");
2992   if (f == NULL) {
2993     f = dlsym(handle, name);
2994   }
2995   return f;
2996 }
2997 
2998 // Handle request to load libnuma symbol version 1.2 (API v2) only.
2999 // Return NULL if the symbol is not defined in this particular version.
3000 void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
3001   return dlvsym(handle, name, "libnuma_1.2");
3002 }
3003 
3004 bool os::Linux::libnuma_init() {
3005   if (sched_getcpu() != -1) { // Requires sched_getcpu() support
3006     void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
3007     if (handle != NULL) {
3008       set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,
3009                                            libnuma_dlsym(handle, "numa_node_to_cpus")));
3010       set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t,
3011                                        libnuma_dlsym(handle, "numa_max_node")));
3012       set_numa_num_configured_nodes(CAST_TO_FN_PTR(numa_num_configured_nodes_func_t,
3013                                                    libnuma_dlsym(handle, "numa_num_configured_nodes")));
3014       set_numa_available(CAST_TO_FN_PTR(numa_available_func_t,
3015                                         libnuma_dlsym(handle, "numa_available")));
3016       set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
3017                                             libnuma_dlsym(handle, "numa_tonode_memory")));
3018       set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
3019                                                 libnuma_dlsym(handle, "numa_interleave_memory")));
3020       set_numa_interleave_memory_v2(CAST_TO_FN_PTR(numa_interleave_memory_v2_func_t,
3021                                                 libnuma_v2_dlsym(handle, "numa_interleave_memory")));


4987     tty->print("Warning: %s handler flags ", exception_name(sig, buf, O_BUFLEN));
4988     tty->print("expected:");
4989     os::Posix::print_sa_flags(tty, os::Linux::get_our_sigflags(sig));
4990     tty->cr();
4991     tty->print("  found:");
4992     os::Posix::print_sa_flags(tty, act.sa_flags);
4993     tty->cr();
4994     // No need to check this sig any longer
4995     sigaddset(&check_signal_done, sig);
4996   }
4997 
4998   // Dump all the signal
4999   if (sigismember(&check_signal_done, sig)) {
5000     print_signal_handlers(tty, buf, O_BUFLEN);
5001   }
5002 }
5003 
5004 extern void report_error(char* file_name, int line_no, char* title,
5005                          char* format, ...);
5006 

























































5007 // this is called _before_ most of the global arguments have been parsed
5008 void os::init(void) {
5009   char dummy;   // used to get a guess on initial stack address
5010 
5011   clock_tics_per_sec = sysconf(_SC_CLK_TCK);
5012 
5013   init_random(1234567);
5014 
5015   Linux::set_page_size(sysconf(_SC_PAGESIZE));
5016   if (Linux::page_size() == -1) {
5017     fatal("os_linux.cpp: os::init: sysconf failed (%s)",
5018           os::strerror(errno));
5019   }
5020   init_page_sizes((size_t) Linux::page_size());
5021 
5022   Linux::initialize_system_info();
5023 
5024   Linux::initialize_os_info();
5025 
5026   os::Linux::CPUPerfTicks pticks;
5027   bool res = os::Linux::get_tick_information(&pticks, -1);
5028 
5029   if (res && pticks.has_steal_ticks) {
5030     has_initial_tick_info = true;
5031     initial_total_ticks = pticks.total;
5032     initial_steal_ticks = pticks.steal;
5033   }
5034 
5035   // _main_thread points to the thread that created/loaded the JVM.
5036   Linux::_main_thread = pthread_self();
5037 
5038   // retrieve entry point for pthread_setname_np
5039   Linux::_pthread_setname_np =
5040     (int(*)(pthread_t, const char*))dlsym(RTLD_DEFAULT, "pthread_setname_np");


5041 
5042   os::Posix::init();
5043 
5044   initial_time_count = javaTimeNanos();
5045 
5046   // Always warn if no monotonic clock available
5047   if (!os::Posix::supports_monotonic_clock()) {
5048     warning("No monotonic clock was available - timed services may "    \
5049             "be adversely affected if the time-of-day clock changes");
5050   }
5051 }
5052 
5053 // To install functions for atexit system call
5054 extern "C" {
5055   static void perfMemory_exit_helper() {
5056     perfMemory_exit();
5057   }
5058 }
5059 
5060 void os::pd_init_container_support() {




  85 # include <pthread.h>
  86 # include <signal.h>
  87 # include <errno.h>
  88 # include <dlfcn.h>
  89 # include <stdio.h>
  90 # include <unistd.h>
  91 # include <sys/resource.h>
  92 # include <pthread.h>
  93 # include <sys/stat.h>
  94 # include <sys/time.h>
  95 # include <sys/times.h>
  96 # include <sys/utsname.h>
  97 # include <sys/socket.h>
  98 # include <sys/wait.h>
  99 # include <pwd.h>
 100 # include <poll.h>
 101 # include <fcntl.h>
 102 # include <string.h>
 103 # include <syscall.h>
 104 # include <sys/sysinfo.h>

 105 # include <sys/ipc.h>
 106 # include <sys/shm.h>
 107 # include <link.h>
 108 # include <stdint.h>
 109 # include <inttypes.h>
 110 # include <sys/ioctl.h>
 111 
 112 #ifndef _GNU_SOURCE
 113   #define _GNU_SOURCE
 114   #include <sched.h>
 115   #undef _GNU_SOURCE
 116 #else
 117   #include <sched.h>
 118 #endif
 119 
 120 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
 121 // getrusage() is prepared to handle the associated failure.
 122 #ifndef RUSAGE_THREAD
 123   #define RUSAGE_THREAD   (1)               /* only the calling thread */
 124 #endif


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


 587     if (thread->is_VM_thread()) {
 588       // Only the VM thread handles BREAK_SIGNAL ...
 589       pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL);
 590     } else {
 591       // ... all other threads block BREAK_SIGNAL
 592       pthread_sigmask(SIG_BLOCK, vm_signals(), NULL);
 593     }
 594   }
 595 }
 596 
 597 //////////////////////////////////////////////////////////////////////////////
 598 // detecting pthread library
 599 
 600 void os::Linux::libpthread_init() {
 601   // Save glibc and pthread version strings.
 602 #if !defined(_CS_GNU_LIBC_VERSION) || \
 603     !defined(_CS_GNU_LIBPTHREAD_VERSION)
 604   #error "glibc too old (< 2.3.2)"
 605 #endif
 606 
 607   size_t n;
 608 
 609   n = confstr(_CS_GNU_LIBC_VERSION, NULL, 0);
 610   if (n > 0) {
 611     char* str = (char *)malloc(n, mtInternal);
 612     confstr(_CS_GNU_LIBC_VERSION, str, n);
 613     os::Linux::set_glibc_version(str);
 614   }
 615 
 616   n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
 617   if (n > 0) {
 618     char* str = (char *)malloc(n, mtInternal);
 619     confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
 620     os::Linux::set_libpthread_version(str);
 621   }
 622 }
 623 
 624 /////////////////////////////////////////////////////////////////////////////
 625 // thread stack expansion
 626 
 627 // os::Linux::manually_expand_stack() takes care of expanding the thread
 628 // stack. Note that this is normally not needed: pthread stacks allocate
 629 // thread stack using mmap() without MAP_NORESERVE, so the stack is already
 630 // committed. Therefore it is not necessary to expand the stack manually.
 631 //
 632 // Manually expanding the stack was historically needed on LinuxThreads
 633 // thread stacks, which were allocated with mmap(MAP_GROWSDOWN). Nowadays
 634 // it is kept to deal with very rare corner cases:
 635 //
 636 // For one, user may run the VM on an own implementation of threads
 637 // whose stacks are - like the old LinuxThreads - implemented using
 638 // mmap(MAP_GROWSDOWN).
 639 //
 640 // Also, this coding may be needed if the VM is running on the primordial
 641 // thread. Normally we avoid running on the primordial thread; however,


2971 void os::Linux::sched_getcpu_init() {
2972   // sched_getcpu() should be in libc.
2973   set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
2974                                   dlsym(RTLD_DEFAULT, "sched_getcpu")));
2975 
2976   // If it's not, try a direct syscall.
2977   if (sched_getcpu() == -1) {
2978     set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
2979                                     (void*)&sched_getcpu_syscall));
2980   }
2981 
2982   if (sched_getcpu() == -1) {
2983     vm_exit_during_initialization("getcpu(2) system call not supported by kernel");
2984   }
2985 }
2986 
2987 // Something to do with the numa-aware allocator needs these symbols
2988 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
2989 extern "C" JNIEXPORT void numa_error(char *where) { }
2990 
2991 static void* dlvsym_if_available(void* handle, const char* name, const char* version) {
2992   typedef void* (*dlvsym_func_type)(void* handle, const char* name, const char* version);
2993   static dlvsym_func_type dlvsym_func;
2994   static bool initialized = false;
2995 
2996   if (!initialized) {
2997     dlvsym_func = (dlvsym_func_type)dlsym(RTLD_NEXT, "dlvsym");
2998     initialized = true;
2999   }
3000 
3001   if (dlvsym_func != NULL) {
3002     void *f = dlvsym_func(handle, name, version);
3003     if (f != NULL) {
3004       return f;
3005     }
3006   }
3007 
3008   return dlsym(handle, name);
3009 }
3010 
3011 // Handle request to load libnuma symbol version 1.1 (API v1). If it fails
3012 // load symbol from base version instead.
3013 void* os::Linux::libnuma_dlsym(void* handle, const char *name) {
3014   return dlvsym_if_available(handle, name, "libnuma_1.1");




3015 }
3016 
3017 // Handle request to load libnuma symbol version 1.2 (API v2) only.
3018 // Return NULL if the symbol is not defined in this particular version.
3019 void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
3020   return dlvsym_if_available(handle, name, "libnuma_1.2");
3021 }
3022 
3023 bool os::Linux::libnuma_init() {
3024   if (sched_getcpu() != -1) { // Requires sched_getcpu() support
3025     void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
3026     if (handle != NULL) {
3027       set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,
3028                                            libnuma_dlsym(handle, "numa_node_to_cpus")));
3029       set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t,
3030                                        libnuma_dlsym(handle, "numa_max_node")));
3031       set_numa_num_configured_nodes(CAST_TO_FN_PTR(numa_num_configured_nodes_func_t,
3032                                                    libnuma_dlsym(handle, "numa_num_configured_nodes")));
3033       set_numa_available(CAST_TO_FN_PTR(numa_available_func_t,
3034                                         libnuma_dlsym(handle, "numa_available")));
3035       set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
3036                                             libnuma_dlsym(handle, "numa_tonode_memory")));
3037       set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
3038                                                 libnuma_dlsym(handle, "numa_interleave_memory")));
3039       set_numa_interleave_memory_v2(CAST_TO_FN_PTR(numa_interleave_memory_v2_func_t,
3040                                                 libnuma_v2_dlsym(handle, "numa_interleave_memory")));


5006     tty->print("Warning: %s handler flags ", exception_name(sig, buf, O_BUFLEN));
5007     tty->print("expected:");
5008     os::Posix::print_sa_flags(tty, os::Linux::get_our_sigflags(sig));
5009     tty->cr();
5010     tty->print("  found:");
5011     os::Posix::print_sa_flags(tty, act.sa_flags);
5012     tty->cr();
5013     // No need to check this sig any longer
5014     sigaddset(&check_signal_done, sig);
5015   }
5016 
5017   // Dump all the signal
5018   if (sigismember(&check_signal_done, sig)) {
5019     print_signal_handlers(tty, buf, O_BUFLEN);
5020   }
5021 }
5022 
5023 extern void report_error(char* file_name, int line_no, char* title,
5024                          char* format, ...);
5025 
5026 // Some linux distributions (notably: Alpine Linux) include the
5027 // grsecurity in the kernel by default. Of particular interest from a
5028 // JVM perspective is PaX (https://pax.grsecurity.net/), which adds
5029 // some security features related to page attributes. Specifically,
5030 // the MPROTECT PaX functionality
5031 // (https://pax.grsecurity.net/docs/mprotect.txt) prevents dynamic
5032 // code generation by disallowing a (previously) writable page to be
5033 // marked as executable. This is, of course, exactly what HotSpot does
5034 // for both JIT compiled method, as well as for stubs, adapters, etc.
5035 //
5036 // Instead of crashing "lazily" when trying to make a page executable,
5037 // this code probes for the presence of PaX and reports the failure
5038 // eagerly.
5039 static void check_pax(void) {
5040   // Zero doesn't generate code dynamically, so no need to perform the PaX check
5041 #ifndef ZERO
5042   size_t size = os::Linux::page_size();
5043 
5044   void* p = ::mmap(NULL, size, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
5045   if (p == MAP_FAILED) {
5046     vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "failed to allocate memory for PaX check.");
5047   }
5048 
5049   int res = ::mprotect(p, size, PROT_WRITE|PROT_EXEC);
5050   if (res == -1) {
5051     vm_exit_during_initialization("Failed to mark memory page as executable",
5052                                   "Please check if grsecurity/PaX is enabled in your kernel.\n"
5053                                   "\n"
5054                                   "For example, you can do this by running (note: you may need root privileges):\n"
5055                                   "\n"
5056                                   "    sysctl kernel.pax.softmode\n"
5057                                   "\n"
5058                                   "If PaX is included in the kernel you will see something like this:\n"
5059                                   "\n"
5060                                   "    kernel.pax.softmode = 0\n"
5061                                   "\n"
5062                                   "In particular, if the value is 0 (zero), then PaX is enabled.\n"
5063                                   "\n"
5064                                   "PaX includes security functionality which interferes with the dynamic code\n"
5065                                   "generation the JVM relies on. Specifically, the MPROTECT functionality as\n"
5066                                   "described on https://pax.grsecurity.net/docs/mprotect.txt is not compatible\n"
5067                                   "with the JVM. If you want to allow the JVM to run you will have to disable PaX.\n"
5068                                   "You can do this on a per-executable basis using the paxctl tool, for example:\n"
5069                                   "\n"
5070                                   "    paxctl -cm bin/java\n"
5071                                   "\n"
5072                                   "Please note that this modifies the executable binary in-place, so you may want\n"
5073                                   "to make a backup of it first. Also note that you have to repeat this for other\n"
5074                                   "executables like javac, jar, jcmd, etc.\n"
5075                                   );
5076 
5077   }
5078 
5079   ::munmap(p, size);
5080 #endif
5081 }
5082 
5083 // this is called _before_ most of the global arguments have been parsed
5084 void os::init(void) {
5085   char dummy;   // used to get a guess on initial stack address
5086 
5087   clock_tics_per_sec = sysconf(_SC_CLK_TCK);
5088 
5089   init_random(1234567);
5090 
5091   Linux::set_page_size(sysconf(_SC_PAGESIZE));
5092   if (Linux::page_size() == -1) {
5093     fatal("os_linux.cpp: os::init: sysconf failed (%s)",
5094           os::strerror(errno));
5095   }
5096   init_page_sizes((size_t) Linux::page_size());
5097 
5098   Linux::initialize_system_info();
5099 
5100   Linux::initialize_os_info();
5101 
5102   os::Linux::CPUPerfTicks pticks;
5103   bool res = os::Linux::get_tick_information(&pticks, -1);
5104 
5105   if (res && pticks.has_steal_ticks) {
5106     has_initial_tick_info = true;
5107     initial_total_ticks = pticks.total;
5108     initial_steal_ticks = pticks.steal;
5109   }
5110 
5111   // _main_thread points to the thread that created/loaded the JVM.
5112   Linux::_main_thread = pthread_self();
5113 
5114   // retrieve entry point for pthread_setname_np
5115   Linux::_pthread_setname_np =
5116     (int(*)(pthread_t, const char*))dlsym(RTLD_DEFAULT, "pthread_setname_np");
5117 
5118   check_pax();
5119 
5120   os::Posix::init();
5121 
5122   initial_time_count = javaTimeNanos();
5123 
5124   // Always warn if no monotonic clock available
5125   if (!os::Posix::supports_monotonic_clock()) {
5126     warning("No monotonic clock was available - timed services may "    \
5127             "be adversely affected if the time-of-day clock changes");
5128   }
5129 }
5130 
5131 // To install functions for atexit system call
5132 extern "C" {
5133   static void perfMemory_exit_helper() {
5134     perfMemory_exit();
5135   }
5136 }
5137 
5138 void os::pd_init_container_support() {


< prev index next >