comparison src/os/solaris/vm/os_solaris.cpp @ 3859:24cee90e9453

6791672: enable 1G and larger pages on solaris Reviewed-by: ysr, iveresov, johnc
author jcoomes
date Wed, 17 Aug 2011 10:32:53 -0700
parents bf6481e5f96d
children 3cd0157e1d4d
comparison
equal deleted inserted replaced
3831:76b1a9420e3d 3859:24cee90e9453
3250 // Otherwise, JVM will fall back to MPSS. 3250 // Otherwise, JVM will fall back to MPSS.
3251 // Becaues ISM is now available on all 3251 // Becaues ISM is now available on all
3252 // supported Solaris versions, this combination 3252 // supported Solaris versions, this combination
3253 // is equivalent to +UseISM -UseMPSS. 3253 // is equivalent to +UseISM -UseMPSS.
3254 3254
3255 typedef int (*getpagesizes_func_type) (size_t[], int);
3256 static size_t _large_page_size = 0; 3255 static size_t _large_page_size = 0;
3257 3256
3258 bool os::Solaris::ism_sanity_check(bool warn, size_t * page_size) { 3257 bool os::Solaris::ism_sanity_check(bool warn, size_t * page_size) {
3259 // x86 uses either 2M or 4M page, depending on whether PAE (Physical Address 3258 // x86 uses either 2M or 4M page, depending on whether PAE (Physical Address
3260 // Extensions) mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. Sparc 3259 // Extensions) mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. Sparc
3282 } 3281 }
3283 } 3282 }
3284 } 3283 }
3285 3284
3286 bool os::Solaris::mpss_sanity_check(bool warn, size_t * page_size) { 3285 bool os::Solaris::mpss_sanity_check(bool warn, size_t * page_size) {
3287 getpagesizes_func_type getpagesizes_func =
3288 CAST_TO_FN_PTR(getpagesizes_func_type, dlsym(RTLD_DEFAULT, "getpagesizes"));
3289 if (getpagesizes_func == NULL) {
3290 if (warn) {
3291 warning("MPSS is not supported by the operating system.");
3292 }
3293 return false;
3294 }
3295
3296 const unsigned int usable_count = VM_Version::page_size_count(); 3286 const unsigned int usable_count = VM_Version::page_size_count();
3297 if (usable_count == 1) { 3287 if (usable_count == 1) {
3298 return false; 3288 return false;
3299 } 3289 }
3300 3290
3291 // Find the right getpagesizes interface. When solaris 11 is the minimum
3292 // build platform, getpagesizes() (without the '2') can be called directly.
3293 typedef int (*gps_t)(size_t[], int);
3294 gps_t gps_func = CAST_TO_FN_PTR(gps_t, dlsym(RTLD_DEFAULT, "getpagesizes2"));
3295 if (gps_func == NULL) {
3296 gps_func = CAST_TO_FN_PTR(gps_t, dlsym(RTLD_DEFAULT, "getpagesizes"));
3297 if (gps_func == NULL) {
3298 if (warn) {
3299 warning("MPSS is not supported by the operating system.");
3300 }
3301 return false;
3302 }
3303 }
3304
3301 // Fill the array of page sizes. 3305 // Fill the array of page sizes.
3302 int n = getpagesizes_func(_page_sizes, page_sizes_max); 3306 int n = (*gps_func)(_page_sizes, page_sizes_max);
3303 assert(n > 0, "Solaris bug?"); 3307 assert(n > 0, "Solaris bug?");
3308
3304 if (n == page_sizes_max) { 3309 if (n == page_sizes_max) {
3305 // Add a sentinel value (necessary only if the array was completely filled 3310 // Add a sentinel value (necessary only if the array was completely filled
3306 // since it is static (zeroed at initialization)). 3311 // since it is static (zeroed at initialization)).
3307 _page_sizes[--n] = 0; 3312 _page_sizes[--n] = 0;
3308 DEBUG_ONLY(warning("increase the size of the os::_page_sizes array.");) 3313 DEBUG_ONLY(warning("increase the size of the os::_page_sizes array.");)
3309 } 3314 }
3310 assert(_page_sizes[n] == 0, "missing sentinel"); 3315 assert(_page_sizes[n] == 0, "missing sentinel");
3316 trace_page_sizes("available page sizes", _page_sizes, n);
3311 3317
3312 if (n == 1) return false; // Only one page size available. 3318 if (n == 1) return false; // Only one page size available.
3313 3319
3314 // Skip sizes larger than 4M (or LargePageSizeInBytes if it was set) and 3320 // Skip sizes larger than 4M (or LargePageSizeInBytes if it was set) and
3315 // select up to usable_count elements. First sort the array, find the first 3321 // select up to usable_count elements. First sort the array, find the first
3335 // Default page size is not the smallest; sort again. 3341 // Default page size is not the smallest; sort again.
3336 insertion_sort_descending(_page_sizes, end + 1); 3342 insertion_sort_descending(_page_sizes, end + 1);
3337 } 3343 }
3338 *page_size = _page_sizes[0]; 3344 *page_size = _page_sizes[0];
3339 3345
3346 trace_page_sizes("usable page sizes", _page_sizes, end + 1);
3340 return true; 3347 return true;
3341 } 3348 }
3342 3349
3343 void os::large_page_init() { 3350 void os::large_page_init() {
3344 if (!UseLargePages) { 3351 if (!UseLargePages) {