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

Backport-of: 1413f9e
  • Loading branch information
DamonFool authored and John Jiang committed Dec 31, 2021
1 parent 9fb2989 commit d356b8988d548f56b1dc63d06777dd7f65903d06
Showing 1 changed file with 17 additions and 1 deletion.
@@ -3225,8 +3225,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("", RTLD_LAZY);
if (handle != NULL) {

1 comment on commit d356b89

Copy link

@openjdk-notifier openjdk-notifier bot commented on d356b89 Dec 31, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.