RFR: 8328083: degrade virtual thread support for GetObjectMonitorUsage [v3]

Chris Plummer cjplummer at openjdk.org
Tue May 14 17:54:05 UTC 2024


On Fri, 3 May 2024 10:42:45 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:

>> ...and there are also comments above with this issue.
>
>> expEnteringCount/expWaitingCount contain the tested patterns.
> 
> I kind of disagree.
> Please, take look at the loop below:
> 
>             for (int i = 0; i < NUMBER_OF_WAITING_THREADS; i++) {
>                 expEnteringCount = isVirtual ? 0 : NUMBER_OF_ENTERING_THREADS + i + 1;
>                 expWaitingCount  = isVirtual ? 0 : NUMBER_OF_WAITING_THREADS - i - 1;
>                 lockCheck.notify(); // notify waiting threads one by one
>                 // now the notified WaitingTask has to be blocked on the lockCheck re-enter
> 
>                 // entry count: 1
>                 // count of threads waiting to enter:       NUMBER_OF_ENTERING_THREADS
>                 // count of threads waiting to re-enter:    i + 1
>                 // count of threads waiting to be notified: NUMBER_OF_WAITING_THREADS - i - 1
>                 check(lockCheck, expOwnerThread(), expEntryCount(),
>                       expEnteringCount,
>                       expWaitingCount);
>             }
> 
> The comment fixed as you suggest does not look useful anymore as the tested pattern is lost:
> 
>                 // entry count: expOwnerThread()
>                 // count of threads waiting to enter:       expEnteringCount
>                 // count of threads waiting to re-enter:   expEntryCount()
>                 // count of threads waiting to be notified: expWaitingCount
>                 check(lockCheck, expOwnerThread(), expEntryCount(),
>                       expEnteringCount,
>                       expWaitingCount);
>             }
> 
> 
> I understand your concern but your suggestion is not that good.
> We could remove these comments but the tested pattern will be thrown away with the comments.
> Would it help if we add clarifications that the comments are correct for platform threads only?

I don't understand the issue with the updated commented. It is precisely telling you what the expected "count" values should be. If you leave the macros in the comment, then the comment is wrong for virtual threads. If you want to keep the macros in the comment, you need to add something like "... or 0 for virtual threads".

BTW, the "re-enter" comment should continue to be "i + 1". I'm not sure why it was changed to "expEntryCount()".

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19030#discussion_r1600436569


More information about the serviceability-dev mailing list