Mercurial > hg > truffle
comparison src/os/linux/vm/os_linux.cpp @ 2211:0cd39a385a72
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@gmail.com> |
---|---|
date | Mon, 21 Feb 2011 19:17:33 +0100 |
parents | d25d4ca69222 63d374c54045 |
children | 0654ee04b214 |
comparison
equal
deleted
inserted
replaced
2184:5d801e6b9a80 | 2211:0cd39a385a72 |
---|---|
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. |
74 #endif | 74 #endif |
75 #ifdef TARGET_ARCH_zero | 75 #ifdef TARGET_ARCH_zero |
76 # include "assembler_zero.inline.hpp" | 76 # include "assembler_zero.inline.hpp" |
77 # include "nativeInst_zero.hpp" | 77 # include "nativeInst_zero.hpp" |
78 #endif | 78 #endif |
79 #ifdef TARGET_ARCH_arm | |
80 # include "assembler_arm.inline.hpp" | |
81 # include "nativeInst_arm.hpp" | |
82 #endif | |
83 #ifdef TARGET_ARCH_ppc | |
84 # include "assembler_ppc.inline.hpp" | |
85 # include "nativeInst_ppc.hpp" | |
86 #endif | |
79 #ifdef COMPILER1 | 87 #ifdef COMPILER1 |
80 #include "c1/c1_Runtime1.hpp" | 88 #include "c1/c1_Runtime1.hpp" |
81 #endif | 89 #endif |
82 #ifdef COMPILER2 | 90 #ifdef COMPILER2 |
83 #include "opto/runtime.hpp" | 91 #include "opto/runtime.hpp" |
121 | 129 |
122 // for timer info max values which include all bits | 130 // for timer info max values which include all bits |
123 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) | 131 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) |
124 #define SEC_IN_NANOSECS 1000000000LL | 132 #define SEC_IN_NANOSECS 1000000000LL |
125 | 133 |
134 #define LARGEPAGES_BIT (1 << 6) | |
126 //////////////////////////////////////////////////////////////////////////////// | 135 //////////////////////////////////////////////////////////////////////////////// |
127 // global variables | 136 // global variables |
128 julong os::Linux::_physical_memory = 0; | 137 julong os::Linux::_physical_memory = 0; |
129 | 138 |
130 address os::Linux::_initial_thread_stack_bottom = NULL; | 139 address os::Linux::_initial_thread_stack_bottom = NULL; |
2507 | 2516 |
2508 char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) { | 2517 char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) { |
2509 return end; | 2518 return end; |
2510 } | 2519 } |
2511 | 2520 |
2512 extern "C" void numa_warn(int number, char *where, ...) { } | 2521 // Something to do with the numa-aware allocator needs these symbols |
2513 extern "C" void numa_error(char *where) { } | 2522 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } |
2523 extern "C" JNIEXPORT void numa_error(char *where) { } | |
2524 extern "C" JNIEXPORT int fork1() { return fork(); } | |
2514 | 2525 |
2515 | 2526 |
2516 // If we are running with libnuma version > 2, then we should | 2527 // If we are running with libnuma version > 2, then we should |
2517 // be trying to use symbols with versions 1.1 | 2528 // be trying to use symbols with versions 1.1 |
2518 // If we are running with earlier version, which did not have symbol versions, | 2529 // If we are running with earlier version, which did not have symbol versions, |
2803 return linux_mprotect(addr, size, PROT_NONE); | 2814 return linux_mprotect(addr, size, PROT_NONE); |
2804 } | 2815 } |
2805 | 2816 |
2806 bool os::unguard_memory(char* addr, size_t size) { | 2817 bool os::unguard_memory(char* addr, size_t size) { |
2807 return linux_mprotect(addr, size, PROT_READ|PROT_WRITE); | 2818 return linux_mprotect(addr, size, PROT_READ|PROT_WRITE); |
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); | |
2808 } | 2856 } |
2809 | 2857 |
2810 // Large page support | 2858 // Large page support |
2811 | 2859 |
2812 static size_t _large_page_size = 0; | 2860 static size_t _large_page_size = 0; |
2861 if (_large_page_size > default_page_size) { | 2909 if (_large_page_size > default_page_size) { |
2862 _page_sizes[0] = _large_page_size; | 2910 _page_sizes[0] = _large_page_size; |
2863 _page_sizes[1] = default_page_size; | 2911 _page_sizes[1] = default_page_size; |
2864 _page_sizes[2] = 0; | 2912 _page_sizes[2] = 0; |
2865 } | 2913 } |
2914 | |
2915 set_coredump_filter(); | |
2866 | 2916 |
2867 // 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 |
2868 // (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. |
2869 // 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 |
2870 // not true, VM will automatically switch to use regular page size. | 2920 // not true, VM will automatically switch to use regular page size. |
3481 // the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART. | 3531 // the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART. |
3482 // | 3532 // |
3483 // Note that the VM will print warnings if it detects conflicting signal | 3533 // Note that the VM will print warnings if it detects conflicting signal |
3484 // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers". | 3534 // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers". |
3485 // | 3535 // |
3486 extern "C" int | 3536 extern "C" JNIEXPORT int |
3487 JVM_handle_linux_signal(int signo, siginfo_t* siginfo, | 3537 JVM_handle_linux_signal(int signo, siginfo_t* siginfo, |
3488 void* ucontext, int abort_if_unrecognized); | 3538 void* ucontext, int abort_if_unrecognized); |
3489 | 3539 |
3490 void signalHandler(int sig, siginfo_t* info, void* uc) { | 3540 void signalHandler(int sig, siginfo_t* info, void* uc) { |
3491 assert(info != NULL && uc != NULL, "it must be old kernel"); | 3541 assert(info != NULL && uc != NULL, "it must be old kernel"); |
4683 jio_fprintf(stderr, | 4733 jio_fprintf(stderr, |
4684 "Could not open pause file '%s', continuing immediately.\n", filename); | 4734 "Could not open pause file '%s', continuing immediately.\n", filename); |
4685 } | 4735 } |
4686 } | 4736 } |
4687 | 4737 |
4688 extern "C" { | |
4689 | |
4690 /** | |
4691 * NOTE: the following code is to keep the green threads code | |
4692 * in the libjava.so happy. Once the green threads is removed, | |
4693 * these code will no longer be needed. | |
4694 */ | |
4695 int | |
4696 jdk_waitpid(pid_t pid, int* status, int options) { | |
4697 return waitpid(pid, status, options); | |
4698 } | |
4699 | |
4700 int | |
4701 fork1() { | |
4702 return fork(); | |
4703 } | |
4704 | |
4705 int | |
4706 jdk_sem_init(sem_t *sem, int pshared, unsigned int value) { | |
4707 return sem_init(sem, pshared, value); | |
4708 } | |
4709 | |
4710 int | |
4711 jdk_sem_post(sem_t *sem) { | |
4712 return sem_post(sem); | |
4713 } | |
4714 | |
4715 int | |
4716 jdk_sem_wait(sem_t *sem) { | |
4717 return sem_wait(sem); | |
4718 } | |
4719 | |
4720 int | |
4721 jdk_pthread_sigmask(int how , const sigset_t* newmask, sigset_t* oldmask) { | |
4722 return pthread_sigmask(how , newmask, oldmask); | |
4723 } | |
4724 | |
4725 } | |
4726 | 4738 |
4727 // Refer to the comments in os_solaris.cpp park-unpark. | 4739 // Refer to the comments in os_solaris.cpp park-unpark. |
4728 // | 4740 // |
4729 // Beware -- Some versions of NPTL embody a flaw where pthread_cond_timedwait() can | 4741 // Beware -- Some versions of NPTL embody a flaw where pthread_cond_timedwait() can |
4730 // hang indefinitely. For instance NPTL 0.60 on 2.4.21-4ELsmp is vulnerable. | 4742 // hang indefinitely. For instance NPTL 0.60 on 2.4.21-4ELsmp is vulnerable. |