Skip to content
Permalink
Browse files
8261023: Document why memory pretouch must be a store
Reviewed-by: shade, iwalulya
  • Loading branch information
Thomas Schatzl committed Feb 4, 2021
1 parent 83357b1 commit be772ffaf3263b9505f051a88b4a9e965fb98fe7
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/hotspot/share/runtime/os.cpp
@@ -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;
}
}

0 comments on commit be772ff

Please sign in to comment.