RFR: 8261401: Add sanity check for UseSHM large pages similar to the one used with hugetlb large pages [v3]
Stefan Johansson
sjohanss at openjdk.java.net
Thu Feb 11 07:48:53 UTC 2021
> When large pages are enabled on Linux (using -XX:+UseLargePages), both UseHugeTLBFS and UseSHM can be used. We prefer to use HugeTLBFS and first do a sanity check to see if this kind of large pages are available and if so we disable UseSHM.
>
> The problematic part is when HugeTLBFS pages are not available, then we disable this flag and without doing any sanity check for UseSHM, we mark large pages as enabled using SHM. One big problem with this is that SHM also requires the same type of explicitly allocated huge pages as HugeTLBFS and also privileges to lock memory. So it is likely that in the case of not being able to use HugeTLBFS we probably can't use SHM either.
>
> A fix for this would be to do a similar sanity check as currently done for HugeTLBFS and if it fails disable UseLargePages since we will always fail such allocation attempts anyways.
>
> The proposed sanity check consist of two part, where the first is just trying create a shared memory segment using `shmget()` with SHM_HUGETLB to use large pages. If this fails there is no idea in trying to use SHM to get large pages.
>
> The second part checks if the process has privileges to lock memory or if there will be a limit for the SHM usage. I think this would be a nice addition since it will notify the user about the limit and explain why large page mappings fail. The implementation parses `/proc/self/status` to make sure the needed capability is available.
>
> This change needs two tests to be updated to handle that large pages not can be disabled even when run with +UseLargePages. One of these tests are also updated in [PR#2486](https://github.com/openjdk/jdk/pull/2486) and I plan to get that integrated before this one.
Stefan Johansson has updated the pull request incrementally with one additional commit since the last revision:
Only warn if UseLargePages was explicitly set.
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/2488/files
- new: https://git.openjdk.java.net/jdk/pull/2488/files/bf6cbce1..6a2606be
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2488&range=02
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2488&range=01-02
Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/2488.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/2488/head:pull/2488
PR: https://git.openjdk.java.net/jdk/pull/2488
More information about the hotspot-dev
mailing list