2833 }
2834
2835 bool os::unguard_memory(char* addr, size_t size) {
2836 return linux_mprotect(addr, size, PROT_READ|PROT_WRITE);
2837 }
2838
2839 bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) {
2840 bool result = false;
2841 void *p = mmap (NULL, page_size, PROT_READ|PROT_WRITE,
2842 MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB,
2843 -1, 0);
2844
2845 if (p != (void *) -1) {
2846 // We don't know if this really is a huge page or not.
2847 FILE *fp = fopen("/proc/self/maps", "r");
2848 if (fp) {
2849 while (!feof(fp)) {
2850 char chars[257];
2851 long x = 0;
2852 if (fgets(chars, sizeof(chars), fp)) {
2853 if (sscanf(chars, "%lx-%*lx", &x) == 1
2854 && x == (long)p) {
2855 if (strstr (chars, "hugepage")) {
2856 result = true;
2857 break;
2858 }
2859 }
2860 }
2861 }
2862 fclose(fp);
2863 }
2864 munmap (p, page_size);
2865 if (result)
2866 return true;
2867 }
2868
2869 if (warn) {
2870 warning("HugeTLBFS is not supported by the operating system.");
2871 }
2872
2873 return result;
|
2833 }
2834
2835 bool os::unguard_memory(char* addr, size_t size) {
2836 return linux_mprotect(addr, size, PROT_READ|PROT_WRITE);
2837 }
2838
2839 bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) {
2840 bool result = false;
2841 void *p = mmap (NULL, page_size, PROT_READ|PROT_WRITE,
2842 MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB,
2843 -1, 0);
2844
2845 if (p != (void *) -1) {
2846 // We don't know if this really is a huge page or not.
2847 FILE *fp = fopen("/proc/self/maps", "r");
2848 if (fp) {
2849 while (!feof(fp)) {
2850 char chars[257];
2851 long x = 0;
2852 if (fgets(chars, sizeof(chars), fp)) {
2853 if (sscanf(chars, "%lx-%*x", &x) == 1
2854 && x == (long)p) {
2855 if (strstr (chars, "hugepage")) {
2856 result = true;
2857 break;
2858 }
2859 }
2860 }
2861 }
2862 fclose(fp);
2863 }
2864 munmap (p, page_size);
2865 if (result)
2866 return true;
2867 }
2868
2869 if (warn) {
2870 warning("HugeTLBFS is not supported by the operating system.");
2871 }
2872
2873 return result;
|