--- old/src/os/linux/vm/os_linux.cpp 2017-05-31 13:51:25.620152810 +0200 +++ new/src/os/linux/vm/os_linux.cpp 2017-05-31 13:51:25.456145756 +0200 @@ -2815,6 +2815,18 @@ return (retval == -1) ? retval : cpu; } +void os::Linux::sched_getcpu_init() { + // sched_getcpu() should be in libc. + set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, + dlsym(RTLD_DEFAULT, "sched_getcpu"))); + + // If it's not, try a direct syscall. + if (sched_getcpu() == -1) { + set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, + (void*)&sched_getcpu_syscall)); + } +} + // Something to do with the numa-aware allocator needs these symbols extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } extern "C" JNIEXPORT void numa_error(char *where) { } @@ -2833,17 +2845,7 @@ } bool os::Linux::libnuma_init() { - // sched_getcpu() should be in libc. - set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, - dlsym(RTLD_DEFAULT, "sched_getcpu"))); - - // If it's not, try a direct syscall. - if (sched_getcpu() == -1) { - set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, - (void*)&sched_getcpu_syscall)); - } - - if (sched_getcpu() != -1) { // Does it work? + if (sched_getcpu() != -1) { // Requires sched_getcpu() support void *handle = dlopen("libnuma.so.1", RTLD_LAZY); if (handle != NULL) { set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t, @@ -4869,6 +4871,7 @@ #endif Linux::libpthread_init(); + Linux::sched_getcpu_init(); log_info(os)("HotSpot is running with %s, %s", Linux::glibc_version(), Linux::libpthread_version()); --- old/src/os/linux/vm/os_linux.hpp 2017-05-31 13:51:25.921165758 +0200 +++ new/src/os/linux/vm/os_linux.hpp 2017-05-31 13:51:25.791160166 +0200 @@ -170,6 +170,7 @@ static const char *libpthread_version() { return _libpthread_version; } static void libpthread_init(); + static void sched_getcpu_init(); static bool libnuma_init(); static void* libnuma_dlsym(void* handle, const char* name);