38 static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
39 // __sigaction(), signal() is loaded
40 static struct sigaction *(*get_signal_action)(int);
41
42 static void check_signal_handler(int sig);
43
44 static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
45 static int (*_pthread_setname_np)(pthread_t, const char*);
46
47 static address _initial_thread_stack_bottom;
48 static uintptr_t _initial_thread_stack_size;
49
50 static const char *_glibc_version;
51 static const char *_libpthread_version;
52
53 static bool _supports_fast_thread_cpu_time;
54
55 static GrowableArray<int>* _cpu_to_node;
56 static GrowableArray<int>* _nindex_to_node;
57
58 // 0x00000000 = uninitialized,
59 // 0x01000000 = kernel version unknown,
60 // otherwise a 32-bit number:
61 // Ox00AABBCC
62 // AA, Major Version
63 // BB, Minor Version
64 // CC, Fix Version
65 static uint32_t _os_version;
66
67 protected:
68
69 static julong _physical_memory;
70 static pthread_t _main_thread;
71 static Mutex* _createThread_lock;
72 static int _page_size;
73
74 static julong available_memory();
75 static julong physical_memory() { return _physical_memory; }
76 static void set_physical_memory(julong phys_mem) { _physical_memory = phys_mem; }
77 static int active_processor_count();
78
79 static void initialize_system_info();
80
81 static int commit_memory_impl(char* addr, size_t bytes, bool exec);
82 static int commit_memory_impl(char* addr, size_t bytes,
83 size_t alignment_hint, bool exec);
84
85 static void set_glibc_version(const char *s) { _glibc_version = s; }
86 static void set_libpthread_version(const char *s) { _libpthread_version = s; }
87
88 static void rebuild_cpu_to_node_map();
89 static void rebuild_nindex_to_node_map();
90 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
91 static GrowableArray<int>* nindex_to_node() { return _nindex_to_node; }
119 uint64_t used;
120 uint64_t usedKernel;
121 uint64_t total;
122 uint64_t steal;
123 bool has_steal_ticks;
124 };
125
126 // which_logical_cpu=-1 returns accumulated ticks for all cpus.
127 static bool get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu);
128 static bool _stack_is_executable;
129 static void *dlopen_helper(const char *name, char *ebuf, int ebuflen);
130 static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen);
131
132 static void init_thread_fpu_state();
133 static int get_fpu_control_word();
134 static void set_fpu_control_word(int fpu_control);
135 static pthread_t main_thread(void) { return _main_thread; }
136 // returns kernel thread id (similar to LWP id on Solaris), which can be
137 // used to access /proc
138 static pid_t gettid();
139 static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
140 static Mutex* createThread_lock(void) { return _createThread_lock; }
141 static void hotspot_sigmask(Thread* thread);
142
143 static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; }
144 static uintptr_t initial_thread_stack_size(void) { return _initial_thread_stack_size; }
145
146 static int page_size(void) { return _page_size; }
147 static void set_page_size(int val) { _page_size = val; }
148
149 static address ucontext_get_pc(const ucontext_t* uc);
150 static void ucontext_set_pc(ucontext_t* uc, address pc);
151 static intptr_t* ucontext_get_sp(const ucontext_t* uc);
152 static intptr_t* ucontext_get_fp(const ucontext_t* uc);
153
154 // For Analyzer Forte AsyncGetCallTrace profiling support:
155 //
156 // This interface should be declared in os_linux_i486.hpp, but
157 // that file provides extensions to the os class and not the
158 // Linux class.
159 static ExtendedPC fetch_frame_from_ucontext(Thread* thread, const ucontext_t* uc,
160 intptr_t** ret_sp, intptr_t** ret_fp);
192 // Return default guard size for the specified thread type
193 static size_t default_guard_size(os::ThreadType thr_type);
194
195 static void capture_initial_stack(size_t max_size);
196
197 // Stack overflow handling
198 static bool manually_expand_stack(JavaThread * t, address addr);
199
200 // fast POSIX clocks support
201 static void fast_thread_clock_init(void);
202
203 static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
204 return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
205 }
206
207 static bool supports_fast_thread_cpu_time() {
208 return _supports_fast_thread_cpu_time;
209 }
210
211 static jlong fast_thread_cpu_time(clockid_t clockid);
212
213 static void initialize_os_info();
214 static uint32_t os_version();
215
216 // Stack repair handling
217
218 // none present
219
220 private:
221 static void numa_init();
222 static void expand_stack_to(address bottom);
223
224 typedef int (*sched_getcpu_func_t)(void);
225 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
226 typedef int (*numa_max_node_func_t)(void);
227 typedef int (*numa_num_configured_nodes_func_t)(void);
228 typedef int (*numa_available_func_t)(void);
229 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
230 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
231 typedef void (*numa_interleave_memory_v2_func_t)(void *start, size_t size, struct bitmask* mask);
232 typedef struct bitmask* (*numa_get_membind_func_t)(void);
233 typedef struct bitmask* (*numa_get_interleave_mask_func_t)(void);
234
|
38 static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
39 // __sigaction(), signal() is loaded
40 static struct sigaction *(*get_signal_action)(int);
41
42 static void check_signal_handler(int sig);
43
44 static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
45 static int (*_pthread_setname_np)(pthread_t, const char*);
46
47 static address _initial_thread_stack_bottom;
48 static uintptr_t _initial_thread_stack_size;
49
50 static const char *_glibc_version;
51 static const char *_libpthread_version;
52
53 static bool _supports_fast_thread_cpu_time;
54
55 static GrowableArray<int>* _cpu_to_node;
56 static GrowableArray<int>* _nindex_to_node;
57
58 protected:
59
60 static julong _physical_memory;
61 static pthread_t _main_thread;
62 static int _page_size;
63
64 static julong available_memory();
65 static julong physical_memory() { return _physical_memory; }
66 static void set_physical_memory(julong phys_mem) { _physical_memory = phys_mem; }
67 static int active_processor_count();
68
69 static void initialize_system_info();
70
71 static int commit_memory_impl(char* addr, size_t bytes, bool exec);
72 static int commit_memory_impl(char* addr, size_t bytes,
73 size_t alignment_hint, bool exec);
74
75 static void set_glibc_version(const char *s) { _glibc_version = s; }
76 static void set_libpthread_version(const char *s) { _libpthread_version = s; }
77
78 static void rebuild_cpu_to_node_map();
79 static void rebuild_nindex_to_node_map();
80 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
81 static GrowableArray<int>* nindex_to_node() { return _nindex_to_node; }
109 uint64_t used;
110 uint64_t usedKernel;
111 uint64_t total;
112 uint64_t steal;
113 bool has_steal_ticks;
114 };
115
116 // which_logical_cpu=-1 returns accumulated ticks for all cpus.
117 static bool get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu);
118 static bool _stack_is_executable;
119 static void *dlopen_helper(const char *name, char *ebuf, int ebuflen);
120 static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen);
121
122 static void init_thread_fpu_state();
123 static int get_fpu_control_word();
124 static void set_fpu_control_word(int fpu_control);
125 static pthread_t main_thread(void) { return _main_thread; }
126 // returns kernel thread id (similar to LWP id on Solaris), which can be
127 // used to access /proc
128 static pid_t gettid();
129 static void hotspot_sigmask(Thread* thread);
130
131 static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; }
132 static uintptr_t initial_thread_stack_size(void) { return _initial_thread_stack_size; }
133
134 static int page_size(void) { return _page_size; }
135 static void set_page_size(int val) { _page_size = val; }
136
137 static address ucontext_get_pc(const ucontext_t* uc);
138 static void ucontext_set_pc(ucontext_t* uc, address pc);
139 static intptr_t* ucontext_get_sp(const ucontext_t* uc);
140 static intptr_t* ucontext_get_fp(const ucontext_t* uc);
141
142 // For Analyzer Forte AsyncGetCallTrace profiling support:
143 //
144 // This interface should be declared in os_linux_i486.hpp, but
145 // that file provides extensions to the os class and not the
146 // Linux class.
147 static ExtendedPC fetch_frame_from_ucontext(Thread* thread, const ucontext_t* uc,
148 intptr_t** ret_sp, intptr_t** ret_fp);
180 // Return default guard size for the specified thread type
181 static size_t default_guard_size(os::ThreadType thr_type);
182
183 static void capture_initial_stack(size_t max_size);
184
185 // Stack overflow handling
186 static bool manually_expand_stack(JavaThread * t, address addr);
187
188 // fast POSIX clocks support
189 static void fast_thread_clock_init(void);
190
191 static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
192 return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
193 }
194
195 static bool supports_fast_thread_cpu_time() {
196 return _supports_fast_thread_cpu_time;
197 }
198
199 static jlong fast_thread_cpu_time(clockid_t clockid);
200
201 // Stack repair handling
202
203 // none present
204
205 private:
206 static void numa_init();
207 static void expand_stack_to(address bottom);
208
209 typedef int (*sched_getcpu_func_t)(void);
210 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
211 typedef int (*numa_max_node_func_t)(void);
212 typedef int (*numa_num_configured_nodes_func_t)(void);
213 typedef int (*numa_available_func_t)(void);
214 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
215 typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
216 typedef void (*numa_interleave_memory_v2_func_t)(void *start, size_t size, struct bitmask* mask);
217 typedef struct bitmask* (*numa_get_membind_func_t)(void);
218 typedef struct bitmask* (*numa_get_interleave_mask_func_t)(void);
219
|