RFR: 8322853: Should use ConditionalMutexLocker in NativeHeapTrimmerThread::print_state
David Holmes
dholmes at openjdk.org
Wed Jan 3 01:52:49 UTC 2024
On Tue, 2 Jan 2024 16:04:30 GMT, Denghui Dong <ddong at openjdk.org> wrote:
> Hi all,
>
> Please help review this small fix.
>
> MutexLocker requires that mutex != nullptr, so we should use ConditionalMutexLocker instead.
>
> Also, this patch made '_stop' volatile, since it will be read twice in run() but may be changed.
ConditionalMutexLocker change is fine
> Also, this patch made '_stop' volatile, since it will be read twice in run() but may be changed.
The only way it can be changed is if a `wait` is done which releases and reacquires the mutex, and the variable is only set while holding the mutex, so reading it twice in run is perfectly safe without it being volatile.
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/17226#pullrequestreview-1801282374
More information about the hotspot-runtime-dev
mailing list