aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Stefan Johansson <sjohanss@openjdk.org> 2021-03-24 20:28:04 +0000
committerGravatar Stefan Johansson <sjohanss@openjdk.org> 2021-03-24 20:28:04 +0000
commit623f0b6bc61bbfb13fbe43e3beaa51481aacb398 (patch)
tree3c26c5f089039105e870a6c20d83510fc14a3b08
parent1a13c9ef83f5cc9a58db3a4c5cc6e049bf239396 (diff)
downloadjdk-623f0b6bc61bbfb13fbe43e3beaa51481aacb398.tar.gz
jdk-623f0b6bc61bbfb13fbe43e3beaa51481aacb398.zip
8262235: Remove unnecessary logic in hugetlbfs_sanity_check()jdk-17+15
Reviewed-by: iwalulya, tschatzl
-rw-r--r--src/hotspot/os/linux/os_linux.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
index f501569fefb..0e9f2427da9 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -3493,39 +3493,21 @@ int os::Linux::hugetlbfs_page_size_flag(size_t page_size) {
}
bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) {
- bool result = false;
-
// Include the page size flag to ensure we sanity check the correct page size.
int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB | hugetlbfs_page_size_flag(page_size);
void *p = mmap(NULL, page_size, PROT_READ|PROT_WRITE, flags, -1, 0);
if (p != MAP_FAILED) {
- // We don't know if this really is a huge page or not.
- FILE *fp = fopen("/proc/self/maps", "r");
- if (fp) {
- while (!feof(fp)) {
- char chars[257];
- long x = 0;
- if (fgets(chars, sizeof(chars), fp)) {
- if (sscanf(chars, "%lx-%*x", &x) == 1
- && x == (long)p) {
- if (strstr (chars, "hugepage")) {
- result = true;
- break;
- }
- }
- }
- }
- fclose(fp);
- }
+ // Mapping succeeded, sanity check passed.
munmap(p, page_size);
+ return true;
}
- if (warn && !result) {
- warning("HugeTLBFS is not supported by the operating system.");
+ if (warn) {
+ warning("HugeTLBFS is not configured or not supported by the operating system.");
}
- return result;
+ return false;
}
bool os::Linux::shm_hugetlbfs_sanity_check(bool warn, size_t page_size) {