mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
8324580: SIGFPE on THP initialization on kernels < 4.10
Reviewed-by: stuefe
Backport-of: a231706a06
This commit is contained in:
committed by
Vitaly Provodin
parent
f06bb52a78
commit
a9532dfd5d
@@ -230,6 +230,19 @@ void THPSupport::print_on(outputStream* os) {
|
||||
StaticHugePageSupport HugePages::_static_hugepage_support;
|
||||
THPSupport HugePages::_thp_support;
|
||||
|
||||
size_t HugePages::thp_pagesize_fallback() {
|
||||
// Older kernels won't publish the THP page size. Fall back to default static huge page size,
|
||||
// since that is likely to be the THP page size as well. Don't do it if the page size is considered
|
||||
// too large to avoid large alignment waste. If static huge page size is unknown, use educated guess.
|
||||
if (thp_pagesize() != 0) {
|
||||
return thp_pagesize();
|
||||
}
|
||||
if (supports_static_hugepages()) {
|
||||
return MIN2(default_static_hugepage_size(), 16 * M);
|
||||
}
|
||||
return 2 * M;
|
||||
}
|
||||
|
||||
void HugePages::initialize() {
|
||||
_static_hugepage_support.scan_os();
|
||||
_thp_support.scan_os();
|
||||
|
||||
@@ -107,6 +107,7 @@ public:
|
||||
static THPMode thp_mode() { return _thp_support.mode(); }
|
||||
static bool supports_thp() { return thp_mode() == THPMode::madvise || thp_mode() == THPMode::always; }
|
||||
static size_t thp_pagesize() { return _thp_support.pagesize(); }
|
||||
static size_t thp_pagesize_fallback();
|
||||
|
||||
static void initialize();
|
||||
static void print_on(outputStream* os);
|
||||
|
||||
@@ -3874,8 +3874,12 @@ void os::large_page_init() {
|
||||
// In THP mode:
|
||||
// - os::large_page_size() is the *THP page size*
|
||||
// - os::pagesizes() has two members, the THP page size and the system page size
|
||||
assert(HugePages::supports_thp() && HugePages::thp_pagesize() > 0, "Missing OS info");
|
||||
_large_page_size = HugePages::thp_pagesize();
|
||||
if (_large_page_size == 0) {
|
||||
log_info(pagesize) ("Cannot determine THP page size (kernel < 4.10 ?)");
|
||||
_large_page_size = HugePages::thp_pagesize_fallback();
|
||||
log_info(pagesize) ("Assuming THP page size to be: " EXACTFMT " (heuristics)", EXACTFMTARGS(_large_page_size));
|
||||
}
|
||||
_page_sizes.add(_large_page_size);
|
||||
_page_sizes.add(os::vm_page_size());
|
||||
|
||||
|
||||
@@ -84,6 +84,20 @@ class HugePageConfiguration {
|
||||
return _thpPageSize;
|
||||
}
|
||||
|
||||
// Returns the THP page size (if exposed by the kernel) or a guessed THP page size.
|
||||
// Mimics HugePages::thp_pagesize_fallback() method in hotspot (must be kept in sync with it).
|
||||
public long getThpPageSizeOrFallback() {
|
||||
long pageSize = getThpPageSize();
|
||||
if (pageSize != 0) {
|
||||
return pageSize;
|
||||
}
|
||||
pageSize = getStaticDefaultHugePageSize();
|
||||
if (pageSize != 0) {
|
||||
return Math.min(pageSize, 16 * 1024 * 1024);
|
||||
}
|
||||
return 2 * 1024 * 1024;
|
||||
}
|
||||
|
||||
// Returns true if the THP support is enabled
|
||||
public boolean supportsTHP() {
|
||||
return _thpMode == THPMode.always || _thpMode == THPMode.madvise;
|
||||
|
||||
@@ -125,7 +125,8 @@ public class TestHugePageDecisionsAtVMStartup {
|
||||
out.shouldContain("[info][pagesize] UseLargePages=1, UseTransparentHugePages=0");
|
||||
out.shouldContain("[info][pagesize] Large page support enabled");
|
||||
} else if (useLP && useTHP && configuration.supportsTHP()) {
|
||||
String thpPageSizeString = buildSizeString(configuration.getThpPageSize());
|
||||
long thpPageSize = configuration.getThpPageSizeOrFallback();
|
||||
String thpPageSizeString = buildSizeString(thpPageSize);
|
||||
// We expect to see exactly two "Usable page sizes" : the system page size and the THP page size. The system
|
||||
// page size differs, but its always in KB).
|
||||
out.shouldContain("[info][pagesize] UseLargePages=1, UseTransparentHugePages=1");
|
||||
|
||||
Reference in New Issue
Block a user