RFR: 8346123: [REDO] NMT should not use ThreadCritical [v15]

Robert Toyonaga duke at openjdk.org
Mon Jan 13 22:18:44 UTC 2025


On Mon, 13 Jan 2025 21:21:55 GMT, David Holmes <dholmes at openjdk.org> wrote:

>I need to rewind a few steps and see exactly what it is we need to be initialized before this lock can be used

Before `NmtVirtualMemoryLocker` can be used, Hotspot mutexes must be initialized (`vm_init_globals()`) and `main_thread->initialize_thread_current()` must be called.  This happens relatively early in `create_vm`.

Hmmm I'm not sure anymore if introducing `is_single_threaded()` is the best approach.  [The original intention](https://github.com/openjdk/jdk/pull/22745#issuecomment-2574379871) was to avoid introducing yet another initialization-progress marker by pivoting from the old approach of setting `Mutex::is_bootstrapping_done()` as soon as it is safe to use `NmtVirtualMemoryLocker` . The downside I've discovered is that there doesn't seem to be a good way to reliably implement `is_single_threaded()` such that it's safe to guard `NmtVirtualMemoryLocker` usage.  And the various workarounds that seem to be necessary make me feel like this approach is more brittle than the original, while at the same time end up tailoring `is_single_threaded()` specifically to this NMT use case - which goes against our original goal.  What do you think?

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

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


More information about the serviceability-dev mailing list