mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
8067469: G1 ignores AlwaysPreTouch
Factor out pretouch code of the various virtual space management classes and use them everywhere including in G1. Reviewed-by: stefank, ehelin, dholmes
This commit is contained in:
parent
12273757f7
commit
f2e110fe77
5 changed files with 16 additions and 16 deletions
|
@ -131,6 +131,9 @@ MemRegion G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages)
|
||||||
_committed.set_range(start, start + size_in_pages);
|
_committed.set_range(start, start + size_in_pages);
|
||||||
|
|
||||||
MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize);
|
MemRegion result((HeapWord*)page_start(start), byte_size_for_pages(size_in_pages) / HeapWordSize);
|
||||||
|
if (AlwaysPreTouch) {
|
||||||
|
os::pretouch_memory((char*)result.start(), (char*)result.end());
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,7 @@ void MutableSpace::numa_setup_pages(MemRegion mr, bool clear_space) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MutableSpace::pretouch_pages(MemRegion mr) {
|
void MutableSpace::pretouch_pages(MemRegion mr) {
|
||||||
for (volatile char *p = (char*)mr.start(); p < (char*)mr.end(); p += os::vm_page_size()) {
|
os::pretouch_memory((char*)mr.start(), (char*)mr.end());
|
||||||
char t = *p; *p = t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MutableSpace::initialize(MemRegion mr,
|
void MutableSpace::initialize(MemRegion mr,
|
||||||
|
|
|
@ -1588,6 +1588,11 @@ bool os::release_memory(char* addr, size_t bytes) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void os::pretouch_memory(char* start, char* end) {
|
||||||
|
for (volatile char *p = start; p < end; p += os::vm_page_size()) {
|
||||||
|
*p = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char* os::map_memory(int fd, const char* file_name, size_t file_offset,
|
char* os::map_memory(int fd, const char* file_name, size_t file_offset,
|
||||||
char *addr, size_t bytes, bool read_only,
|
char *addr, size_t bytes, bool read_only,
|
||||||
|
|
|
@ -311,6 +311,12 @@ class os: AllStatic {
|
||||||
static bool uncommit_memory(char* addr, size_t bytes);
|
static bool uncommit_memory(char* addr, size_t bytes);
|
||||||
static bool release_memory(char* addr, size_t bytes);
|
static bool release_memory(char* addr, size_t bytes);
|
||||||
|
|
||||||
|
// Touch memory pages that cover the memory range from start to end (exclusive)
|
||||||
|
// to make the OS back the memory range with actual memory.
|
||||||
|
// Current implementation may not touch the last page if unaligned addresses
|
||||||
|
// are passed.
|
||||||
|
static void pretouch_memory(char* start, char* end);
|
||||||
|
|
||||||
enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
|
enum ProtType { MEM_PROT_NONE, MEM_PROT_READ, MEM_PROT_RW, MEM_PROT_RWX };
|
||||||
static bool protect_memory(char* addr, size_t bytes, ProtType prot,
|
static bool protect_memory(char* addr, size_t bytes, ProtType prot,
|
||||||
bool is_committed = true);
|
bool is_committed = true);
|
||||||
|
|
|
@ -615,19 +615,7 @@ bool VirtualSpace::expand_by(size_t bytes, bool pre_touch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pre_touch || AlwaysPreTouch) {
|
if (pre_touch || AlwaysPreTouch) {
|
||||||
int vm_ps = os::vm_page_size();
|
os::pretouch_memory(previous_high, unaligned_new_high);
|
||||||
for (char* curr = previous_high;
|
|
||||||
curr < unaligned_new_high;
|
|
||||||
curr += vm_ps) {
|
|
||||||
// Note the use of a write here; originally we tried just a read, but
|
|
||||||
// since the value read was unused, the optimizer removed the read.
|
|
||||||
// If we ever have a concurrent touchahead thread, we'll want to use
|
|
||||||
// a read, to avoid the potential of overwriting data (if a mutator
|
|
||||||
// thread beats the touchahead thread to a page). There are various
|
|
||||||
// ways of making sure this read is not optimized away: for example,
|
|
||||||
// generating the code for a read procedure at runtime.
|
|
||||||
*curr = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_high += bytes;
|
_high += bytes;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue