8259380: Correct pretouch chunk size to cap with actual page size

Reviewed-by: tschatzl, sjohanss
This commit is contained in:
Patrick Zhang 2021-01-12 10:10:48 +00:00 committed by Thomas Schatzl
parent 28ff2de186
commit 67e1b639ba

View File

@ -64,13 +64,14 @@ void PretouchTask::work(uint worker_id) {
void PretouchTask::pretouch(const char* task_name, char* start_address, char* end_address,
size_t page_size, WorkGang* pretouch_gang) {
// Chunk size should be at least (unmodified) page size as using multiple threads
// pretouch on a single page can decrease performance.
size_t chunk_size = MAX2(PretouchTask::chunk_size(), page_size);
#ifdef LINUX
// When using THP we need to always pre-touch using small pages as the OS will
// initially always use small pages.
page_size = UseTransparentHugePages ? (size_t)os::vm_page_size() : page_size;
#endif
size_t chunk_size = MAX2(PretouchTask::chunk_size(), page_size);
PretouchTask task(task_name, start_address, end_address, page_size, chunk_size);
size_t total_bytes = pointer_delta(end_address, start_address, sizeof(char));