RFR: 8356173: Remove ThreadCritical
Coleen Phillimore
coleenp at openjdk.org
Fri May 9 14:58:54 UTC 2025
On Fri, 9 May 2025 13:20:06 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:
>> Updated the description in the bug. This removes the last use of ThreadCritical and replaces it with a global PlatformMutex lock.
>> Tested with tier1-4, and tier1 on all Oracle-supported OSs.
>
> src/hotspot/share/nmt/mallocTracker.cpp line 68:
>
>> 66: // copy is going on, because their size is adjusted using this
>> 67: // buffer in make_adjustment().
>> 68: ChunkPoolLocker lock;
>
> At the time NMT was written, `ThreadCritical` was the only native lock. I wonder it is the time NMT gets its own lock?
Yes, ThreadCritical preceded the PlatformMutex locks, which were added later. We had ThreadCritical (iirc) for a limitation in the Windows malloc code, which is why it was around all the os::malloc calls once. NMT just built upon that since it was there.
We cannot use regular Mutex because Mutex requires Thread::current() which doesn't exist at this point. The NMT code might be able to use a lock around the code that deletes arenas, as the comments suggest that it is trying to protect. This could be a regular Mutex because the arena code is deleted individually and purged well after startup time. I left this as a shared lock, but it could be further improved to use a nmt-delete-lock Mutex.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25072#discussion_r2081860936
More information about the hotspot-dev
mailing list