RFR: 8291714: Implement a Multi-Reader Single-Writer mutex for Hotspot

Coleen Phillimore coleenp at openjdk.org
Thu Aug 18 20:26:36 UTC 2022


On Thu, 11 Aug 2022 15:18:10 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

I also want to echo David's bikeshedding comment.  Two things - I can't speak this name so am unlikely to recommend further use of this class if someone asks, and it looks too much like Mutex which has a lot of differences, and pretty simple, so don't make that more complicated to share functionality.
For some reason, I can't believe that we don't have this feature already in the vm, or at least, I was expecting this to be a simple wrapper over globalCounter.hpp. Or SingleWriterSynchronizer.hpp (whose name I can say).
If it's the same as the ZGC version, maybe the ZGC version should be moved or reconciled in the utilities directory.

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

PR: https://git.openjdk.org/jdk/pull/9838


More information about the hotspot-runtime-dev mailing list