RFR: 8277486: NMT: Cleanup ThreadStackTracker
Zhengyu Gu
zgu at openjdk.java.net
Mon Nov 22 15:46:44 UTC 2021
There are several issues with `ThreadStackTracker`.
1) Following assertion:
`assert(MemTracker::tracking_level() >= NMT_summary, "Must be");`
in `ThreadStackTracker::record/release_thread_stack()` is unreliable. The full fence after downgrading tracking level is *not* sufficient to avoid the racy.
2) NMT tracking level is downgraded without `ThreadCritical` lock held. But, it does require `ThreadCritical` lock to be held when it actually downgrade internal tracking data structure, so checking internal state is reliable to determine current tracking state.
Add assertion to ensure correct tracking state
3) `_thread_counter` is updated with `ThreadCritical` lock, but is read without the lock. Change to atomic update to ensure reader will not read stale value.
4) NMT events are relative rare. So far, I have yet seen (1) assertion failure but add new test may help to spot such problem.
-------------
Commit messages:
- Unnecessary check
- v1
- Merge branch 'master' into nmt_shutdown
- v0
Changes: https://git.openjdk.java.net/jdk/pull/6504/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6504&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8277486
Stats: 137 lines in 5 files changed: 124 ins; 6 del; 7 mod
Patch: https://git.openjdk.java.net/jdk/pull/6504.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6504/head:pull/6504
PR: https://git.openjdk.java.net/jdk/pull/6504
More information about the hotspot-runtime-dev
mailing list