RFR: 8288904: Incorrect memory ordering in UL [v2]
Johan Sjölén
duke at openjdk.org
Wed Jun 22 13:57:11 UTC 2022
On Wed, 22 Jun 2022 12:31:31 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Johan Sjölén has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Comment the loadstore
>
> This fix in itself looks good.
>
> But it raises a lot of questions for me about how concurrent access is actual controlled here. I can't see what stops a new reader from becoming active after we see _active_readers go to zero?
>
> Thanks.
@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.
-------------
PR: https://git.openjdk.org/jdk/pull/9225
More information about the hotspot-runtime-dev
mailing list