Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/aix/vm/os_aix.hpp
32284 views
1
/*
2
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3
* Copyright 2013 SAP AG. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#ifndef OS_AIX_VM_OS_AIX_HPP
27
#define OS_AIX_VM_OS_AIX_HPP
28
29
// Information about the protection of the page at address '0' on this os.
30
static bool zero_page_read_protected() { return false; }
31
32
// Class Aix defines the interface to the Aix operating systems.
33
34
class Aix {
35
friend class os;
36
37
// For signal-chaining
38
// highest so far (AIX 5.2) is SIGSAK (63)
39
#define MAXSIGNUM 63
40
// length of strings included in the libperfstat structures
41
#define IDENTIFIER_LENGTH 64
42
43
static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
44
static unsigned int sigs; // mask of signals that have
45
// preinstalled signal handlers
46
static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
47
// __sigaction(), signal() is loaded
48
static struct sigaction *(*get_signal_action)(int);
49
static struct sigaction *get_preinstalled_handler(int);
50
static void save_preinstalled_handler(int, struct sigaction&);
51
52
static void check_signal_handler(int sig);
53
54
// For signal flags diagnostics
55
static int sigflags[MAXSIGNUM];
56
57
protected:
58
59
static julong _physical_memory;
60
static pthread_t _main_thread;
61
static Mutex* _createThread_lock;
62
static int _page_size;
63
static int _logical_cpus;
64
65
// -1 = uninitialized, 0 = AIX, 1 = OS/400 (PASE)
66
static int _on_pase;
67
68
// -1 = uninitialized, otherwise 16 bit number:
69
// lower 8 bit - minor version
70
// higher 8 bit - major version
71
// For AIX, e.g. 0x0601 for AIX 6.1
72
// for OS/400 e.g. 0x0504 for OS/400 V5R4
73
static int _os_version;
74
75
// -1 = uninitialized,
76
// 0 - SPEC1170 not requested (XPG_SUS_ENV is OFF or not set)
77
// 1 - SPEC1170 requested (XPG_SUS_ENV is ON)
78
static int _xpg_sus_mode;
79
80
// -1 = uninitialized,
81
// 0 - EXTSHM=OFF or not set
82
// 1 - EXTSHM=ON
83
static int _extshm;
84
85
// page sizes on AIX.
86
//
87
// AIX supports four different page sizes - 4K, 64K, 16MB, 16GB. The latter two
88
// (16M "large" resp. 16G "huge" pages) require special setup and are normally
89
// not available.
90
//
91
// AIX supports multiple page sizes per process, for:
92
// - Stack (of the primordial thread, so not relevant for us)
93
// - Data - data, bss, heap, for us also pthread stacks
94
// - Text - text code
95
// - shared memory
96
//
97
// Default page sizes can be set via linker options (-bdatapsize, -bstacksize, ...)
98
// and via environment variable LDR_CNTRL (DATAPSIZE, STACKPSIZE, ...)
99
//
100
// For shared memory, page size can be set dynamically via shmctl(). Different shared memory
101
// regions can have different page sizes.
102
//
103
// More information can be found at AIBM info center:
104
// http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.prftungd/doc/prftungd/multiple_page_size_app_support.htm
105
//
106
// -----
107
// We want to support 4K and 64K and, if the machine is set up correctly, 16MB pages.
108
//
109
110
// page size of the stack of newly created pthreads
111
// (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib)
112
static int _stack_page_size;
113
114
// Default shm page size. Read: what page size shared memory will be backed
115
// with if no page size was set explicitly using shmctl(SHM_PAGESIZE).
116
// Should be LDR_CNTRL SHMPSIZE.
117
static size_t _shm_default_page_size;
118
119
// True if sys V shm can be used with 64K pages dynamically.
120
// (via shmctl(.. SHM_PAGESIZE..). Should be true for AIX 53 and
121
// newer / PASE V6R1 and newer. (0 or 1, -1 if not initialized)
122
static int _can_use_64K_pages;
123
124
// True if sys V shm can be used with 16M pages dynamically.
125
// (via shmctl(.. SHM_PAGESIZE..). Only true on AIX 5.3 and
126
// newer, if the system was set up to use 16M pages and the
127
// jvm has enough user rights. (0 or 1, -1 if not initialized)
128
static int _can_use_16M_pages;
129
130
static julong available_memory();
131
static julong physical_memory() { return _physical_memory; }
132
static void initialize_system_info();
133
134
// OS recognitions (PASE/AIX, OS level) call this before calling any
135
// one of Aix::on_pase(), Aix::os_version().
136
static void initialize_os_info();
137
138
static int commit_memory_impl(char* addr, size_t bytes, bool exec);
139
static int commit_memory_impl(char* addr, size_t bytes,
140
size_t alignment_hint, bool exec);
141
142
// Scan environment for important settings which might effect the
143
// VM. Trace out settings. Warn about invalid settings and/or
144
// correct them.
145
//
146
// Must run after os::Aix::initialue_os_info().
147
static void scan_environment();
148
149
// Retrieve information about multipage size support. Will initialize
150
// _page_size, _stack_page_size, _can_use_64K_pages/_can_use_16M_pages
151
static void query_multipage_support();
152
153
// Initialize libo4 (on PASE) and libperfstat (on AIX). Call this
154
// before relying on functions from either lib, e.g. Aix::get_meminfo().
155
static void initialize_libo4();
156
static void initialize_libperfstat();
157
158
static bool supports_variable_stack_size();
159
160
public:
161
static void init_thread_fpu_state();
162
static pthread_t main_thread(void) { return _main_thread; }
163
// returns kernel thread id (similar to LWP id on Solaris), which can be
164
// used to access /proc
165
static pid_t gettid();
166
static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
167
static Mutex* createThread_lock(void) { return _createThread_lock; }
168
static void hotspot_sigmask(Thread* thread);
169
170
// Given an address, returns the size of the page backing that address
171
static size_t query_pagesize(void* p);
172
173
static int page_size(void) {
174
assert(_page_size != -1, "not initialized");
175
return _page_size;
176
}
177
178
// Accessor methods for stack page size which may be different from usual page size.
179
static int stack_page_size(void) {
180
assert(_stack_page_size != -1, "not initialized");
181
return _stack_page_size;
182
}
183
184
// default shm page size. Read: what page size shared memory
185
// will be backed with if no page size was set explicitly using shmctl(SHM_PAGESIZE).
186
// Should be LDR_CNTRL SHMPSIZE.
187
static int shm_default_page_size(void) {
188
assert(_shm_default_page_size != -1, "not initialized");
189
return _shm_default_page_size;
190
}
191
192
// Return true if sys V shm can be used with 64K pages dynamically
193
// (via shmctl(.. SHM_PAGESIZE..).
194
static bool can_use_64K_pages () {
195
assert(_can_use_64K_pages != -1, "not initialized");
196
return _can_use_64K_pages == 1 ? true : false;
197
}
198
199
// Return true if sys V shm can be used with 16M pages dynamically.
200
// (via shmctl(.. SHM_PAGESIZE..).
201
static bool can_use_16M_pages () {
202
assert(_can_use_16M_pages != -1, "not initialized");
203
return _can_use_16M_pages == 1 ? true : false;
204
}
205
206
static address ucontext_get_pc(const ucontext_t* uc);
207
static intptr_t* ucontext_get_sp(ucontext_t* uc);
208
static intptr_t* ucontext_get_fp(ucontext_t* uc);
209
// Set PC into context. Needed for continuation after signal.
210
static void ucontext_set_pc(ucontext_t* uc, address pc);
211
212
// This boolean allows users to forward their own non-matching signals
213
// to JVM_handle_aix_signal, harmlessly.
214
static bool signal_handlers_are_installed;
215
216
static int get_our_sigflags(int);
217
static void set_our_sigflags(int, int);
218
static void signal_sets_init();
219
static void install_signal_handlers();
220
static void set_signal_handler(int, bool);
221
static bool is_sig_ignored(int sig);
222
223
static sigset_t* unblocked_signals();
224
static sigset_t* vm_signals();
225
static sigset_t* allowdebug_blocked_signals();
226
227
// For signal-chaining
228
static struct sigaction *get_chained_signal_action(int sig);
229
static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
230
231
// libpthread version string
232
static void libpthread_init();
233
234
// Minimum stack size a thread can be created with (allowing
235
// the VM to completely create the thread and enter user code)
236
static size_t min_stack_allowed;
237
238
// Return default stack size or guard size for the specified thread type
239
static size_t default_stack_size(os::ThreadType thr_type);
240
static size_t default_guard_size(os::ThreadType thr_type);
241
242
// Function returns true if we run on OS/400 (pase), false if we run
243
// on AIX.
244
static bool on_pase() {
245
assert(_on_pase != -1, "not initialized");
246
return _on_pase ? true : false;
247
}
248
249
// Function returns true if we run on AIX, false if we run on OS/400
250
// (pase).
251
static bool on_aix() {
252
assert(_on_pase != -1, "not initialized");
253
return _on_pase ? false : true;
254
}
255
256
// -1 = uninitialized, otherwise 16 bit number:
257
// lower 8 bit - minor version
258
// higher 8 bit - major version
259
// For AIX, e.g. 0x0601 for AIX 6.1
260
// for OS/400 e.g. 0x0504 for OS/400 V5R4
261
static int os_version () {
262
assert(_os_version != -1, "not initialized");
263
return _os_version;
264
}
265
266
// Convenience method: returns true if running on AIX 5.3 or older.
267
static bool on_aix_53_or_older() {
268
return on_aix() && os_version() <= 0x0503;
269
}
270
271
// Returns true if we run in SPEC1170 compliant mode (XPG_SUS_ENV=ON).
272
static bool xpg_sus_mode() {
273
assert(_xpg_sus_mode != -1, "not initialized");
274
return _xpg_sus_mode;
275
}
276
277
// Returns true if EXTSHM=ON.
278
static bool extshm() {
279
assert(_extshm != -1, "not initialized");
280
return _extshm;
281
}
282
283
// result struct for get_meminfo()
284
struct meminfo_t {
285
286
// Amount of virtual memory (in units of 4 KB pages)
287
unsigned long long virt_total;
288
289
// Amount of real memory, in bytes
290
unsigned long long real_total;
291
292
// Amount of free real memory, in bytes
293
unsigned long long real_free;
294
295
// Total amount of paging space, in bytes
296
unsigned long long pgsp_total;
297
298
// Amount of free paging space, in bytes
299
unsigned long long pgsp_free;
300
301
};
302
303
// Result struct for get_cpuinfo().
304
struct cpuinfo_t {
305
char description[IDENTIFIER_LENGTH]; // processor description (type/official name)
306
u_longlong_t processorHZ; // processor speed in Hz
307
int ncpus; // number of active logical processors
308
double loadavg[3]; // (1<<SBITS) times the average number of runnables processes during the last 1, 5 and 15 minutes.
309
// To calculate the load average, divide the numbers by (1<<SBITS). SBITS is defined in <sys/proc.h>.
310
char version[20]; // processor version from _system_configuration (sys/systemcfg.h)
311
};
312
313
// Functions to retrieve memory information on AIX, PASE.
314
// (on AIX, using libperfstat, on PASE with libo4.so).
315
// Returns true if ok, false if error.
316
static bool get_meminfo(meminfo_t* pmi);
317
318
// Function to retrieve cpu information on AIX
319
// (on AIX, using libperfstat)
320
// Returns true if ok, false if error.
321
static bool get_cpuinfo(cpuinfo_t* pci);
322
323
}; // os::Aix class
324
325
326
class PlatformEvent : public CHeapObj<mtInternal> {
327
private:
328
double CachePad [4]; // increase odds that _mutex is sole occupant of cache line
329
volatile int _Event;
330
volatile int _nParked;
331
pthread_mutex_t _mutex [1];
332
pthread_cond_t _cond [1];
333
double PostPad [2];
334
Thread * _Assoc;
335
336
public: // TODO-FIXME: make dtor private
337
~PlatformEvent() { guarantee (0, "invariant"); }
338
339
public:
340
PlatformEvent() {
341
int status;
342
status = pthread_cond_init (_cond, NULL);
343
assert_status(status == 0, status, "cond_init");
344
status = pthread_mutex_init (_mutex, NULL);
345
assert_status(status == 0, status, "mutex_init");
346
_Event = 0;
347
_nParked = 0;
348
_Assoc = NULL;
349
}
350
351
// Use caution with reset() and fired() -- they may require MEMBARs
352
void reset() { _Event = 0; }
353
int fired() { return _Event; }
354
void park ();
355
void unpark ();
356
int TryPark ();
357
int park (jlong millis);
358
void SetAssociation (Thread * a) { _Assoc = a; }
359
};
360
361
class PlatformParker : public CHeapObj<mtInternal> {
362
protected:
363
pthread_mutex_t _mutex [1];
364
pthread_cond_t _cond [1];
365
366
public: // TODO-FIXME: make dtor private
367
~PlatformParker() { guarantee (0, "invariant"); }
368
369
public:
370
PlatformParker() {
371
int status;
372
status = pthread_cond_init (_cond, NULL);
373
assert_status(status == 0, status, "cond_init");
374
status = pthread_mutex_init (_mutex, NULL);
375
assert_status(status == 0, status, "mutex_init");
376
}
377
};
378
379
#endif // OS_AIX_VM_OS_AIX_HPP
380
381