Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -Xlp:offheap: #21048

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 56 additions & 8 deletions runtime/gc_modron_startup/mmparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,13 @@ gcParseXlpOption(J9JavaVM *vm)
IDATA xlpGCIndex = -1;
UDATA requestedPageSize = 0;
UDATA requestedPageFlags = J9PORT_VMEM_PAGE_FLAG_NOT_USED;
UDATA *pageSizes;
UDATA *pageFlags;
PORT_ACCESS_FROM_JAVAVM(vm);

pageSizes = j9vmem_supported_page_sizes();
pageFlags = j9vmem_supported_page_flags();
Copy link
Contributor

Choose a reason for hiding this comment

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

could initialize at definition line


/* Parse -Xlp option.
* -Xlp option enables large pages with the default large page size, but will not
* override any -Xlp<size> or -Xlp:objectheap:pagesize=<size> option.
Expand Down Expand Up @@ -782,18 +787,16 @@ gcParseXlpOption(J9JavaVM *vm)
}

/*
* Check for -Xlp:gc: and handle it if necessary
* Check for -Xlp:gcmetadata: and handle it if necessary
*/
xlpGCIndex = FIND_AND_CONSUME_VMARG(STARTSWITH_MATCH, "-Xlp:gcmetadata:", NULL);

if (-1 != xlpGCIndex) {
UDATA gcmetadataPageSize = 0;
UDATA gcmetadataPageFlags = J9PORT_VMEM_PAGE_FLAG_NOT_USED;
UDATA *pageSizes;
UDATA *pageFlags;
bool found = false;
/*
* Parse sub options for -Xlp:gc:
* Parse sub options for -Xlp:gcmetadata:
*/
xlpErrorState = xlpSubOptionsParser(vm, xlpGCIndex, &xlpError, &gcmetadataPageSize, &gcmetadataPageFlags, NULL, NULL);

Expand All @@ -809,15 +812,12 @@ gcParseXlpOption(J9JavaVM *vm)
/*
* Update values in case of exact match only
*/
pageSizes = j9vmem_supported_page_sizes();
pageFlags = j9vmem_supported_page_flags();

for (UDATA pageIndex = 0; 0 != pageSizes[pageIndex]; ++pageIndex) {
if ((pageSizes[pageIndex] == gcmetadataPageSize) && (pageFlags[pageIndex] == gcmetadataPageFlags)) {
found = true;
extensions->gcmetadataPageSize = gcmetadataPageSize;
extensions->gcmetadataPageFlags = gcmetadataPageFlags;
break;
break;
}
}

Expand All @@ -834,6 +834,54 @@ gcParseXlpOption(J9JavaVM *vm)
}
}

/*
* Check for -Xlp:offheap: and handle it if necessary
*/
xlpGCIndex = FIND_AND_CONSUME_VMARG(STARTSWITH_MATCH, "-Xlp:offheap:", NULL);

if (-1 != xlpGCIndex) {
UDATA offheapPageSize = 0;
UDATA offheapPageFlags = J9PORT_VMEM_PAGE_FLAG_NOT_USED;
bool found = false;
/*
* Parse sub options for -Xlp:offheap:
*/
xlpErrorState = xlpSubOptionsParser(vm, xlpGCIndex, &xlpError, &offheapPageSize, &offheapPageFlags, NULL, NULL);

if (XLP_NO_ERROR != xlpErrorState) {
goto _reportXlpError;
}

if (xlpError.extraCommaWarning) {
/* print extra comma ignored warning */
j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_GC_OPTIONS_XLP_EXTRA_COMMA);
}

/*
* Update values in case of exact match only
*/
for (UDATA pageIndex = 0; 0 != pageSizes[pageIndex]; ++pageIndex) {
if ((pageSizes[pageIndex] == offheapPageSize) && (pageFlags[pageIndex] == offheapPageFlags)) {
found = true;
extensions->sparseHeapPageSize = offheapPageSize;
extensions->sparseHeapPageFlags = offheapPageFlags;
break;
}
}

if (!found) {
const char *oldQualifier, *newQualifier;
Copy link
Contributor

Choose a reason for hiding this comment

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

could initialize to null (for gcmetadata too)

UDATA oldSize = offheapPageSize;
UDATA newSize = extensions->sparseHeapPageSize;
const char *oldPageType = getPageTypeStringWithLeadingSpace(oldSize);
const char *newPageType = getPageTypeStringWithLeadingSpace(newSize);
qualifiedSize(&oldSize, &oldQualifier);
qualifiedSize(&newSize, &newQualifier);

j9nls_printf(PORTLIB, J9NLS_INFO, J9NLS_GC_OPTIONS_XLP_PAGE_NOT_SUPPORTED, "offheap", oldSize, oldQualifier, oldPageType, newSize, newQualifier, newPageType);
}
}

_reportXlpError:
/* If error occurred during parsing of -Xlp options, report it here. */
if (XLP_NO_ERROR != xlpErrorState) {
Expand Down