RFR: 8346123: [REDO] NMT should not use ThreadCritical [v15]
Robert Toyonaga
duke at openjdk.org
Mon Jan 13 20:56:47 UTC 2025
On Mon, 13 Jan 2025 02:56:13 GMT, David Holmes <dholmes at openjdk.org> wrote:
> So a simple solution would be to just use Thread::number_of_threads() > 0 as the guard. That means we will skip the lock whilst it is unsafe to try and use it, then start using it once the main thread has "attached" even though it is not technically needed until there is another thread created.
Hi @dholmes-ora, I think it would still be problem that NonJavaThreads (such as `WatcherThread` and `AsyncLogWriter`) may use NMT before main_thread is "attached" and detectable with `Thread::number_of_threads()`.
Both JavaThreads and NonJavaThreads can use NMT before being detectable by `Thread::number_of_threads()` or `NonJavaThread::end()`. Threads also use NMT after `Threads::remove` or `NonJavaThread::remove_from_the_list()` is called. So it seems that even checking both `Thread::number_of_threads()` and `NonJavaThread::end()` doesn't reliably tell us whether the lock needs to be taken.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22745#issuecomment-2588176443
More information about the serviceability-dev
mailing list