RFR: 8247972: incorrect implementation of JVM TI GetObjectMonitorUsage [v9]

Serguei Spitsyn sspitsyn at openjdk.org
Mon Feb 19 13:35:58 UTC 2024


On Fri, 16 Feb 2024 06:09:40 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Serguei Spitsyn has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   review: JDWP monitor_info spec clarification; removed debugging code from objmonusage001
>
> src/hotspot/share/prims/jvmtiEnvBase.cpp line 1500:
> 
>> 1498:     for (int i = 0; i < nWait; i++) {
>> 1499:       if (waiter == nullptr || (i != 0 && waiter == mon->first_waiter())) {
>> 1500:         // robustness: the waiting list has gotten smaller
> 
> We are at a safepoint so I don't see how the wait list can shrink. I initially thought perhaps a waiter could timeout, but the code that does the timed park is wrapped in ` ThreadBlockInVMPreprocess` which will block at a safepoint if one is active.

Thank you for the question.
The `nWait` count we got from the `mon->waiters()` can include the threads that are re-entering the monitor after being notified. Here we are correcting the actual number of the waiting threads by excluding those re-entering the monitor. The comment need an update to explain it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17680#discussion_r1494556207


More information about the serviceability-dev mailing list