RFR: 8263551: Provide shared lock-free FIFO queue implementation

David Holmes david.holmes at oracle.com
Sat Mar 13 12:12:21 UTC 2021


On 13/03/2021 9:02 pm, Man Cao wrote:
> On Sat, 13 Mar 2021 10:41:44 GMT, Man Cao <manc at openjdk.org> wrote:
> 
>> Hi all,
>>
>> Could anyone review this change that is mainly code motion? It creates a generalized lock-free queue implementation based on G1DirtyCardQueueSet::Queue, which will be used by JDK-8236485 in the future.
>>
>> The shared LockFreeQueue is similar to the existing LockFreeStack. The notable difference is that the LockFreeQueue has an additional template parameter for whether to use GlobalCounter::CriticalSection to avoid ABA problem.
>>
>> -Man
> 
> src/hotspot/share/utilities/lockFreeQueue.hpp line 99:
> 
>> 97:     } else {
>> 98:       assert(get_next(*old_tail) == NULL, "invariant");
>> 99:       Atomic::store(next_ptr(*old_tail), &first);
> 
> I changed this store from a normal store to an Atomic store. Otherwise there is a data race between this store and the load of _head->_next in pop().

Atomic store just ensures no word-tearing, it has no impact on ordering 
or data races.

David
-----

> -------------
> 
> PR: https://git.openjdk.java.net/jdk/pull/2986
> 


More information about the hotspot-dev mailing list