From d92946b2e86b3c9bc78f9ad25c5bfe15aef0f661 Mon Sep 17 00:00:00 2001 From: jcoomes Date: Wed, 17 Aug 2011 10:32:53 -0700 Subject: [PATCH] 6791672: enable 1G and larger pages on solaris Reviewed-by: ysr, iveresov, johnc --- src/os/solaris/vm/os_solaris.cpp | 29 ++++++++++++++++++----------- src/share/vm/runtime/os.cpp | 11 +++++++++++ src/share/vm/runtime/os.hpp | 4 +++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/os/solaris/vm/os_solaris.cpp b/src/os/solaris/vm/os_solaris.cpp index 3280040da..4fa64a284 100644 --- a/src/os/solaris/vm/os_solaris.cpp +++ b/src/os/solaris/vm/os_solaris.cpp @@ -3252,7 +3252,6 @@ bool os::unguard_memory(char* addr, size_t bytes) { // supported Solaris versions, this combination // is equivalent to +UseISM -UseMPSS. -typedef int (*getpagesizes_func_type) (size_t[], int); static size_t _large_page_size = 0; bool os::Solaris::ism_sanity_check(bool warn, size_t * page_size) { @@ -3284,23 +3283,29 @@ static void insertion_sort_descending(size_t* array, int len) { } bool os::Solaris::mpss_sanity_check(bool warn, size_t * page_size) { - getpagesizes_func_type getpagesizes_func = - CAST_TO_FN_PTR(getpagesizes_func_type, dlsym(RTLD_DEFAULT, "getpagesizes")); - if (getpagesizes_func == NULL) { - if (warn) { - warning("MPSS is not supported by the operating system."); - } - return false; - } - const unsigned int usable_count = VM_Version::page_size_count(); if (usable_count == 1) { return false; } + // Find the right getpagesizes interface. When solaris 11 is the minimum + // build platform, getpagesizes() (without the '2') can be called directly. + typedef int (*gps_t)(size_t[], int); + gps_t gps_func = CAST_TO_FN_PTR(gps_t, dlsym(RTLD_DEFAULT, "getpagesizes2")); + if (gps_func == NULL) { + gps_func = CAST_TO_FN_PTR(gps_t, dlsym(RTLD_DEFAULT, "getpagesizes")); + if (gps_func == NULL) { + if (warn) { + warning("MPSS is not supported by the operating system."); + } + return false; + } + } + // Fill the array of page sizes. - int n = getpagesizes_func(_page_sizes, page_sizes_max); + int n = (*gps_func)(_page_sizes, page_sizes_max); assert(n > 0, "Solaris bug?"); + if (n == page_sizes_max) { // Add a sentinel value (necessary only if the array was completely filled // since it is static (zeroed at initialization)). @@ -3308,6 +3313,7 @@ bool os::Solaris::mpss_sanity_check(bool warn, size_t * page_size) { DEBUG_ONLY(warning("increase the size of the os::_page_sizes array.");) } assert(_page_sizes[n] == 0, "missing sentinel"); + trace_page_sizes("available page sizes", _page_sizes, n); if (n == 1) return false; // Only one page size available. @@ -3337,6 +3343,7 @@ bool os::Solaris::mpss_sanity_check(bool warn, size_t * page_size) { } *page_size = _page_sizes[0]; + trace_page_sizes("usable page sizes", _page_sizes, end + 1); return true; } diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp index 5da110807..aa3fbdb32 100644 --- a/src/share/vm/runtime/os.cpp +++ b/src/share/vm/runtime/os.cpp @@ -1232,6 +1232,17 @@ size_t os::page_size_for_region(size_t region_min_size, size_t region_max_size, } #ifndef PRODUCT +void os::trace_page_sizes(const char* str, const size_t* page_sizes, int count) +{ + if (TracePageSizes) { + tty->print("%s: ", str); + for (int i = 0; i < count; ++i) { + tty->print(" " SIZE_FORMAT, page_sizes[i]); + } + tty->cr(); + } +} + void os::trace_page_sizes(const char* str, const size_t region_min_size, const size_t region_max_size, const size_t page_size, const char* base, const size_t size) diff --git a/src/share/vm/runtime/os.hpp b/src/share/vm/runtime/os.hpp index 0b401b1f8..b43100d1f 100644 --- a/src/share/vm/runtime/os.hpp +++ b/src/share/vm/runtime/os.hpp @@ -208,11 +208,13 @@ class os: AllStatic { size_t region_max_size, uint min_pages); - // Method for tracing page sizes returned by the above method; enabled by + // Methods for tracing page sizes returned by the above method; enabled by // TracePageSizes. The region_{min,max}_size parameters should be the values // passed to page_size_for_region() and page_size should be the result of that // call. The (optional) base and size parameters should come from the // ReservedSpace base() and size() methods. + static void trace_page_sizes(const char* str, const size_t* page_sizes, + int count) PRODUCT_RETURN; static void trace_page_sizes(const char* str, const size_t region_min_size, const size_t region_max_size, const size_t page_size, -- GitLab