RFR: 8369622: GlobalChunkPoolMutex is recursively locked during error handling [v3]

Afshin Zafari azafari at openjdk.org
Thu Oct 23 07:13:18 UTC 2025


On Wed, 22 Oct 2025 12:24:04 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> This change disables recursive locking for the ChunkPoolLocker during error handling for NMT callers.  The patch is written by Johan as an alternative to supporting another recursive locker for this lock.
>> Tested with tier1-4, tier5 on aarch64 (product and debug).
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Small things.

Thank you Coleen, for taking this PR.
All good.

src/hotspot/share/memory/arena.hpp line 46:

> 44:   bool _locked;
> 45: public:
> 46:   ChunkPoolLocker(LockStrategy ls = LockStrategy::Lock);

If the `LockStrategy` is defaulted to `Lock`, then all the instances of this lock used in `ChunkPool`'s cleaning functions (`return_to_pool`, `take_from_pool`, `prune` and `deallocate_chunk`) would try to lock this explicitly. So, when either of these called while NMT is reporting (acquired the lock), we have deadlock again.

src/hotspot/share/nmt/nmtUsage.cpp line 67:

> 65:     }
> 66:     ChunkPoolLocker cpl(ls);
> 67:     ms = MallocMemorySummary::as_snapshot();

Preexisting: 
The `MMS::as_snapshot()` just returns the pointer to the snapshot structure and does not update/access anything there. The life time of the `ChunkPoolLocker cpl` should be the whole body of the function.

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

Marked as reviewed by azafari (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27869#pullrequestreview-3360152979
PR Review Comment: https://git.openjdk.org/jdk/pull/27869#discussion_r2447860103
PR Review Comment: https://git.openjdk.org/jdk/pull/27869#discussion_r2447834489


More information about the hotspot-runtime-dev mailing list