RFR: 8291714: Implement a Multi-Reader Single-Writer mutex for Hotspot [v2]
Johan Sjölén
duke at openjdk.org
Fri Aug 19 15:46:36 UTC 2022
On Fri, 19 Aug 2022 15:34:45 GMT, Johan Sjölén <duke at openjdk.org> wrote:
>> May I please have a review for this PR which implements a `MRWMutex` class for Hotspot?
>>
>> This PR does 3 things:
>>
>> * Adds a port of ZGC's MRSW mutex (see [0]) to Hotspot
>> * Adds some new utilities for writing multi-threaded tests.
>> * Adds some tests for MRSW Mutex using these new utilities
>>
>> The ticket has some comments which might be worth checking out: https://bugs.openjdk.org/browse/JDK-8291714
>>
>> [0] Original source code here: https://github.com/openjdk/zgc/blob/zgc_generational/src/hotspot/share/gc/z/zJNICritical.cpp
>
> Johan Sjölén has updated the pull request incrementally with one additional commit since the last revision:
>
> Review comments
I just pushed my first clean up of this code based on your comments.
Here's a short summary:
1. Rename to ReadWriteLock
2. Move to utilities
3. Remove template, use a conditional branch + lambda for ThreadBlockInVM (painful way of doing it, stefank has a good idea with the nullptr strategy)
4. Clarify some comments
5. Remove nullptr case from Locker, as it's not used in this code anyway
6. Use int32_t instead of int64_t for counter
Some of your comments are still not handled. Off the top of my head, I'm still not documenting everything that dholmes is interested in. @robehn has mentioned to me that there are issues when a safepointed thread holds a lock that the VM thread wants to hold, so that needs to be handled (he has also pointed out how to handle this).
Kim mentioned that UL might want to use GlobalCounter instead. This is viable, but contention on the global counter may lead to performance degradation for other users, AFAIK.
Finally, I will be simplifying this PR by pulling out the additions to threadHelper.inline.hpp into its own PR.
-------------
PR: https://git.openjdk.org/jdk/pull/9838
More information about the hotspot-runtime-dev
mailing list