comparison src/os/linux/vm/os_linux.cpp @ 12176:88c255656030

8016155: SIGBUS when running Kitchensink with ParallelScavenge and ParallelOld Summary: When using NUMA and large pages we need to ease the requirement on which node the memory should be allocated on. To avoid the SIGBUS we now use the memory policy MPOL_PREFERRED, which prefers a certain node, instead of MPOL_BIND, which requires a certain node. Reviewed-by: jmasa, pliden Contributed-by: stefan.johansson@oracle.com
author mgerdin
date Thu, 22 Aug 2013 10:50:41 +0200
parents 59b052799158
children 0d59407e7e09
comparison
equal deleted inserted replaced
12115:ec145d04eda8 12176:88c255656030
2794 2794
2795 void os::numa_make_global(char *addr, size_t bytes) { 2795 void os::numa_make_global(char *addr, size_t bytes) {
2796 Linux::numa_interleave_memory(addr, bytes); 2796 Linux::numa_interleave_memory(addr, bytes);
2797 } 2797 }
2798 2798
2799 // Define for numa_set_bind_policy(int). Setting the argument to 0 will set the
2800 // bind policy to MPOL_PREFERRED for the current thread.
2801 #define USE_MPOL_PREFERRED 0
2802
2799 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { 2803 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
2804 // To make NUMA and large pages more robust when both enabled, we need to ease
2805 // the requirements on where the memory should be allocated. MPOL_BIND is the
2806 // default policy and it will force memory to be allocated on the specified
2807 // node. Changing this to MPOL_PREFERRED will prefer to allocate the memory on
2808 // the specified node, but will not force it. Using this policy will prevent
2809 // getting SIGBUS when trying to allocate large pages on NUMA nodes with no
2810 // free large pages.
2811 Linux::numa_set_bind_policy(USE_MPOL_PREFERRED);
2800 Linux::numa_tonode_memory(addr, bytes, lgrp_hint); 2812 Linux::numa_tonode_memory(addr, bytes, lgrp_hint);
2801 } 2813 }
2802 2814
2803 bool os::numa_topology_changed() { return false; } 2815 bool os::numa_topology_changed() { return false; }
2804 2816
2896 libnuma_dlsym(handle, "numa_available"))); 2908 libnuma_dlsym(handle, "numa_available")));
2897 set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t, 2909 set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
2898 libnuma_dlsym(handle, "numa_tonode_memory"))); 2910 libnuma_dlsym(handle, "numa_tonode_memory")));
2899 set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t, 2911 set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
2900 libnuma_dlsym(handle, "numa_interleave_memory"))); 2912 libnuma_dlsym(handle, "numa_interleave_memory")));
2913 set_numa_set_bind_policy(CAST_TO_FN_PTR(numa_set_bind_policy_func_t,
2914 libnuma_dlsym(handle, "numa_set_bind_policy")));
2901 2915
2902 2916
2903 if (numa_available() != -1) { 2917 if (numa_available() != -1) {
2904 set_numa_all_nodes((unsigned long*)libnuma_dlsym(handle, "numa_all_nodes")); 2918 set_numa_all_nodes((unsigned long*)libnuma_dlsym(handle, "numa_all_nodes"));
2905 // Create a cpu -> node mapping 2919 // Create a cpu -> node mapping
2962 os::Linux::numa_node_to_cpus_func_t os::Linux::_numa_node_to_cpus; 2976 os::Linux::numa_node_to_cpus_func_t os::Linux::_numa_node_to_cpus;
2963 os::Linux::numa_max_node_func_t os::Linux::_numa_max_node; 2977 os::Linux::numa_max_node_func_t os::Linux::_numa_max_node;
2964 os::Linux::numa_available_func_t os::Linux::_numa_available; 2978 os::Linux::numa_available_func_t os::Linux::_numa_available;
2965 os::Linux::numa_tonode_memory_func_t os::Linux::_numa_tonode_memory; 2979 os::Linux::numa_tonode_memory_func_t os::Linux::_numa_tonode_memory;
2966 os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory; 2980 os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
2981 os::Linux::numa_set_bind_policy_func_t os::Linux::_numa_set_bind_policy;
2967 unsigned long* os::Linux::_numa_all_nodes; 2982 unsigned long* os::Linux::_numa_all_nodes;
2968 2983
2969 bool os::pd_uncommit_memory(char* addr, size_t size) { 2984 bool os::pd_uncommit_memory(char* addr, size_t size) {
2970 uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE, 2985 uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
2971 MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0); 2986 MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);