RFR: 8288904: Incorrect memory ordering in UL [v2]
Johan Sjölén
duke at openjdk.org
Fri Jul 29 08:15:10 UTC 2022
On Wed, 22 Jun 2022 21:57:59 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> @dholmes-ora,
>>
>> The implementation is lock-free and uses RCU.
>>
>> This is approximately how it works in pseudo-code:
>>
>>
>> class LogOutputList {
>> LogOutputNode* entry; // All threads gain entry to the linked list through this pointer
>> }
>>
>> void LogOutputList::mutate_output_list() {
>> // Save the entry pointer
>> LogOutputNode* cur = entry;
>> // Remove the entry pointer, now no new readers can access this list
>> entry = NULL;
>> // OK, we can now wait for all readers to exit
>> wait_until_no_readers();
>> // ... Do things we need to do to cur ...
>> // Restore pointer, new readers can occur.
>> entry = cur;
>> }
>>
>>
>> There are some details here which I have omitted, but this is the gist of it.
>
>> There are some details here which I have omitted, but this is the gist of it.
>
> @jdksjolen - it is the actual details I have concerns about. More seems to be done than just a pointer switch to unlink, and the unlink itself is not an atomic operation - are we guaranteed only a single writer is possible? And even so, as others have noted, without atomics or barriers there is no guarantee readers will see the unlink has happened. I'm a bit surprised as this code has been extensively examined in the past.
This PR is still looking for a sponsor. @dholmes-ora, would you mind sponsoring this?
-------------
PR: https://git.openjdk.org/jdk/pull/9225
More information about the hotspot-runtime-dev
mailing list