Skip to content

Commit

Permalink
8312492: Remove THP sanity checks at VM startup
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, coleenp
  • Loading branch information
tstuefe committed Jul 31, 2023
1 parent e47a84f commit 5362ec9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
31 changes: 3 additions & 28 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3563,27 +3563,6 @@ bool os::unguard_memory(char* addr, size_t size) {
return linux_mprotect(addr, size, PROT_READ|PROT_WRITE);
}

bool os::Linux::transparent_huge_pages_sanity_check(bool warn,
size_t page_size) {
bool result = false;
void *p = mmap(nullptr, page_size * 2, PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
if (p != MAP_FAILED) {
void *aligned_p = align_up(p, page_size);

result = madvise(aligned_p, page_size, MADV_HUGEPAGE) == 0;

munmap(p, page_size * 2);
}

if (warn && !result) {
warning("TransparentHugePages is not supported by the operating system.");
}

return result;
}

int os::Linux::hugetlbfs_page_size_flag(size_t page_size) {
if (page_size != HugePages::default_static_hugepage_size()) {
return (exact_log2(page_size) << MAP_HUGE_SHIFT);
Expand Down Expand Up @@ -3715,13 +3694,9 @@ bool os::Linux::setup_large_page_type(size_t page_size) {
}

if (UseTransparentHugePages) {
bool warn_on_failure = !FLAG_IS_DEFAULT(UseTransparentHugePages);
if (transparent_huge_pages_sanity_check(warn_on_failure, page_size)) {
UseHugeTLBFS = false;
UseSHM = false;
return true;
}
UseTransparentHugePages = false;
UseHugeTLBFS = false;
UseSHM = false;
return true;
}

if (UseHugeTLBFS) {
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/os/linux/os_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class os::Linux {
static GrowableArray<int>* nindex_to_node() { return _nindex_to_node; }

static bool setup_large_page_type(size_t page_size);
static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size);
static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
static bool shm_hugetlbfs_sanity_check(bool warn, size_t page_size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import jdk.test.lib.process.ProcessTools;

import java.util.ArrayList;
import java.util.Arrays;

public class TestLargePagesFlags {

Expand Down Expand Up @@ -299,6 +300,9 @@ public void expect(Flag... expectedFlags) throws Exception {
throw new IllegalStateException("Must run use() before expect()");
}

System.out.println("Using: " + Arrays.toString(useFlags));
System.out.println("Expecting: " + Arrays.toString(expectedFlags));

OutputAnalyzer output = executeNewJVM(useFlags);

for (Flag flag : expectedFlags) {
Expand Down Expand Up @@ -381,6 +385,9 @@ public String name() {
public String value() {
return Boolean.toString(value);
}

@Override
public String toString() { return flagString(); }
}

private static interface Flag {
Expand Down

1 comment on commit 5362ec9

@openjdk-notifier
Copy link

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.