< prev index next >

src/hotspot/os/linux/os_linux.cpp

Print this page




 114   #undef _GNU_SOURCE
 115 #else
 116   #include <sched.h>
 117 #endif
 118 
 119 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
 120 // getrusage() is prepared to handle the associated failure.
 121 #ifndef RUSAGE_THREAD
 122   #define RUSAGE_THREAD   (1)               /* only the calling thread */
 123 #endif
 124 
 125 #define MAX_PATH    (2 * K)
 126 
 127 #define MAX_SECS 100000000
 128 
 129 // for timer info max values which include all bits
 130 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
 131 
 132 enum CoredumpFilterBit {
 133   FILE_BACKED_PVT_BIT = 1 << 2,

 134   LARGEPAGES_BIT = 1 << 6,
 135   DAX_SHARED_BIT = 1 << 8
 136 };
 137 
 138 ////////////////////////////////////////////////////////////////////////////////
 139 // global variables
 140 julong os::Linux::_physical_memory = 0;
 141 
 142 address   os::Linux::_initial_thread_stack_bottom = NULL;
 143 uintptr_t os::Linux::_initial_thread_stack_size   = 0;
 144 
 145 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
 146 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
 147 Mutex* os::Linux::_createThread_lock = NULL;
 148 pthread_t os::Linux::_main_thread;
 149 int os::Linux::_page_size = -1;
 150 bool os::Linux::_supports_fast_thread_cpu_time = false;
 151 uint32_t os::Linux::_os_version = 0;
 152 const char * os::Linux::_glibc_version = NULL;
 153 const char * os::Linux::_libpthread_version = NULL;


5114     // only register atexit functions if PerfAllowAtExitRegistration is set.
5115     // atexit functions can be delayed until process exit time, which
5116     // can be problematic for embedded VM situations. Embedded VMs should
5117     // call DestroyJavaVM() to assure that VM resources are released.
5118 
5119     // note: perfMemory_exit_helper atexit function may be removed in
5120     // the future if the appropriate cleanup code can be added to the
5121     // VM_Exit VMOperation's doit method.
5122     if (atexit(perfMemory_exit_helper) != 0) {
5123       warning("os::init_2 atexit(perfMemory_exit_helper) failed");
5124     }
5125   }
5126 
5127   // initialize thread priority policy
5128   prio_init();
5129 
5130   if (!FLAG_IS_DEFAULT(AllocateHeapAt) || !FLAG_IS_DEFAULT(AllocateOldGenAt)) {
5131     set_coredump_filter(DAX_SHARED_BIT);
5132   }
5133 
5134 #if INCLUDE_CDS
5135   if (UseSharedSpaces && DumpPrivateMappingsInCore) {
5136     set_coredump_filter(FILE_BACKED_PVT_BIT);
5137   }
5138 #endif



5139 
5140   return JNI_OK;
5141 }
5142 
5143 // Mark the polling page as unreadable
5144 void os::make_polling_page_unreadable(void) {
5145   if (!guard_memory((char*)_polling_page, Linux::page_size())) {
5146     fatal("Could not disable polling page");
5147   }
5148 }
5149 
5150 // Mark the polling page as readable
5151 void os::make_polling_page_readable(void) {
5152   if (!linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) {
5153     fatal("Could not enable polling page");
5154   }
5155 }
5156 
5157 // older glibc versions don't have this macro (which expands to
5158 // an optimized bit-counting function) so we have to roll our own




 114   #undef _GNU_SOURCE
 115 #else
 116   #include <sched.h>
 117 #endif
 118 
 119 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
 120 // getrusage() is prepared to handle the associated failure.
 121 #ifndef RUSAGE_THREAD
 122   #define RUSAGE_THREAD   (1)               /* only the calling thread */
 123 #endif
 124 
 125 #define MAX_PATH    (2 * K)
 126 
 127 #define MAX_SECS 100000000
 128 
 129 // for timer info max values which include all bits
 130 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
 131 
 132 enum CoredumpFilterBit {
 133   FILE_BACKED_PVT_BIT = 1 << 2,
 134   FILE_BACKED_SHARED_BIT = 1 << 3,
 135   LARGEPAGES_BIT = 1 << 6,
 136   DAX_SHARED_BIT = 1 << 8
 137 };
 138 
 139 ////////////////////////////////////////////////////////////////////////////////
 140 // global variables
 141 julong os::Linux::_physical_memory = 0;
 142 
 143 address   os::Linux::_initial_thread_stack_bottom = NULL;
 144 uintptr_t os::Linux::_initial_thread_stack_size   = 0;
 145 
 146 int (*os::Linux::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
 147 int (*os::Linux::_pthread_setname_np)(pthread_t, const char*) = NULL;
 148 Mutex* os::Linux::_createThread_lock = NULL;
 149 pthread_t os::Linux::_main_thread;
 150 int os::Linux::_page_size = -1;
 151 bool os::Linux::_supports_fast_thread_cpu_time = false;
 152 uint32_t os::Linux::_os_version = 0;
 153 const char * os::Linux::_glibc_version = NULL;
 154 const char * os::Linux::_libpthread_version = NULL;


5115     // only register atexit functions if PerfAllowAtExitRegistration is set.
5116     // atexit functions can be delayed until process exit time, which
5117     // can be problematic for embedded VM situations. Embedded VMs should
5118     // call DestroyJavaVM() to assure that VM resources are released.
5119 
5120     // note: perfMemory_exit_helper atexit function may be removed in
5121     // the future if the appropriate cleanup code can be added to the
5122     // VM_Exit VMOperation's doit method.
5123     if (atexit(perfMemory_exit_helper) != 0) {
5124       warning("os::init_2 atexit(perfMemory_exit_helper) failed");
5125     }
5126   }
5127 
5128   // initialize thread priority policy
5129   prio_init();
5130 
5131   if (!FLAG_IS_DEFAULT(AllocateHeapAt) || !FLAG_IS_DEFAULT(AllocateOldGenAt)) {
5132     set_coredump_filter(DAX_SHARED_BIT);
5133   }
5134 
5135   if (DumpPrivateMappingsInCore) {

5136     set_coredump_filter(FILE_BACKED_PVT_BIT);
5137   }
5138 
5139   if (DumpSharedMappingsInCore) {
5140     set_coredump_filter(FILE_BACKED_SHARED_BIT);
5141   }
5142 
5143   return JNI_OK;
5144 }
5145 
5146 // Mark the polling page as unreadable
5147 void os::make_polling_page_unreadable(void) {
5148   if (!guard_memory((char*)_polling_page, Linux::page_size())) {
5149     fatal("Could not disable polling page");
5150   }
5151 }
5152 
5153 // Mark the polling page as readable
5154 void os::make_polling_page_readable(void) {
5155   if (!linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) {
5156     fatal("Could not enable polling page");
5157   }
5158 }
5159 
5160 // older glibc versions don't have this macro (which expands to
5161 // an optimized bit-counting function) so we have to roll our own


< prev index next >