RFR: 8332362: Implement os::committed_in_range for MacOS and AIX

Thomas Stuefe stuefe at openjdk.org
Tue Jun 11 13:42:21 UTC 2024


On Wed, 29 May 2024 14:04:37 GMT, Robert Toyonaga <duke at openjdk.org> wrote:

> ### Summary
> This change adds `os::committed_in_range` to `src/hotspot/os/posix/os_posix.cpp` so that AIX and MacOS can use it. It is mostly the same as the prior implementation in `os_linux.cpp`, but takes into account AIX may have unaligned stacks and variable page sizes, and that mincore uses a different argument type on linux.  This will allow AIX and MacOS to report true liveness information for thread stacks reported by NMT. Previously this was only possible on Windows and Linux.
> 
> **Testing**
> - `TestAlwaysPreTouchStacks.java` is updated to also test the case when stacks are large but mostly not paged in. 
> - A few new unit tests in `test_committed_virtualmemory.cpp` to check`os::committed_in_range`. I've excluded these tests on Windows because it reports the committed region as fully paged in. 
> - tier1
> 
> I've tested on Linux and Windows. I don't have a Mac to test on, but the Mac GHA tests are passing. Not yet tested on AIX.

Thanks for doing this, Robert.

I think we can simplify. No need to count page remainders.

First, get pagesize: non-aix os::vm_page_size, aix with sysconf 

can be as simple as 


const size_t ps = NOT_AIX(os::vm_page_size()) AIX_ONLY(sysconf(_SC_PAGESIZE));


Then please assert that boundaries are page-aligned. They should be. On AIX, we inner-page-align since [JDK-8332237](https://bugs.openjdk.org/browse/JDK-8332237). (https://github.com/openjdk/jdk/blob/9160ef8b9d9f2c87ca6df08d85dad4271085f0ac/src/hotspot/share/nmt/threadStackTracker.cpp#L54)

The rest then can be all simple shared coding.

Patch works on MacOS.

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

PR Review: https://git.openjdk.org/jdk/pull/19455#pullrequestreview-2090845902
PR Comment: https://git.openjdk.org/jdk/pull/19455#issuecomment-2159881666


More information about the hotspot-runtime-dev mailing list