Skip to content

Commit

Permalink
8312620: WSL Linux build crashes after JDK-8310233
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, djelinski
  • Loading branch information
tstuefe committed Jul 27, 2023
1 parent 8661b8e commit 25058cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/hotspot/os/linux/hugepages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <dirent.h>

StaticHugePageSupport::StaticHugePageSupport() :
_initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX) {}
_initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX), _inconsistent(false) {}

os::PageSizes StaticHugePageSupport::pagesizes() const {
assert(_initialized, "Not initialized");
Expand Down Expand Up @@ -141,15 +141,24 @@ void StaticHugePageSupport::print_on(outputStream* os) {
} else {
os->print_cr(" unknown.");
}
if (_inconsistent) {
os->print_cr(" Support inconsistent. JVM will not use static hugepages.");
}
}

void StaticHugePageSupport::scan_os() {
_default_hugepage_size = scan_default_hugepagesize();
if (_default_hugepage_size > 0) {
_pagesizes = scan_hugepages();
assert(_pagesizes.contains(_default_hugepage_size),
"Unexpected configuration: default pagesize (" SIZE_FORMAT ") "
"has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size);
// See https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt: /proc/meminfo should match
// /sys/kernel/mm/hugepages/hugepages-xxxx. However, we may run on a broken kernel (e.g. on WSL)
// that only exposes /proc/meminfo but not /sys/kernel/mm/hugepages. In that case, we are not
// sure about the state of hugepage support by the kernel, so we won't use static hugepages.
if (!_pagesizes.contains(_default_hugepage_size)) {
log_info(pagesize)("Unexpected configuration: default pagesize (" SIZE_FORMAT ") "
"has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size);
_inconsistent = true;
}
}
_initialized = true;
LogTarget(Info, pagesize) lt;
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/os/linux/hugepages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class StaticHugePageSupport {
// - is the size one gets when using mmap(MAP_HUGETLB) when omitting size specifiers like MAP_HUGE_SHIFT)
size_t _default_hugepage_size;

// If true, the kernel support for hugepages is inconsistent
bool _inconsistent;

public:
StaticHugePageSupport();

Expand All @@ -60,6 +63,8 @@ class StaticHugePageSupport {
os::PageSizes pagesizes() const;
size_t default_hugepage_size() const;
void print_on(outputStream* os);

bool inconsistent() const { return _inconsistent; }
};

enum class THPMode { always, never, madvise };
Expand Down Expand Up @@ -98,7 +103,7 @@ class HugePages : public AllStatic {
static const THPSupport& thp_info() { return _thp_support; }

static size_t default_static_hugepage_size() { return _static_hugepage_support.default_hugepage_size(); }
static bool supports_static_hugepages() { return default_static_hugepage_size() > 0; }
static bool supports_static_hugepages() { return default_static_hugepage_size() > 0 && !_static_hugepage_support.inconsistent(); }
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(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
* @requires os.family == "linux"
* @modules java.base/jdk.internal.misc
* java.management
* @run driver HugePageDetection
* @run driver TestHugePageDetection
*/

import java.util.*;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

public class HugePageDetection {
public class TestHugePageDetection {

public static void main(String[] args) throws Exception {

Expand Down

7 comments on commit 25058cd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on 25058cd Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe Could not automatically backport 25058cd2 to openjdk/jdk17u due to conflicts in the following files:

  • src/hotspot/os/linux/hugepages.cpp
  • src/hotspot/os/linux/hugepages.hpp
  • test/hotspot/jtreg/runtime/os/TestHugePageDetection.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b tstuefe-backport-25058cd2

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 25058cd23ac9c8993e7acfd82728ee4c623f0914

# Backport the commit
$ git cherry-pick --no-commit 25058cd23ac9c8993e7acfd82728ee4c623f0914
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 25058cd23ac9c8993e7acfd82728ee4c623f0914'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u with the title Backport 25058cd23ac9c8993e7acfd82728ee4c623f0914.

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on 25058cd Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe Could not automatically backport 25058cd2 to openjdk/jdk21u due to conflicts in the following files:

  • src/hotspot/os/linux/hugepages.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b tstuefe-backport-25058cd2

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 25058cd23ac9c8993e7acfd82728ee4c623f0914

# Backport the commit
$ git cherry-pick --no-commit 25058cd23ac9c8993e7acfd82728ee4c623f0914
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 25058cd23ac9c8993e7acfd82728ee4c623f0914'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u with the title Backport 25058cd23ac9c8993e7acfd82728ee4c623f0914.

@tstuefe
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on 25058cd Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstuefe the backport was successfully created on the branch tstuefe-backport-25058cd2 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 25058cd2 from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 27 Jul 2023 and was reviewed by David Holmes and Daniel Jeliński.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git tstuefe-backport-25058cd2:tstuefe-backport-25058cd2
$ git checkout tstuefe-backport-25058cd2
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git tstuefe-backport-25058cd2

Please sign in to comment.