Skip to content

Commit

Permalink
If no 4K pages, use smallest one as per omrvmem_startup
Browse files Browse the repository at this point in the history
Co-authored-by: Tobi Ajila <[email protected]>
Co-authored-by: Marius Pirvu <[email protected]>
Co-authored-by: Nathan Henderson <[email protected]>
Signed-off-by: Amarpreet Singh <[email protected]>
  • Loading branch information
4 people committed Jun 7, 2024
1 parent 3c8d63d commit 2b8da0c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions port/common/omrmem32helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ allocateVmemRegion32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount, J
*/
#if defined(OMR_PORT_CAN_RESERVE_SPECIFIC_ADDRESS)
J9PortVmemIdentifier *vmemID = NULL;
uintptr_t *pageSizes = NULL;
uintptr_t pageSize = 0;
uintptr_t i = 0;
J9HeapWrapper *wrapper = NULL;
Expand All @@ -556,8 +557,10 @@ allocateVmemRegion32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount, J
return NULL;
}

pageSizes = portLibrary->vmem_supported_page_sizes(portLibrary);

/* get the default page size */
pageSize = portLibrary->vmem_supported_page_sizes(portLibrary)[0];
pageSize = pageSizes[0];
if (0 == pageSize) {
Trc_PRT_mem_allocate_memory32_failed_page(callSite);
portLibrary->mem_free_memory(portLibrary, vmemID);
Expand All @@ -570,7 +573,15 @@ allocateVmemRegion32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount, J
// pageSize = 0x1000;
// }
/* Make sure that we only allocate 4k pages. */
pageSize = 0x1000;
// pageSize = 0x1000;
/* If 4K is not the default page size, then look for the smallest one as per omrvmem_startup. */
if (0x1000 != pageSize) {
for (i = 0 ; pageSizes[i] != 0 ; i++) {
if (pageSize > pageSizes[i]) {
pageSize = pageSizes[i];
}
}
}

#if defined(LINUX)
if (OMR_ARE_ALL_BITS_SET(PPG_mem32BitFlags, OMRPORT_MEM_32BIT_FLAGS_TMP_FILE_BACKED_VMEM)) {
Expand Down

0 comments on commit 2b8da0c

Please sign in to comment.