RFR: 8272807: Permit use of memory concurrent with pretouch
Kim Barrett
kbarrett at openjdk.java.net
Fri Feb 4 12:34:04 UTC 2022
On Fri, 4 Feb 2022 12:07:32 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> src/hotspot/share/runtime/os.cpp line 1771:
>>
>>> 1769: Atomic::add(reinterpret_cast<int*>(cur), 0, memory_order_relaxed);
>>> 1770: if (cur == last) break;
>>> 1771: }
>>
>> Took me some time to check the loop. Suggestion:
>>
>>
>> do {
>> Atomic::add(reinterpret_cast<int*>(cur), 0, memory_order_relaxed);
>> cur += page_size;
>> } while (cur < last);
>
> Intentionally didn't write it that way, because of the potential for UB pointer arithmetic overflow in `cur += page_size`.
Also, that won't touch the last page when first page != last page, unless the last page is made exclusive, which calculation could also suffer from UB pointer arithmetic overflow. Of course, the caller could suffer from that too; we can't so easily fix that. Representing address ranges as [start, end) just generally suffers from that problem.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7343
More information about the hotspot-runtime-dev
mailing list