2813 #endif |
2813 #endif |
2814 |
2814 |
2815 return (retval == -1) ? retval : cpu; |
2815 return (retval == -1) ? retval : cpu; |
2816 } |
2816 } |
2817 |
2817 |
|
2818 void os::Linux::sched_getcpu_init() { |
|
2819 // sched_getcpu() should be in libc. |
|
2820 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, |
|
2821 dlsym(RTLD_DEFAULT, "sched_getcpu"))); |
|
2822 |
|
2823 // If it's not, try a direct syscall. |
|
2824 if (sched_getcpu() == -1) { |
|
2825 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, |
|
2826 (void*)&sched_getcpu_syscall)); |
|
2827 } |
|
2828 } |
|
2829 |
2818 // Something to do with the numa-aware allocator needs these symbols |
2830 // Something to do with the numa-aware allocator needs these symbols |
2819 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } |
2831 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } |
2820 extern "C" JNIEXPORT void numa_error(char *where) { } |
2832 extern "C" JNIEXPORT void numa_error(char *where) { } |
2821 |
2833 |
2822 // Handle request to load libnuma symbol version 1.1 (API v1). If it fails |
2834 // Handle request to load libnuma symbol version 1.1 (API v1). If it fails |
2834 void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) { |
2846 void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) { |
2835 return dlvsym(handle, name, "libnuma_1.2"); |
2847 return dlvsym(handle, name, "libnuma_1.2"); |
2836 } |
2848 } |
2837 |
2849 |
2838 bool os::Linux::libnuma_init() { |
2850 bool os::Linux::libnuma_init() { |
2839 // sched_getcpu() should be in libc. |
2851 if (sched_getcpu() != -1) { // Requires sched_getcpu() support |
2840 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, |
|
2841 dlsym(RTLD_DEFAULT, "sched_getcpu"))); |
|
2842 |
|
2843 // If it's not, try a direct syscall. |
|
2844 if (sched_getcpu() == -1) { |
|
2845 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, |
|
2846 (void*)&sched_getcpu_syscall)); |
|
2847 } |
|
2848 |
|
2849 if (sched_getcpu() != -1) { // Does it work? |
|
2850 void *handle = dlopen("libnuma.so.1", RTLD_LAZY); |
2852 void *handle = dlopen("libnuma.so.1", RTLD_LAZY); |
2851 if (handle != NULL) { |
2853 if (handle != NULL) { |
2852 set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t, |
2854 set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t, |
2853 libnuma_dlsym(handle, "numa_node_to_cpus"))); |
2855 libnuma_dlsym(handle, "numa_node_to_cpus"))); |
2854 set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t, |
2856 set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t, |
4873 #if defined(IA32) |
4875 #if defined(IA32) |
4874 workaround_expand_exec_shield_cs_limit(); |
4876 workaround_expand_exec_shield_cs_limit(); |
4875 #endif |
4877 #endif |
4876 |
4878 |
4877 Linux::libpthread_init(); |
4879 Linux::libpthread_init(); |
|
4880 Linux::sched_getcpu_init(); |
4878 log_info(os)("HotSpot is running with %s, %s", |
4881 log_info(os)("HotSpot is running with %s, %s", |
4879 Linux::glibc_version(), Linux::libpthread_version()); |
4882 Linux::glibc_version(), Linux::libpthread_version()); |
4880 |
4883 |
4881 if (UseNUMA) { |
4884 if (UseNUMA) { |
4882 if (!Linux::libnuma_init()) { |
4885 if (!Linux::libnuma_init()) { |