[crac] RFR: RCU Lock - RW lock with very lightweight read- and heavyweight write-locking [v5]

Radim Vansa duke at openjdk.org
Thu Apr 13 15:06:07 UTC 2023


On Thu, 13 Apr 2023 13:16:37 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> Radim Vansa has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add synchronized context
>
> src/java.base/share/classes/jdk/crac/RCULock.java line 32:
> 
>> 30:  * <strong>acquire</strong> the read-lock <strong>inside</strong> the critical
>> 31:  * section (at the beginning) and <strong>release</strong> it <strong>outside</strong>,
>> 32:  * preferrably in the <code>finally</code> block.
> 
> This assimetry in the interface does not look nice. Likely because the implementation, we can release the lock only outside a method with the critical code. But this leaks too much implementation details to the interface.

It would *almost* work except for interpreted mode; in compiled code the safepoint poll is only at method exit (and in uncounted loops). I couldn't find the specific place in code but I've read that in interpreted mode the safepoint may happen on every bytecode instruction, so we would have to somehow disable this. Sounds too fragile to expect that you could jump straight into the critical section.
Alternatively we could try to do flow analysis on the bytecode and check where's the critical section, but that's also too much work just to make it look a tad better. This type of lock is intended for very specific use anyway.

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

PR Review Comment: https://git.openjdk.org/crac/pull/58#discussion_r1165670679


More information about the crac-dev mailing list