代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/openjdk-21 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Subject: BackPort of JDK-8324580: SIGFPE on THP initialization on kernels < 4.10
---
src/hotspot/os/linux/hugepages.cpp | 13 +++++++++++++
src/hotspot/os/linux/hugepages.hpp | 1 +
src/hotspot/os/linux/os_linux.cpp | 6 +++++-
.../jtreg/runtime/os/HugePageConfiguration.java | 14 ++++++++++++++
.../os/TestHugePageDecisionsAtVMStartup.java | 3 ++-
5 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/src/hotspot/os/linux/hugepages.cpp b/src/hotspot/os/linux/hugepages.cpp
index f9f9dd497..715bfc165 100644
--- a/src/hotspot/os/linux/hugepages.cpp
+++ b/src/hotspot/os/linux/hugepages.cpp
@@ -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();
diff --git a/src/hotspot/os/linux/hugepages.hpp b/src/hotspot/os/linux/hugepages.hpp
index cb7c992d7..5d196504c 100644
--- a/src/hotspot/os/linux/hugepages.hpp
+++ b/src/hotspot/os/linux/hugepages.hpp
@@ -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);
diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
index 4da04ebc7..4ece9f471 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -3843,8 +3843,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());
diff --git a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java b/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java
index f475af4c2..14cb88fb6 100644
--- a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java
+++ b/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java
@@ -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;
diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java
index 340c13707..18242578d 100644
--- a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java
+++ b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java
@@ -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");
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。