mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-24 05:14:52 +02:00
8181319: Make os::Linux::sched_getcpu() available even when UseNUMA is false
Reviewed-by: dholmes, rehn
This commit is contained in:
parent
3e24f6d955
commit
ce57b75eef
2 changed files with 15 additions and 11 deletions
|
@ -2815,6 +2815,18 @@ int os::Linux::sched_getcpu_syscall(void) {
|
||||||
return (retval == -1) ? retval : cpu;
|
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
|
// 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_warn(int number, char *where, ...) { }
|
||||||
extern "C" JNIEXPORT void numa_error(char *where) { }
|
extern "C" JNIEXPORT void numa_error(char *where) { }
|
||||||
|
@ -2836,17 +2848,7 @@ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::Linux::libnuma_init() {
|
bool os::Linux::libnuma_init() {
|
||||||
// sched_getcpu() should be in libc.
|
if (sched_getcpu() != -1) { // Requires sched_getcpu() support
|
||||||
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?
|
|
||||||
void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
|
void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
|
||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,
|
set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,
|
||||||
|
@ -4875,6 +4877,7 @@ jint os::init_2(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Linux::libpthread_init();
|
Linux::libpthread_init();
|
||||||
|
Linux::sched_getcpu_init();
|
||||||
log_info(os)("HotSpot is running with %s, %s",
|
log_info(os)("HotSpot is running with %s, %s",
|
||||||
Linux::glibc_version(), Linux::libpthread_version());
|
Linux::glibc_version(), Linux::libpthread_version());
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,7 @@ class Linux {
|
||||||
static const char *libpthread_version() { return _libpthread_version; }
|
static const char *libpthread_version() { return _libpthread_version; }
|
||||||
|
|
||||||
static void libpthread_init();
|
static void libpthread_init();
|
||||||
|
static void sched_getcpu_init();
|
||||||
static bool libnuma_init();
|
static bool libnuma_init();
|
||||||
static void* libnuma_dlsym(void* handle, const char* name);
|
static void* libnuma_dlsym(void* handle, const char* name);
|
||||||
// libnuma v2 (libnuma_1.2) symbols
|
// libnuma v2 (libnuma_1.2) symbols
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue