comparison src/os/linux/vm/os_linux.cpp @ 3318:188c9a5d6a6d

7040485: Use transparent huge page on linux by default Summary: Turn on UseLargePages by default but try only HugeTLBFS method if it is not explicitly specified on the command line. Reviewed-by: ysr
author iveresov
date Fri, 29 Apr 2011 12:39:32 -0700
parents c303b3532d4a
children 97b64f73103b
comparison
equal deleted inserted replaced
3315:da0fffdcc453 3318:188c9a5d6a6d
2912 2912
2913 // Large page support 2913 // Large page support
2914 2914
2915 static size_t _large_page_size = 0; 2915 static size_t _large_page_size = 0;
2916 2916
2917 bool os::large_page_init() { 2917 void os::large_page_init() {
2918 if (!UseLargePages) { 2918 if (!UseLargePages) {
2919 UseHugeTLBFS = false; 2919 UseHugeTLBFS = false;
2920 UseSHM = false; 2920 UseSHM = false;
2921 return false; 2921 return;
2922 } 2922 }
2923 2923
2924 if (FLAG_IS_DEFAULT(UseHugeTLBFS) && FLAG_IS_DEFAULT(UseSHM)) { 2924 if (FLAG_IS_DEFAULT(UseHugeTLBFS) && FLAG_IS_DEFAULT(UseSHM)) {
2925 // Our user has not expressed a preference, so we'll try both. 2925 // If UseLargePages is specified on the command line try both methods,
2926 UseHugeTLBFS = UseSHM = true; 2926 // if it's default, then try only HugeTLBFS.
2927 if (FLAG_IS_DEFAULT(UseLargePages)) {
2928 UseHugeTLBFS = true;
2929 } else {
2930 UseHugeTLBFS = UseSHM = true;
2931 }
2927 } 2932 }
2928 2933
2929 if (LargePageSizeInBytes) { 2934 if (LargePageSizeInBytes) {
2930 _large_page_size = LargePageSizeInBytes; 2935 _large_page_size = LargePageSizeInBytes;
2931 } else { 2936 } else {
2976 if (_large_page_size > default_page_size) { 2981 if (_large_page_size > default_page_size) {
2977 _page_sizes[0] = _large_page_size; 2982 _page_sizes[0] = _large_page_size;
2978 _page_sizes[1] = default_page_size; 2983 _page_sizes[1] = default_page_size;
2979 _page_sizes[2] = 0; 2984 _page_sizes[2] = 0;
2980 } 2985 }
2981
2982 UseHugeTLBFS = UseHugeTLBFS && 2986 UseHugeTLBFS = UseHugeTLBFS &&
2983 Linux::hugetlbfs_sanity_check(warn_on_failure, _large_page_size); 2987 Linux::hugetlbfs_sanity_check(warn_on_failure, _large_page_size);
2984 2988
2985 if (UseHugeTLBFS) 2989 if (UseHugeTLBFS)
2986 UseSHM = false; 2990 UseSHM = false;
2987 2991
2988 UseLargePages = UseHugeTLBFS || UseSHM; 2992 UseLargePages = UseHugeTLBFS || UseSHM;
2989 2993
2990 set_coredump_filter(); 2994 set_coredump_filter();
2991
2992 // Large page support is available on 2.6 or newer kernel, some vendors
2993 // (e.g. Redhat) have backported it to their 2.4 based distributions.
2994 // We optimistically assume the support is available. If later it turns out
2995 // not true, VM will automatically switch to use regular page size.
2996 return true;
2997 } 2995 }
2998 2996
2999 #ifndef SHM_HUGETLB 2997 #ifndef SHM_HUGETLB
3000 #define SHM_HUGETLB 04000 2998 #define SHM_HUGETLB 04000
3001 #endif 2999 #endif
4116 if(Verbose && PrintMiscellaneous) 4114 if(Verbose && PrintMiscellaneous)
4117 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); 4115 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page);
4118 #endif 4116 #endif
4119 } 4117 }
4120 4118
4121 FLAG_SET_DEFAULT(UseLargePages, os::large_page_init()); 4119 os::large_page_init();
4122 4120
4123 // initialize suspend/resume support - must do this before signal_sets_init() 4121 // initialize suspend/resume support - must do this before signal_sets_init()
4124 if (SR_initialize() != 0) { 4122 if (SR_initialize() != 0) {
4125 perror("SR_initialize failed"); 4123 perror("SR_initialize failed");
4126 return JNI_ERR; 4124 return JNI_ERR;