RFR: 8346123: [REDO] NMT should not use ThreadCritical [v15]
David Holmes
dholmes at openjdk.org
Mon Jan 13 02:58:41 UTC 2025
On Fri, 10 Jan 2025 19:15:29 GMT, Robert Toyonaga <duke at openjdk.org> wrote:
> For JavaThreads:
In attach_current_thread, create_stack_guard_pages() and register_thread_stack_with_NMT() are called before Threads::add.
You can't attach to a VM until a certain point deep into initialization has been reached.
> For NonJavaThreads:
In Thread::call_run(), register_thread_stack_with_NMT() is called before NonJavaThread::pre_run() which later calls NonJavaThread::add_to_the_list().
Yes it is a problem that the created thread adds itself to the list.
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.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22745#issuecomment-2586086059
More information about the serviceability-dev
mailing list