8261023: Document why memory pretouch must be a store

Reviewed-by: shade, iwalulya
This commit is contained in:
Thomas Schatzl 2021-02-04 13:47:51 +00:00
parent 83357b1196
commit be772ffaf3

@ -1814,6 +1814,10 @@ void os::print_memory_mappings(outputStream* st) {
void os::pretouch_memory(void* start, void* end, size_t page_size) {
for (volatile char *p = (char*)start; p < (char*)end; p += page_size) {
// Note: this must be a store, not a load. On many OSes loads from fresh
// memory would be satisfied from a single mapped page containing all zeros.
// We need to store something to each page to get them backed by their own
// memory, which is the effect we want here.
*p = 0;
}
}