5252#include " runtime/javaThread.hpp"
5353#include " runtime/mutexLocker.hpp"
5454#include " runtime/objectMonitor.hpp"
55+ #include " runtime/osInfo.hpp"
5556#include " runtime/osThread.hpp"
5657#include " runtime/perfMemory.hpp"
5758#include " runtime/sharedRuntime.hpp"
@@ -162,7 +163,6 @@ uintptr_t os::Linux::_initial_thread_stack_size = 0;
162163int (*os::Linux::_pthread_getcpuclockid)(pthread_t , clockid_t *) = NULL ;
163164int (*os::Linux::_pthread_setname_np)(pthread_t , const char *) = NULL ;
164165pthread_t os::Linux::_main_thread;
165- int os::Linux::_page_size = -1 ;
166166bool os::Linux::_supports_fast_thread_cpu_time = false ;
167167const char * os::Linux::_libc_version = NULL ;
168168const char * os::Linux::_libpthread_version = NULL ;
@@ -605,8 +605,8 @@ static void NOINLINE _expand_stack_to(address bottom) {
605605
606606 // Adjust bottom to point to the largest address within the same page, it
607607 // gives us a one-page buffer if alloca() allocates slightly more memory.
608- bottom = (address)align_down ((uintptr_t )bottom, os::Linux::page_size ());
609- bottom += os::Linux::page_size () - 1 ;
608+ bottom = (address)align_down ((uintptr_t )bottom, os::vm_page_size ());
609+ bottom += os::vm_page_size () - 1 ;
610610
611611 // sp might be slightly above current stack pointer; if that's the case, we
612612 // will alloca() a little more space than necessary, which is OK. Don't use
@@ -1078,8 +1078,8 @@ void os::Linux::capture_initial_stack(size_t max_size) {
10781078 // lower end of primordial stack; reduce ulimit -s value a little bit
10791079 // so we won't install guard page on ld.so's data section.
10801080 // But ensure we don't underflow the stack size - allow 1 page spare
1081- if (stack_size >= (size_t )(3 * page_size ())) {
1082- stack_size -= 2 * page_size ();
1081+ if (stack_size >= (size_t )(3 * os::vm_page_size ())) {
1082+ stack_size -= 2 * os::vm_page_size ();
10831083 }
10841084
10851085 // Try to figure out where the stack base (top) is. This is harder.
@@ -1235,11 +1235,11 @@ void os::Linux::capture_initial_stack(size_t max_size) {
12351235 // stack top, use it as stack top, and reduce stack size so we won't put
12361236 // guard page outside stack.
12371237 stack_top = stack_start;
1238- stack_size -= 16 * page_size ();
1238+ stack_size -= 16 * os::vm_page_size ();
12391239 }
12401240
12411241 // stack_top could be partially down the page so align it
1242- stack_top = align_up (stack_top, page_size ());
1242+ stack_top = align_up (stack_top, os::vm_page_size ());
12431243
12441244 // Allowed stack value is minimum of max_size and what we derived from rlimit
12451245 if (max_size > 0 ) {
@@ -1249,7 +1249,7 @@ void os::Linux::capture_initial_stack(size_t max_size) {
12491249 // clamp it at 8MB as we do on Solaris
12501250 _initial_thread_stack_size = MIN2 (stack_size, 8 *M);
12511251 }
1252- _initial_thread_stack_size = align_down (_initial_thread_stack_size, page_size ());
1252+ _initial_thread_stack_size = align_down (_initial_thread_stack_size, os::vm_page_size ());
12531253 _initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
12541254
12551255 assert (_initial_thread_stack_bottom < (address)stack_top, " overflow!" );
@@ -2594,18 +2594,6 @@ void os::jvm_path(char *buf, jint buflen) {
25942594// //////////////////////////////////////////////////////////////////////////////
25952595// Virtual Memory
25962596
2597- int os::vm_page_size () {
2598- // Seems redundant as all get out
2599- assert (os::Linux::page_size () != -1 , " must call os::init" );
2600- return os::Linux::page_size ();
2601- }
2602-
2603- // Solaris allocates memory by pages.
2604- int os::vm_allocation_granularity () {
2605- assert (os::Linux::page_size () != -1 , " must call os::init" );
2606- return os::Linux::page_size ();
2607- }
2608-
26092597// Rationale behind this function:
26102598// current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable
26112599// mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get
@@ -3012,7 +3000,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
30123000 // Creating guard page is very expensive. Java thread has HotSpot
30133001 // guard pages, only enable glibc guard page for non-Java threads.
30143002 // (Remember: compiler thread is a Java thread, too!)
3015- return ((thr_type == java_thread || thr_type == compiler_thread) ? 0 : page_size ());
3003+ return ((thr_type == java_thread || thr_type == compiler_thread) ? 0 : os::vm_page_size ());
30163004}
30173005
30183006void os::Linux::rebuild_nindex_to_node_map () {
@@ -3423,7 +3411,7 @@ extern char* g_assert_poison; // assertion poison page address
34233411
34243412static bool linux_mprotect (char * addr, size_t size, int prot) {
34253413 // Linux wants the mprotect address argument to be page aligned.
3426- char * bottom = (char *)align_down ((intptr_t )addr, os::Linux::page_size ());
3414+ char * bottom = (char *)align_down ((intptr_t )addr, os::vm_page_size ());
34273415
34283416 // According to SUSv3, mprotect() should only be used with mappings
34293417 // established by mmap(), and mmap() always maps whole pages. Unaligned
@@ -3432,7 +3420,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) {
34323420 // caller if you hit this assert.
34333421 assert (addr == bottom, " sanity check" );
34343422
3435- size = align_up (pointer_delta (addr, bottom, 1 ) + size, os::Linux::page_size ());
3423+ size = align_up (pointer_delta (addr, bottom, 1 ) + size, os::vm_page_size ());
34363424 // Don't log anything if we're executing in the poison page signal handling
34373425 // context. It can lead to reentrant use of other parts of the VM code.
34383426#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
@@ -4315,7 +4303,7 @@ extern void report_error(char* file_name, int line_no, char* title,
43154303static void check_pax (void ) {
43164304 // Zero doesn't generate code dynamically, so no need to perform the PaX check
43174305#ifndef ZERO
4318- size_t size = os::Linux::page_size ();
4306+ size_t size = os::vm_page_size ();
43194307
43204308 void * p = ::mmap (NULL , size, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1 , 0 );
43214309 if (p == MAP_FAILED) {
@@ -4340,12 +4328,14 @@ void os::init(void) {
43404328
43414329 clock_tics_per_sec = sysconf (_SC_CLK_TCK);
43424330
4343- Linux::set_page_size (sysconf (_SC_PAGESIZE));
4344- if (Linux::page_size () == -1 ) {
4331+ int page_size = sysconf (_SC_PAGESIZE);
4332+ OSInfo::set_vm_page_size (page_size);
4333+ OSInfo::set_vm_allocation_granularity (page_size);
4334+ if (os::vm_page_size () <= 0 ) {
43454335 fatal (" os_linux.cpp: os::init: sysconf failed (%s)" ,
43464336 os::strerror (errno));
43474337 }
4348- _page_sizes.add (Linux::page_size ());
4338+ _page_sizes.add (os::vm_page_size ());
43494339
43504340 Linux::initialize_system_info ();
43514341
0 commit comments