RFR: 8264682: MemProfiling does not own Heap_lock when using G1

David Holmes dholmes at openjdk.java.net
Tue Apr 6 02:08:36 UTC 2021


On Mon, 5 Apr 2021 07:34:30 GMT, Yi Yang <yyang at openjdk.org> wrote:

> Trivial fix for JDK-8264682.
> 
> `Universe::heap()->used()` calls G1Allocator::used_in_alloc_regions() when G1 enabled,  it checks whether Heap_lock was owned on this thread's behalf.

Sorry but I have to agree with Kim that this is the wrong fix for this problem.

And the test needs adjusting.

Thanks,
David

src/hotspot/share/runtime/memprofiler.cpp line 120:

> 118:     // used() calls G1Allocator::used_in_alloc_regions() when G1 enabled,
> 119:     // it checks whether Heap_lock was owned on this thread's behalf.
> 120:     G1GC_ONLY(MutexLocker ml(Heap_lock);)

This seems really out of place - this code should not need to know anything about the specific locking requirements of different GC's. That should be handled inside the appropriate chunk of GC code.

test/hotspot/jtreg/runtime/MemProfiler/MemProfilingWithGC.java line 44:

> 42:             "UseShenandoahGC",
> 43:             "UseZGC",
> 44:             "UseEpsilonGC",

You have to allow for the fact that these GC's may not have all been built into the JVM under test.

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

Changes requested by dholmes (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3340



More information about the hotspot-gc-dev mailing list