Skip to content


8261023: Document why memory pretouch must be a store
Browse files Browse the repository at this point in the history
Reviewed-by: shade, iwalulya
  • Loading branch information
Thomas Schatzl committed Feb 4, 2021
1 parent 83357b1 commit be772ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/share/runtime/os.cpp
Expand Up @@ -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;
Expand Down

1 comment on commit be772ff

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.