RFR: JDK-8304954: SegmentedCodeCache fails when using large pages
Damon Fenacci
dfenacci at openjdk.org
Thu Jul 20 12:26:09 UTC 2023
# Issue
When large pages are enabled and segmented code cache is used, the VM tries to use one page for each segment. If the amount of reserved code cache is limited, this can make the total size of the code cache bigger than the reserved size, which in turn makes the VM fail, claiming that there is not enough space (e.g. this happens when running `java -XX:+UseLargePages -XX:+SegmentedCodeCache -XX:InitialCodeCacheSize=2g -XX:ReservedCodeCacheSize=2g -XX:LargePageSizeInBytes=1g -Xlog:pagesize*=debug -version`).
This behaviour is not correct as the VM should fall back and try with a smaller page size (and print a warning).
# Solution
Right before reserving heap space for code segments we introduce a test (if we are using large pages) that checks for the total size of aligned code segments and selects smaller and smaller page sizes until the total size fits in the reserved size for the code cache.
# Test
The regression test runs a new VM with `-XX:+UseLargePages -XX:LargePageSizeInBytes=1g`. The `main` method then checks if the two flags have been "taken". If so, another process is started that checks for a specific output, otherwise the test passes (i.e. the current system doesn't allow 1GB large pages)
-------------
Commit messages:
- JDK-8304954: exclude ZGC from test
- JDK-8304954: adding test
- JDK-8304954: fix syntax
- JDK-8304954: print warning only when page size actually changes
- JDK-8304954: use loop to find smaller page in case there are multiple failing large pages
- JDK-8304954: update warning message
- JDK-8304954: SegmentedCodeCache fails when using large pages
Changes: https://git.openjdk.org/jdk/pull/14903/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14903&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8304954
Stats: 100 lines in 3 files changed: 94 ins; 1 del; 5 mod
Patch: https://git.openjdk.org/jdk/pull/14903.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14903/head:pull/14903
PR: https://git.openjdk.org/jdk/pull/14903
More information about the hotspot-compiler-dev
mailing list