RFR: 8318817: Could not reserve enough space in CodeHeap 'profiled nmethods' (0K)
Daniel Lundén
duke at openjdk.org
Thu Oct 26 09:40:04 UTC 2023
This changeset fixes an issue where certain large values of `-XX:NMethodSizeLimit` could cause code heap initialization to fail with the error message
Error occurred during initialization of VM
Could not reserve enough space in CodeHeap 'profiled nmethods' (0K)
Two components in `CodeCache::initialize_heaps` may cause the error:
1. The minimum size (`min_size = os::vm_page_size();`) for profiled and non-profiled code heaps is sometimes not large enough. Specifically, when `profiled_size` and/or `non_profiled_size` are set to `min_size` and `alignment > os::vm_page_size()`, the `align_down` below (from `CodeCache::initialize_heaps`) sets the size to 0.
```
const size_t alignment = MAX2(ps, os::vm_allocation_granularity());
non_nmethod_size = align_up(non_nmethod_size, alignment);
profiled_size = align_down(profiled_size, alignment);
non_profiled_size = align_down(non_profiled_size, alignment);
```
2. The calculation for default code heap sizes does not consider the edge case when `cache_size > non_nmethod_size > cache_size - 2 * min_size`.
This changeset
1. ensures that `min_size >= alignment`, and
2. fixes the edge case.
The changeset includes new tests that exercise the above, also in combination with `-XX:+UseLargePages -XX:+UseTransparentHugePages` on Linux to test the case when `os::can_execute_large_page_memory()` is true (which can affect `alignment`).
### Testing (on all Oracle-supported platforms)
- `tier1`
- HotSpot parts of `tier2` and `tier3`
-------------
Commit messages:
- Fix issue
Changes: https://git.openjdk.org/jdk/pull/16373/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16373&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8318817
Stats: 72 lines in 2 files changed: 70 ins; 1 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/16373.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16373/head:pull/16373
PR: https://git.openjdk.org/jdk/pull/16373
More information about the hotspot-compiler-dev
mailing list