18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef OS_LINUX_VM_OS_LINUX_HPP
26 #define OS_LINUX_VM_OS_LINUX_HPP
27
28 // Linux_OS defines the interface to Linux operating systems
29
30 /* pthread_getattr_np comes with LinuxThreads-0.9-7 on RedHat 7.1 */
31 typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
32
33 // Information about the protection of the page at address '0' on this os.
34 static bool zero_page_read_protected() { return true; }
35
36 class Linux {
37 friend class os;
38 friend class TestReserveMemorySpecial;
39
40 // For signal-chaining
41 #define MAXSIGNUM 32
42 static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
43 static unsigned int sigs; // mask of signals that have
44 // preinstalled signal handlers
45 static bool libjsig_is_loaded; // libjsig that interposes sigaction(),
46 // __sigaction(), signal() is loaded
47 static struct sigaction *(*get_signal_action)(int);
48 static struct sigaction *get_preinstalled_handler(int);
49 static void save_preinstalled_handler(int, struct sigaction&);
50
51 static void check_signal_handler(int sig);
52
53 // For signal flags diagnostics
54 static int sigflags[MAXSIGNUM];
55
56 static int (*_clock_gettime)(clockid_t, struct timespec *);
57 static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
62 static const char *_glibc_version;
63 static const char *_libpthread_version;
64
65 static bool _is_floating_stack;
66 static bool _is_NPTL;
67 static bool _supports_fast_thread_cpu_time;
68
69 static GrowableArray<int>* _cpu_to_node;
70 static GrowableArray<int>* _nindex_to_node;
71
72 protected:
73
74 static julong _physical_memory;
75 static pthread_t _main_thread;
76 static Mutex* _createThread_lock;
77 static int _page_size;
78 static const int _vm_default_page_size;
79
80 static julong available_memory();
81 static julong physical_memory() { return _physical_memory; }
82 static void initialize_system_info();
83
84 static int commit_memory_impl(char* addr, size_t bytes, bool exec);
85 static int commit_memory_impl(char* addr, size_t bytes,
86 size_t alignment_hint, bool exec);
87
88 static void set_glibc_version(const char *s) { _glibc_version = s; }
89 static void set_libpthread_version(const char *s) { _libpthread_version = s; }
90
91 static bool supports_variable_stack_size();
92
93 static void set_is_NPTL() { _is_NPTL = true; }
94 static void set_is_LinuxThreads() { _is_NPTL = false; }
95 static void set_is_floating_stack() { _is_floating_stack = true; }
96
97 static void rebuild_cpu_to_node_map();
98 static void rebuild_nindex_to_node_map();
99 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
100 static GrowableArray<int>* nindex_to_node() { return _nindex_to_node; }
101
102 static size_t find_large_page_size();
103 static size_t setup_large_page_size();
104
105 static bool setup_large_page_type(size_t page_size);
106 static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size);
107 static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
108
109 static char* reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec);
110 static char* reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec);
111 static char* reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec);
112 static char* reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec);
113
114 static bool release_memory_special_impl(char* base, size_t bytes);
115 static bool release_memory_special_shm(char* base, size_t bytes);
116 static bool release_memory_special_huge_tlbfs(char* base, size_t bytes);
117
118 static void print_full_memory_info(outputStream* st);
119 static void print_distro_info(outputStream* st);
120 static void print_libversion_info(outputStream* st);
121
122 public:
123 static bool _stack_is_executable;
124 static void *dlopen_helper(const char *name, char *ebuf, int ebuflen);
125 static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen);
126
127 static void init_thread_fpu_state();
128 static int get_fpu_control_word();
129 static void set_fpu_control_word(int fpu_control);
130 static pthread_t main_thread(void) { return _main_thread; }
131 // returns kernel thread id (similar to LWP id on Solaris), which can be
132 // used to access /proc
133 static pid_t gettid();
134 static void set_createThread_lock(Mutex* lk) { _createThread_lock = lk; }
135 static Mutex* createThread_lock(void) { return _createThread_lock; }
136 static void hotspot_sigmask(Thread* thread);
137
138 static address initial_thread_stack_bottom(void) { return _initial_thread_stack_bottom; }
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef OS_LINUX_VM_OS_LINUX_HPP
26 #define OS_LINUX_VM_OS_LINUX_HPP
27
28 // Linux_OS defines the interface to Linux operating systems
29
30 /* pthread_getattr_np comes with LinuxThreads-0.9-7 on RedHat 7.1 */
31 typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
32
33 // Information about the protection of the page at address '0' on this os.
34 static bool zero_page_read_protected() { return true; }
35
36 class Linux {
37 friend class os;
38 friend class OSContainer;
39 friend class TestReserveMemorySpecial;
40
41 // For signal-chaining
42 #define MAXSIGNUM 32
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 static int (*_clock_gettime)(clockid_t, struct timespec *);
58 static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
63 static const char *_glibc_version;
64 static const char *_libpthread_version;
65
66 static bool _is_floating_stack;
67 static bool _is_NPTL;
68 static bool _supports_fast_thread_cpu_time;
69
70 static GrowableArray<int>* _cpu_to_node;
71 static GrowableArray<int>* _nindex_to_node;
72
73 protected:
74
75 static julong _physical_memory;
76 static pthread_t _main_thread;
77 static Mutex* _createThread_lock;
78 static int _page_size;
79 static const int _vm_default_page_size;
80
81 static julong available_memory();
82 static julong physical_memory() { return _physical_memory; }
83 static void set_physical_memory(julong phys_mem) { _physical_memory = phys_mem; }
84 static int active_processor_count();
85
86 static void initialize_system_info();
87
88 static int commit_memory_impl(char* addr, size_t bytes, bool exec);
89 static int commit_memory_impl(char* addr, size_t bytes,
90 size_t alignment_hint, bool exec);
91
92 static void set_glibc_version(const char *s) { _glibc_version = s; }
93 static void set_libpthread_version(const char *s) { _libpthread_version = s; }
94
95 static bool supports_variable_stack_size();
96
97 static void set_is_NPTL() { _is_NPTL = true; }
98 static void set_is_LinuxThreads() { _is_NPTL = false; }
99 static void set_is_floating_stack() { _is_floating_stack = true; }
100
101 static void rebuild_cpu_to_node_map();
102 static void rebuild_nindex_to_node_map();
103 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
104 static GrowableArray<int>* nindex_to_node() { return _nindex_to_node; }
105
106 static size_t find_large_page_size();
107 static size_t setup_large_page_size();
108
109 static bool setup_large_page_type(size_t page_size);
110 static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size);
111 static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
112
113 static char* reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec);
114 static char* reserve_memory_special_huge_tlbfs(size_t bytes, size_t alignment, char* req_addr, bool exec);
115 static char* reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec);
116 static char* reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec);
117
118 static bool release_memory_special_impl(char* base, size_t bytes);
119 static bool release_memory_special_shm(char* base, size_t bytes);
120 static bool release_memory_special_huge_tlbfs(char* base, size_t bytes);
121
122 static void print_full_memory_info(outputStream* st);
123 static void print_container_info(outputStream* st);
124 static void print_distro_info(outputStream* st);
125 static void print_libversion_info(outputStream* st);
126
127 public:
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; }
|