Skip to content

Commit

Permalink
Fix code cache allocation with large pages enabled
Browse files Browse the repository at this point in the history
When large pages/huge pages are enabled and page size >= 1GB, code cache
size is rounded up to the page size. When codecachetotal is lesser than
the page size, this can make the size of code cache segment bigger
than the total code cache size.
In this case, page size should be recalculated to a smaller value.
Also a warning message should be printed in the verbose output.

Closes: ##18274
Signed-off-by: SajinaKandy <[email protected]>
  • Loading branch information
SajinaKandy committed Oct 31, 2023
1 parent a80c01f commit 040228e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions runtime/compiler/runtime/J9CodeCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ J9::CodeCacheManager::allocateCodeCacheSegment(size_t segmentSize,

TR::CodeCacheConfig &config = self()->codeCacheConfig();

UDATA ccTotalSizeB = config.codeCacheTotalKB() << 10;

size_t largeCodePageSize = config.largeCodePageSize();
#if defined(TR_TARGET_POWER) && defined(TR_HOST_POWER)
/* Use largeCodePageSize on PPC only if its 16M.
Expand All @@ -298,6 +300,19 @@ J9::CodeCacheManager::allocateCodeCacheSegment(size_t segmentSize,
{
vmemParams.pageSize = largeCodePageSize;
vmemParams.pageFlags = config.largeCodePageFlags();

// Recalculate the page size if using large pages
UDATA *pageSizes = j9vmem_supported_page_sizes();
if(vmemParams.pageSize > ccTotalSizeB)
{
for (UDATA pageIndex = 0; 0 != pageSizes[pageIndex]; ++pageIndex)
{
if(pageSizes[pageIndex] <= ccTotalSizeB)
vmemParams.pageSize = pageSizes[pageIndex];
}
if (config.verboseCodeCache() || config.verbosePerformance())
TR_VerboseLog::writeLineLocked(TR_Vlog_CODECACHE,"Warning: Using page size %zu instead of large page size %zu", (size_t)vmemParams.pageSize, largeCodePageSize);
}
}

UDATA mode = J9PORT_VMEM_MEMORY_MODE_READ |
Expand Down

0 comments on commit 040228e

Please sign in to comment.