Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8243961: ForceNUMA and only one available NUMA node fails assertion o…
Browse files Browse the repository at this point in the history
…n Windows

Improve ergnomics for UseNUMA and UseNUMAInterleaving

Reviewed-by: tschatzl, sjohanss
  • Loading branch information
Kim Barrett committed May 6, 2020
1 parent 317bd88 commit 7ae3bea
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
7 changes: 3 additions & 4 deletions src/hotspot/os/aix/os_aix.cpp
Expand Up @@ -3549,10 +3549,9 @@ jint os::init_2(void) {
return JNI_ERR;
}

if (UseNUMA) {
UseNUMA = false;
warning("NUMA optimizations are not available on this OS.");
}
// Not supported.
FLAG_SET_ERGO(UseNUMA, false);
FLAG_SET_ERGO(UseNUMAInterleaving, false);

if (MaxFDLimit) {
// Set the number of file descriptors to max. print out error
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/os/bsd/os_bsd.cpp
Expand Up @@ -3140,6 +3140,10 @@ jint os::init_2(void) {
return JNI_ERR;
}

// Not supported.
FLAG_SET_ERGO(UseNUMA, false);
FLAG_SET_ERGO(UseNUMAInterleaving, false);

if (MaxFDLimit) {
// set the number of file descriptors to max. print out error
// if getrlimit/setrlimit fails but continue regardless.
Expand Down
10 changes: 8 additions & 2 deletions src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -5175,7 +5175,8 @@ void os::Linux::numa_init() {
// bitmask when externally configured to run on all or fewer nodes.

if (!Linux::libnuma_init()) {
UseNUMA = false;
FLAG_SET_ERGO(UseNUMA, false);
FLAG_SET_ERGO(UseNUMAInterleaving, false); // Also depends on libnuma.
} else {
if ((Linux::numa_max_node() < 1) || Linux::is_bound_to_single_node()) {
// If there's only one node (they start from 0) or if the process
Expand Down Expand Up @@ -5208,6 +5209,11 @@ void os::Linux::numa_init() {
}
}

// When NUMA requested, not-NUMA-aware allocations default to interleaving.
if (UseNUMA && !UseNUMAInterleaving) {
FLAG_SET_ERGO_IF_DEFAULT(UseNUMAInterleaving, true);
}

if (UseParallelGC && UseNUMA && UseLargePages && !can_commit_large_page_memory()) {
// With SHM and HugeTLBFS large pages we cannot uncommit a page, so there's no way
// we can make the adaptive lgrp chunk resizing work. If the user specified both
Expand Down Expand Up @@ -5272,7 +5278,7 @@ jint os::init_2(void) {
log_info(os)("HotSpot is running with %s, %s",
Linux::glibc_version(), Linux::libpthread_version());

if (UseNUMA) {
if (UseNUMA || UseNUMAInterleaving) {
Linux::numa_init();
}

Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/os/solaris/os_solaris.cpp
Expand Up @@ -3916,7 +3916,7 @@ jint os::init_2(void) {

if (UseNUMA) {
if (!Solaris::liblgrp_init()) {
UseNUMA = false;
FLAG_SET_ERGO(UseNUMA, false);
} else {
size_t lgrp_limit = os::numa_get_groups_num();
int *lgrp_ids = NEW_C_HEAP_ARRAY(int, lgrp_limit, mtInternal);
Expand All @@ -3930,6 +3930,11 @@ jint os::init_2(void) {
}
}

// When NUMA requested, not-NUMA-aware allocations default to interleaving.
if (UseNUMA && !UseNUMAInterleaving) {
FLAG_SET_ERGO_IF_DEFAULT(UseNUMAInterleaving, true);
}

Solaris::signal_sets_init();
Solaris::init_signal_mem();
Solaris::install_signal_handlers();
Expand Down
11 changes: 7 additions & 4 deletions src/hotspot/os/windows/os_windows.cpp
Expand Up @@ -4096,10 +4096,13 @@ jint os::init_2(void) {
UseNUMA = false; // We don't fully support this yet
}

if (UseNUMAInterleaving) {
// first check whether this Windows OS supports VirtualAllocExNuma, if not ignore this flag
bool success = numa_interleaving_init();
if (!success) UseNUMAInterleaving = false;
if (UseNUMAInterleaving || (UseNUMA && FLAG_IS_DEFAULT(UseNUMAInterleaving))) {
if (!numa_interleaving_init()) {
FLAG_SET_ERGO(UseNUMAInterleaving, false);
} else if (!UseNUMAInterleaving) {
// When NUMA requested, not-NUMA-aware allocations default to interleaving.
FLAG_SET_ERGO(UseNUMAInterleaving, true);
}
}

if (initSock() != JNI_OK) {
Expand Down
8 changes: 0 additions & 8 deletions src/hotspot/share/runtime/arguments.cpp
Expand Up @@ -4158,14 +4158,6 @@ jint Arguments::adjust_after_os() {
FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
}
}
// UseNUMAInterleaving is set to ON for all collectors and platforms when
// UseNUMA is set to ON. NUMA-aware collectors will interleave old gen and
// survivor spaces on top of NUMA allocation policy for the eden space.
// Non NUMA-aware collectors will interleave all of the heap spaces across
// NUMA nodes.
if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) {
FLAG_SET_ERGO(UseNUMAInterleaving, true);
}
}
return JNI_OK;
}
Expand Down

0 comments on commit 7ae3bea

Please sign in to comment.