VirtualMemoryTracker takes ThreadCritical lock to check tracking level to ensure that it does not race again NMT shutdown.
e.g. VirtualMemoryTracker::record_virtual_memory_split_reserved() has following comment:
if (addr != NULL) {
ThreadCritical tc;
// Recheck to avoid potential racing during NMT shutdown
if (tracking_level() < NMT_summary) return;
VirtualMemoryTracker::split_reserved_region((address)addr, size, split);
The comment seems incorrect, because NMT downgrades its tracking level without taking ThreadCritical lock, so reading tracking level is a race.
However, it may not be a problem, because tracking level can only be downgraded monotonically, ThreadCritical lock is held and tracking level is already downgraded before downgrading transition.
But this part of the code is obscure, we should re-examine and cleanup it up.
e.g. VirtualMemoryTracker::record_virtual_memory_split_reserved() has following comment:
if (addr != NULL) {
ThreadCritical tc;
// Recheck to avoid potential racing during NMT shutdown
if (tracking_level() < NMT_summary) return;
VirtualMemoryTracker::split_reserved_region((address)addr, size, split);
The comment seems incorrect, because NMT downgrades its tracking level without taking ThreadCritical lock, so reading tracking level is a race.
However, it may not be a problem, because tracking level can only be downgraded monotonically, ThreadCritical lock is held and tracking level is already downgraded before downgrading transition.
But this part of the code is obscure, we should re-examine and cleanup it up.
- relates to
-
JDK-8277486 NMT: Cleanup ThreadStackTracker
-
- Closed
-
-
JDK-8277990 NMT: Remove NMT shutdown capability
-
- Resolved
-