RFR: 8280828: Improve invariants in NonblockingQueue::append [v2]

Thomas Schatzl tschatzl at openjdk.java.net
Tue Feb 8 13:16:04 UTC 2022


On Tue, 8 Feb 2022 10:09:48 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Please review this change to NonblockingQueue to improve invariants in the
>> append operation by making a change in try_pop.
>> 
>> When taking the last entry in the queue, try_pop needs to do some cleanup of
>> the queue fields, setting them to NULL.  The order of those cleanups doesn't
>> matter for correctness.  However, setting first _head then _tail permits
>> append to assert that _head is NULL when it finds _tail was NULL.  The current
>> order (set _tail first, then _head) doesn't permit such an assertion.
>> 
>> Testing:
>> mach5 tier1-3
>> 
>> I also did lots of testing with this change included while investigating
>> JDK-8273383.
>
> Kim Barrett has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - Merge branch 'master' into append-invariant
>  - minor comment fixes
>  - append invariant

Lgtm.

src/hotspot/share/utilities/nonblockingQueue.inline.hpp line 200:

> 198:     // cmpxchg indicates a concurrent operation updated _head first.  That
> 199:     // could be either a push/append or a try_pop in [Clause 1b].
> 200:     Atomic::cmpxchg(&_head, result, (T*)NULL);

These `NULL`s could be replaced by `nullptr`.

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

Marked as reviewed by tschatzl (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7250


More information about the hotspot-dev mailing list