JDK-8243535 : NMT may show wrong numbers for CDS and CCS
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-24
  • Updated: 2024-10-17
  • Resolved: 2020-06-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15 JDK 16
15 b27Fixed 16Resolved
Related Reports
Blocks :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
NMT is not able to correctly follow os::split_reserved_memory operations.

os::split_reserved_memory() is used when a ReservedSpace is split in two with the "split" parameter set to true, which we (only) use when CDS reserves space for class space and archives together and then splits those regions up.

On Posix platforms, os::split_reserved_memory() is a noop since no interaction with the OS is needed. Therefore, to NMT, this split is invisible.

So we cannot split a region and then track those regions with different NMT flags. The effect of this error is that in the NMT summary "mtShared" and "Class" may be wrong:

Reproduction:

../../jdks/sapmachine14/bin/java -XX:CompressedClassSpaceSize=3G  -XX:NativeMemoryTracking=summary -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics -Xlog:cds*,gc+metaspace=trace -XX:ArchiveRelocationMode=1
Native Memory Tracking:

Total: reserved=7730887KB, committed=347843KB
-                 Java Heap (reserved=4091904KB, committed=258048KB)
                            (mmap: reserved=4091904KB, committed=258048KB) 
 
-                     Class (reserved=8302KB, committed=4462KB)
                            (classes #652)
                            (  instance classes #552, array classes #100)
                            (malloc=110KB #738) 
                            (mmap: reserved=8192KB, committed=4352KB) 
                            (  Metadata:   )
                            (    reserved=8192KB, committed=4352KB)
                            (    used=254KB)
                            (    free=4098KB)
                            (    waste=0KB =0,00%)
                            (  Class space:)
                            (    reserved=3145728KB, committed=512KB)
                            (    used=24KB)
                            (    free=488KB)
                            (    waste=0KB =0,00%)
 
-                    Thread (reserved=18553KB, committed=833KB)
                            (thread #18)
                            (stack: reserved=18472KB, committed=752KB)
                            (malloc=61KB #110) 
                            (arena=19KB #34)
 
-                      Code (reserved=247736KB, committed=7596KB)
                            (malloc=48KB #492) 
                            (mmap: reserved=247688KB, committed=7548KB) 
 
-                        GC (reserved=203613KB, committed=61341KB)
                            (malloc=17965KB #2148) 
                            (mmap: reserved=185648KB, committed=43376KB) 
 
-                  Compiler (reserved=332KB, committed=332KB)
                            (malloc=3KB #44) 
                            (arena=329KB #10)
 
-                  Internal (reserved=1440KB, committed=1440KB)
                            (malloc=1404KB #988) 
                            (mmap: reserved=36KB, committed=36KB) 
 
-                    Symbol (reserved=1136KB, committed=1136KB)
                            (malloc=776KB #246) 
                            (arena=360KB #1)
 
-    Native Memory Tracking (reserved=111KB, committed=111KB)
                            (malloc=5KB #71) 
                            (tracking overhead=106KB)
 
-        Shared class space (reserved=3157028KB, committed=11812KB)
                            (mmap: reserved=3157028KB, committed=11812KB) 
 
-               Arena Chunk (reserved=618KB, committed=618KB)
                            (malloc=618KB) 
 
-                   Logging (reserved=5KB, committed=5KB)
                            (malloc=5KB #198) 
 
-                 Arguments (reserved=13KB, committed=13KB)
                            (malloc=13KB #431) 
 
-                    Module (reserved=59KB, committed=59KB)
                            (malloc=59KB #1035) 
 
-                 Safepoint (reserved=8KB, committed=8KB)
                            (mmap: reserved=8KB, committed=8KB) 
 
-           Synchronization (reserved=28KB, committed=28KB)
                            (malloc=28KB #181) 
 

We reserve 3G of compressed class space, but the 3G show up as reserved area under "Shared Classes". This only happens when we artificially disable the common cds base address with ArchiveRelocationMode=1, because otherwise CDS just creates two mappings.







Comments
This bug introduced a subtle bug in VirtualMemoryRegion::overlap_region() which was fixed with JDK-8263455
30-06-2021

Note that this introduced a subtle bug in VirtualMemory::overlap_region() which then was fixed with JDK-8263455.
30-06-2021

Fix was pushed while main bug was targeted to '16'. Reset the main bug to fixed in '15' and copied the hgupdater entry here.
09-06-2020

HG Updates added a comment - 7 hours ago URL: https://hg.openjdk.java.net/jdk/jdk/rev/c5211129e21e User: stuefe Date: 2020-06-09 06:43:20 +0000
09-06-2020

Already fixed in JDK15 repo.
09-06-2020

ILW = MLM = P4
28-04-2020