Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8241423: NUMA APIs fail to work in dockers due to dependent syscalls are disabled by default #4205

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -2962,7 +2962,8 @@ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
}

bool os::Linux::libnuma_init() {
if (sched_getcpu() != -1) { // Requires sched_getcpu() support
// Requires sched_getcpu() and numa dependent syscalls support
if ((sched_getcpu() != -1) && numa_syscall_check()) {
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,
Expand Down Expand Up @@ -4477,6 +4478,21 @@ void os::Linux::numa_init() {
}
}

// Check numa dependent syscalls
bool os::Linux::numa_syscall_check() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be a static function in the file rather then being in the os::Linux "namespace"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be a static function in the file rather then being in the os::Linux "namespace"

Updated.
Thanks.

// NUMA APIs depend on several syscalls. E.g., get_mempolicy is required for numa_get_membind and
// numa_get_interleave_mask. But these dependent syscalls can be unsupported for various reasons.
// Especially in dockers, get_mempolicy is not allowed with the default configuration. So it's necessary
// to check whether the syscalls are available. Currently, only get_mempolicy is checked since checking
// others like mbind would cause unexpected side effects.
int dummy = 0;
if (syscall(SYS_get_mempolicy, &dummy, NULL, 0, (void*)&dummy, 3) == -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this SYS_get_mempolicy symbol guaranteed to be available on our supported Linux versions? See earlier in the file for how we handle SYS_gettid and SYS_getcpu.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this SYS_get_mempolicy symbol guaranteed to be available on our supported Linux versions? See earlier in the file for how we handle SYS_gettid and SYS_getcpu.

I think it's OK to use the symbol directly since we have used it in ZGC [1].
Thanks.

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/os/linux/gc/z/zSyscall_linux.cpp#L39

return false;
}

return true;
}

// this is called _after_ the global arguments have been parsed
jint os::init_2(void) {

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/os/linux/os_linux.hpp
Expand Up @@ -180,6 +180,7 @@ class Linux {

private:
static void numa_init();
static bool numa_syscall_check();
static void expand_stack_to(address bottom);

typedef int (*sched_getcpu_func_t)(void);
Expand Down