RFR: 8304824: NMT should not use ThreadCritical [v5]
David Holmes
dholmes at openjdk.org
Sun Sep 22 23:25:36 UTC 2024
On Sun, 22 Sep 2024 10:15:29 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> src/hotspot/share/runtime/mutexLocker.hpp line 197:
>>
>>> 195: _mutex(mutex) {
>>> 196: bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag;
>>> 197: if (_mutex != nullptr && Thread::current_or_null() != nullptr) {
>>
>> I do not like this addition to the mutex locker code. First, it probably needs to be `Thread::current_or_null_safe` in case we ever lock in a signal-handling context. But second this slows down all mutex uses. Instead `NMTLocker` should extend ConditionalMutexLocker and make the current thread check the condition.
>
> @dholmes-ora I agree with you, but it seems strange that MutexLockerImpl even handles mutex==null instead of asserting that.
It may be that not all uses were switched over to ConditionalMutexLocker when it was introduced. Passing null during init phase was common practice when no locking needed; possibly also cases of passing null if already locked.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20852#discussion_r1770656878
More information about the serviceability-dev
mailing list