RFR: 8332362: Implement os::committed_in_range for MacOS and AIX [v4]

Martin Doerr mdoerr at openjdk.org
Wed Jun 12 19:35:15 UTC 2024


On Tue, 11 Jun 2024 21:58:28 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.
>
> Robert Toyonaga has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Simplification. Just cast address to char* on aix.

I'm getting gtest failures on AIX:

[ RUN      ] CommittedVirtualMemory.test_full_committed_in_range_vm
test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp:243: Failure
Value of: result
  Actual: false
Expected: true

[  FAILED  ] CommittedVirtualMemory.test_full_committed_in_range_vm (9 ms)
[ RUN      ] CommittedVirtualMemory.test_partial_committed_in_range_vm
test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp:277: Failure
Value of: result
  Actual: false
Expected: true

[  FAILED  ] CommittedVirtualMemory.test_partial_committed_in_range_vm (0 ms)

And in runtime/Thread/TestAlwaysPreTouchStacks.java#preTouch:

Native Memory Tracking:

Total: reserved=1788826570, committed=237654986
       malloc: 54547402 #15174, peak=54334442 #14990
       mmap:   reserved=1734279168, committed=183107584

-                 Java Heap (reserved=134217728, committed=134217728)
                            (mmap: reserved=134217728, committed=134217728, at peak)

-                     Class (reserved=1073862097, committed=644561)
                            (classes #799)
                            (  instance classes #687, array classes #112)
                            (malloc=120273 #1928) (peak=120417 #1925)
                            (mmap: reserved=1073741824, committed=524288, at peak)
                            (  Metadata:   )
                            (    reserved=67108864, committed=5505024)
                            (    used=5384968)
                            (    waste=120056 =2.18%)
                            (  Class space:)
                            (    reserved=1073741824, committed=524288)
                            (    used=496080)
                            (    waste=28208 =5.38%)

-                    Thread (reserved=169253800, committed=105384)
                            (threads #30)
                            (stack: reserved=169148416, committed=0)
                            (malloc=67536 #210) (peak=76304 #216)
                            (arena=37848 #65) (peak=154160 #28)

-                      Code (reserved=253840128, committed=6638336)
                            (malloc=150272 #1612) (at peak)
                            (mmap: reserved=253689856, committed=6488064, at peak)
                            (arena=0 #0) (peak=984 #1)

-                        GC (reserved=85380018, committed=85380018)
                            (malloc=49073074 #1101) (at peak)
                            (mmap: reserved=36306944, committed=36306944, at peak)

-                 GCCardSet (reserved=29928, committed=29928)
                            (malloc=29928 #387) (at peak)

-                  Compiler (reserved=172764, committed=172764)
                            (malloc=4204 #32) (peak=4340 #33)
                            (arena=168560 #5) (peak=2287712 #7)

-                  Internal (reserved=304202, committed=304202)
                            (malloc=238666 #2256) (peak=238770 #2262)
                            (mmap: reserved=65536, committed=65536, at peak)

-                    Symbol (reserved=2050243, committed=2050243)
                            (malloc=928859 #4132) (at peak)
                            (arena=1121384 #1) (at peak)

-    Native Memory Tracking (reserved=251608, committed=251608)
                            (malloc=8824 #133) (peak=9176 #137)
                            (tracking overhead=242784)

-               Arena Chunk (reserved=2010184, committed=2010184)
                            (malloc=2010184 #161) (peak=3461024 #139)

-                   Tracing (reserved=313, committed=313)
                            (malloc=313 #9) (at peak)

-                Statistics (reserved=128, committed=128)
                            (malloc=128 #2) (at peak)

-                 Arguments (reserved=77, committed=77)
                            (malloc=77 #4) (at peak)

-                    Module (reserved=174488, committed=174488)
                            (malloc=174488 #2095) (at peak)

-           Synchronization (reserved=139056, committed=139056)
                            (malloc=139056 #1083) (at peak)

-            Serviceability (reserved=17144, committed=17144)
                            (malloc=17144 #10) (peak=17288 #12)

-                 Metaspace (reserved=67121728, committed=5517888)
                            (malloc=12864 #10) (at peak)
                            (mmap: reserved=67108864, committed=5505024, at peak)

-      String Deduplication (reserved=608, committed=608)
                            (malloc=608 #8) (at peak)

-           Object Monitors (reserved=328, committed=328)
                            (malloc=328 #1) (at peak)

-                   Unknown (reserved=0, committed=0)
                            (mmap: reserved=0, committed=0, peak=65536)

];
 stderr: []
 exitValue = 0

java.lang.RuntimeException: Expected a higher ratio between stack committed and reserved.
	at TestAlwaysPreTouchStacks.main(TestAlwaysPreTouchStacks.java:158)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
	at java.base/java.lang.Thread.run(Thread.java:1575)

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

PR Comment: https://git.openjdk.org/jdk/pull/19455#issuecomment-2163756784
PR Comment: https://git.openjdk.org/jdk/pull/19455#issuecomment-2163760524


More information about the hotspot-runtime-dev mailing list