On Mon, 6 Jan 2025 05:00:01 GMT, David Holmes <dhol...@openjdk.org> wrote:

> In case my comment within the existing conversations gets missed I will 
> re-state that I don't think you need any new "is bootstrapping" logic because 
> you can just use `Threads::number_of_threads() > 0` to tell you if you need 
> to acquire the NMT lock. Though that assumes that the `WatcherThread` does 
> not use NMT ... but in that case you can use `WatcherThread::watcher_thread() 
> != nullptr` as the bootstrap condition instead.

I think that the `WatcherThread` does use NMT (at least upon starting), since 
`Thread::call_run() ` calls `register_thread_stack_with_NMT()`. However, it 
looks like `WatcherThread::stop()` is called early in `before_exit` -- after 
which point NMT can still  be used. So checking 
`WatcherThread::watcher_thread() != nullptr` may not work in this case as it 
could be set back to nullptr too early.

Another solution might be to introduce something like 
`Threads::is_single_threaded()` which checks for  `WatcherThread`, 
`Threads::number_of_threads()`, and any other threads that fall outside this 
set. I'm not sure whether that would be better than the current approach.

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

PR Comment: https://git.openjdk.org/jdk/pull/22745#issuecomment-2573756615

Reply via email to