1 /* |
1 /* |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
129 |
129 |
130 // for timer info max values which include all bits |
130 // for timer info max values which include all bits |
131 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
131 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
132 #define SEC_IN_NANOSECS 1000000000LL |
132 #define SEC_IN_NANOSECS 1000000000LL |
133 |
133 |
|
134 #define LARGEPAGES_BIT (1 << 6) |
134 //////////////////////////////////////////////////////////////////////////////// |
135 //////////////////////////////////////////////////////////////////////////////// |
135 // global variables |
136 // global variables |
136 julong os::Linux::_physical_memory = 0; |
137 julong os::Linux::_physical_memory = 0; |
137 |
138 |
138 address os::Linux::_initial_thread_stack_bottom = NULL; |
139 address os::Linux::_initial_thread_stack_bottom = NULL; |
2815 |
2816 |
2816 bool os::unguard_memory(char* addr, size_t size) { |
2817 bool os::unguard_memory(char* addr, size_t size) { |
2817 return linux_mprotect(addr, size, PROT_READ|PROT_WRITE); |
2818 return linux_mprotect(addr, size, PROT_READ|PROT_WRITE); |
2818 } |
2819 } |
2819 |
2820 |
|
2821 /* |
|
2822 * Set the coredump_filter bits to include largepages in core dump (bit 6) |
|
2823 * |
|
2824 * From the coredump_filter documentation: |
|
2825 * |
|
2826 * - (bit 0) anonymous private memory |
|
2827 * - (bit 1) anonymous shared memory |
|
2828 * - (bit 2) file-backed private memory |
|
2829 * - (bit 3) file-backed shared memory |
|
2830 * - (bit 4) ELF header pages in file-backed private memory areas (it is |
|
2831 * effective only if the bit 2 is cleared) |
|
2832 * - (bit 5) hugetlb private memory |
|
2833 * - (bit 6) hugetlb shared memory |
|
2834 */ |
|
2835 static void set_coredump_filter(void) { |
|
2836 FILE *f; |
|
2837 long cdm; |
|
2838 |
|
2839 if ((f = fopen("/proc/self/coredump_filter", "r+")) == NULL) { |
|
2840 return; |
|
2841 } |
|
2842 |
|
2843 if (fscanf(f, "%lx", &cdm) != 1) { |
|
2844 fclose(f); |
|
2845 return; |
|
2846 } |
|
2847 |
|
2848 rewind(f); |
|
2849 |
|
2850 if ((cdm & LARGEPAGES_BIT) == 0) { |
|
2851 cdm |= LARGEPAGES_BIT; |
|
2852 fprintf(f, "%#lx", cdm); |
|
2853 } |
|
2854 |
|
2855 fclose(f); |
|
2856 } |
|
2857 |
2820 // Large page support |
2858 // Large page support |
2821 |
2859 |
2822 static size_t _large_page_size = 0; |
2860 static size_t _large_page_size = 0; |
2823 |
2861 |
2824 bool os::large_page_init() { |
2862 bool os::large_page_init() { |
2871 if (_large_page_size > default_page_size) { |
2909 if (_large_page_size > default_page_size) { |
2872 _page_sizes[0] = _large_page_size; |
2910 _page_sizes[0] = _large_page_size; |
2873 _page_sizes[1] = default_page_size; |
2911 _page_sizes[1] = default_page_size; |
2874 _page_sizes[2] = 0; |
2912 _page_sizes[2] = 0; |
2875 } |
2913 } |
|
2914 |
|
2915 set_coredump_filter(); |
2876 |
2916 |
2877 // Large page support is available on 2.6 or newer kernel, some vendors |
2917 // Large page support is available on 2.6 or newer kernel, some vendors |
2878 // (e.g. Redhat) have backported it to their 2.4 based distributions. |
2918 // (e.g. Redhat) have backported it to their 2.4 based distributions. |
2879 // We optimistically assume the support is available. If later it turns out |
2919 // We optimistically assume the support is available. If later it turns out |
2880 // not true, VM will automatically switch to use regular page size. |
2920 // not true, VM will automatically switch to use regular page size. |