RFR: 8263551: Provide shared lock-free FIFO queue implementation [v2]
Man Cao
manc at openjdk.java.net
Tue Mar 16 09:06:39 UTC 2021
On Sun, 14 Mar 2021 01:12:16 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> Man Cao has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Address comment and add a gtest.
>
> src/hotspot/share/utilities/lockFreeQueue.hpp line 46:
>
>> 44: //
>> 45: // \tparam rcu_pop true if use GlobalCounter critical section in pop().
>> 46: template<typename T, T* volatile* (*next_ptr)(T&), bool rcu_pop>
>
> I think this is the wrong place for the rcu parameterization. Among other things, it violates the SCARY principle for template design, making the entire class dependent on this parameter that is only relevant to the one operation. I think it would be better if the parameterization was on the pop operation.
Thanks. My experience on template design is limited. Good to learn about the SCARY principle!
> src/hotspot/share/utilities/lockFreeQueue.inline.hpp line 58:
>
>> 56: // CS could lead to excessive allocation of objects, because the CS
>> 57: // may block return of released objects to a free list for reuse.
>> 58: LockFreeQueueCriticalSection<rcu_pop> cs(current_thread);
>
> The comment about excessive allocation is closely tied to the use in G1DirtyCardQueueSet. The purpose of a critical section here needs further description and generalization. I'm wondering whether it's actually important (maybe it is, just not sure and haven't though about it for a while), but I'm also thinking LockFreeQueue/Stack ought to be consistent about this. That would suggest a common utility for optional critical sections.
I added a ConditionalCriticalSection class to globalCounter.hpp.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2986
More information about the hotspot-dev
mailing list