2360 } |
2360 } |
2361 |
2361 |
2362 extern "C" void numa_warn(int number, char *where, ...) { } |
2362 extern "C" void numa_warn(int number, char *where, ...) { } |
2363 extern "C" void numa_error(char *where) { } |
2363 extern "C" void numa_error(char *where) { } |
2364 |
2364 |
|
2365 |
|
2366 // If we are running with libnuma version > 2, then we should |
|
2367 // be trying to use symbols with versions 1.1 |
|
2368 // If we are running with earlier version, which did not have symbol versions, |
|
2369 // we should use the base version. |
|
2370 void* os::Linux::libnuma_dlsym(void* handle, const char *name) { |
|
2371 void *f = dlvsym(handle, name, "libnuma_1.1"); |
|
2372 if (f == NULL) { |
|
2373 f = dlsym(handle, name); |
|
2374 } |
|
2375 return f; |
|
2376 } |
|
2377 |
2365 bool os::Linux::libnuma_init() { |
2378 bool os::Linux::libnuma_init() { |
2366 // sched_getcpu() should be in libc. |
2379 // sched_getcpu() should be in libc. |
2367 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, |
2380 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, |
2368 dlsym(RTLD_DEFAULT, "sched_getcpu"))); |
2381 dlsym(RTLD_DEFAULT, "sched_getcpu"))); |
2369 |
2382 |
2370 if (sched_getcpu() != -1) { // Does it work? |
2383 if (sched_getcpu() != -1) { // Does it work? |
2371 void *handle = dlopen("libnuma.so.1", RTLD_LAZY); |
2384 void *handle = dlopen("libnuma.so.1", RTLD_LAZY); |
2372 if (handle != NULL) { |
2385 if (handle != NULL) { |
2373 set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t, |
2386 set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t, |
2374 dlsym(handle, "numa_node_to_cpus"))); |
2387 libnuma_dlsym(handle, "numa_node_to_cpus"))); |
2375 set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t, |
2388 set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t, |
2376 dlsym(handle, "numa_max_node"))); |
2389 libnuma_dlsym(handle, "numa_max_node"))); |
2377 set_numa_available(CAST_TO_FN_PTR(numa_available_func_t, |
2390 set_numa_available(CAST_TO_FN_PTR(numa_available_func_t, |
2378 dlsym(handle, "numa_available"))); |
2391 libnuma_dlsym(handle, "numa_available"))); |
2379 set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t, |
2392 set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t, |
2380 dlsym(handle, "numa_tonode_memory"))); |
2393 libnuma_dlsym(handle, "numa_tonode_memory"))); |
2381 set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t, |
2394 set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t, |
2382 dlsym(handle, "numa_interleave_memory"))); |
2395 libnuma_dlsym(handle, "numa_interleave_memory"))); |
2383 |
2396 |
2384 |
2397 |
2385 if (numa_available() != -1) { |
2398 if (numa_available() != -1) { |
2386 set_numa_all_nodes((unsigned long*)dlsym(handle, "numa_all_nodes")); |
2399 set_numa_all_nodes((unsigned long*)libnuma_dlsym(handle, "numa_all_nodes")); |
2387 // Create a cpu -> node mapping |
2400 // Create a cpu -> node mapping |
2388 _cpu_to_node = new (ResourceObj::C_HEAP) GrowableArray<int>(0, true); |
2401 _cpu_to_node = new (ResourceObj::C_HEAP) GrowableArray<int>(0, true); |
2389 rebuild_cpu_to_node_map(); |
2402 rebuild_cpu_to_node_map(); |
2390 return true; |
2403 return true; |
2391 } |
2404 } |