Skip to content
Permalink
Browse files
8241423: NUMA APIs fail to work in dockers due to dependent syscalls …
…are disabled by default

Reviewed-by: dholmes, pliden
  • Loading branch information
DamonFool committed May 28, 2021
1 parent 1d2c7ac commit 1413f9e070b19bed33a4552f3e7adb53cf7daf73
Showing 1 changed file with 17 additions and 1 deletion.
@@ -2961,8 +2961,24 @@ void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
return dlvsym(handle, name, "libnuma_1.2");
}

// Check numa dependent syscalls
static bool numa_syscall_check() {
// 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) {
return false;
}

return true;
}

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,

3 comments on commit 1413f9e

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 1413f9e May 28, 2021

Choose a reason for hiding this comment

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

@DamonFool
Copy link
Member Author

@DamonFool DamonFool commented on 1413f9e Dec 30, 2021

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 1413f9e Dec 30, 2021

Choose a reason for hiding this comment

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

@DamonFool the backport was successfully created on the branch DamonFool-backport-1413f9e0 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 1413f9e0 from the openjdk/jdk repository.

The commit being backported was authored by Jie Fu on 28 May 2021 and was reviewed by David Holmes and Per Liden.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev DamonFool-backport-1413f9e0:DamonFool-backport-1413f9e0
$ git checkout DamonFool-backport-1413f9e0
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev DamonFool-backport-1413f9e0

Please sign in to comment.