RFR: 8324580: SIGFPE on THP initialization on kernels < 4.10 [v4]

Thomas Stuefe stuefe at openjdk.org
Wed Feb 7 14:54:59 UTC 2024


On Wed, 7 Feb 2024 14:07:52 GMT, Zdenek Zambersky <zzambers at openjdk.org> wrote:

>> Zdenek Zambersky has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Disable THP for too large page sizes
>
> After more thinking about this and looking to code, I think, I would now prefer current state. (i.e. keeping [HugePages class](https://github.com/openjdk/jdk/blob/c3a632dca75d2fad0a60e03e7b4fc64edb1e906e/src/hotspot/os/linux/hugepages.hpp#L123) as container for "raw" (detected) OS values and than setting _large_page_size to final value in [os_linux.cpp](https://github.com/openjdk/jdk/blob/c3a632dca75d2fad0a60e03e7b4fc64edb1e906e/src/hotspot/os/linux/os_linux.cpp))
> 
> **Reasons:**
> - It is convenient for debugging to (also) see raw values as read from OS in log
> - There is already some other logic that which can affect final configuration, [being done in os_linux.cpp](https://github.com/openjdk/jdk/blob/c3a632dca75d2fad0a60e03e7b4fc64edb1e906e/src/hotspot/os/linux/os_linux.cpp#L3990), so to keep things consistent (also not to do refactoring in this change).
> - It keeps some tests more intuitive straightforward e.g. [TestHugePageDetection](https://github.com/openjdk/jdk/blob/f173e278368d31bc1fe2407defe914e7e246e231/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java) which uses [HugePageConfiguration](https://github.com/openjdk/jdk/blob/f173e278368d31bc1fe2407defe914e7e246e231/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java#L179), read from OS and from log and compares them.
> 
> **Log:**
> - There is an information about not being able to determine THP pagesize:
> `[0.007s][info][pagesize] Cannot determine THP page size (kernel < 4.10 ?)`
> - Final value of page size (_large_page_size variable) is displayed as "Default large page size":
> `[0.007s][info][pagesize] Large page support enabled. Usable page sizes: 4k, 2M. Default large page size: 2M.`
> - Line informing about falling back to default static hugepage size can be added.
> 
> **Full log:**
> (current state in case of unknown THP pagesize (with fallback))
> 
> build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:+UseTransparentHugePages -Xmx128m -Xlog:pagesize -version
> [0.007s][info][pagesize] Static hugepage support:
> [0.007s][info][pagesize]   hugepage size: 2M
> [0.007s][info][pagesize]   hugepage size: 1G
> [0.007s][info][pagesize]   default hugepage size: 2M
> [0.007s][info][pagesize] Transparent hugepage (THP) support:
> [0.007s][info][pagesize]   THP mode: always
> [0.007s][info][pagesize]   THP pagesize: 0B
> [0.007s][info][pagesize] Shared memory transparent hugepage (THP) support:
> [0.007s][info][pagesize]   Shared memory THP mode: unknown
> [0.007s][info][pagesize] JVM will attempt to prevent THPs in thread stac...

@zzambers I am fine with the current version of the patch too, but would ask you to:
- change, like @kstefanj suggested, the behaviour when no static hugepage was detected. In that case just use 2MB as an assumed default. I think that's usually right, and if it is wrong it is no big deal.
- add a log line somewhere that clearly states "we chose such and such page size as assumed THP page size"

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17545#issuecomment-1932212787


More information about the hotspot-runtime-dev mailing list