diff --git a/runtime/gc_modron_startup/mminit.cpp b/runtime/gc_modron_startup/mminit.cpp index 3f6bacaaf9d..7a988b21677 100644 --- a/runtime/gc_modron_startup/mminit.cpp +++ b/runtime/gc_modron_startup/mminit.cpp @@ -3183,7 +3183,12 @@ gcReinitializeDefaultsForRestore(J9VMThread* vmThread) PORT_ACCESS_FROM_JAVAVM(vm); OMRPORT_ACCESS_FROM_J9PORT(PORTLIB); - extensions->gcThreadCountForced = false; + /* If Snapshot VM did not specify -Xgcthreads or -Xgcmaxthreads, the count will be determined from scratch, either as new restore default or through restore specified options. + * If Snapshot VM did specify, we want to continue using the count value unless (only) restore specific options override it */ + if (!extensions->gcThreadCountSpecified) { + extensions->gcThreadCount = 0; + extensions->gcThreadCountForced = false; + } extensions->parSweepChunkSize = 0; if (!gcParseReconfigurableCommandLine(vm, vm->checkpointState.restoreArgsList)) { diff --git a/runtime/gc_modron_startup/mmparse.cpp b/runtime/gc_modron_startup/mmparse.cpp index 26d84b47f3b..8a09b79ac48 100644 --- a/runtime/gc_modron_startup/mmparse.cpp +++ b/runtime/gc_modron_startup/mmparse.cpp @@ -981,26 +981,6 @@ gcParseSovereignArguments(J9JavaVM *vm) extensions->heapContractionGCRatioThreshold._wasSpecified = true; } - /* Handling VMOPT_XGCMAXTHREADS is equivalent to VMOPT_XGCTHREADS (above), except it sets gcThreadCountForced to false rather than true. */ - if (-1 != FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, VMOPT_XGCMAXTHREADS, NULL)) { - result = option_set_to_opt_integer(vm, VMOPT_XGCMAXTHREADS, &index, EXACT_MEMORY_MATCH, &extensions->gcThreadCount); - if (OPTION_OK != result) { - if (OPTION_MALFORMED == result) { - j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_MUST_BE_NUMBER, VMOPT_XGCMAXTHREADS); - } else { - j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_OVERFLOWED, VMOPT_XGCMAXTHREADS); - } - goto _error; - } - - if (0 == extensions->gcThreadCount) { - j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_MUST_BE_ABOVE, VMOPT_XGCMAXTHREADS, (UDATA)0); - goto _error; - } - - extensions->gcThreadCountForced = false; - } - if(-1 != FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, "-Xgcworkpackets", NULL)) { result = option_set_to_opt_integer(vm, "-Xgcworkpackets", &index, EXACT_MEMORY_MATCH, &extensions->workpacketCount); if (OPTION_OK != result) { @@ -1275,11 +1255,13 @@ gcParseReconfigurableSoverignArguments(J9JavaVM* vm, J9VMInitArgs* args) MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(vm); IDATA index = -1; IDATA result = 0; + IDATA gcthread_index = -1; PORT_ACCESS_FROM_JAVAVM(vm); if (-1 != FIND_ARG_IN_ARGS(args, EXACT_MEMORY_MATCH, VMOPT_XGCTHREADS, NULL)) { result = option_set_to_opt_integer_args(vm, VMOPT_XGCTHREADS, &index, EXACT_MEMORY_MATCH, &extensions->gcThreadCount, args); + gcthread_index = index; if (OPTION_OK != result) { if (OPTION_MALFORMED == result) { j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_MUST_BE_NUMBER, VMOPT_XGCTHREADS); @@ -1294,9 +1276,37 @@ gcParseReconfigurableSoverignArguments(J9JavaVM* vm, J9VMInitArgs* args) goto _error; } + extensions->gcThreadCountSpecified = true; extensions->gcThreadCountForced = true; } + /* Handling VMOPT_XGCMAXTHREADS is equivalent to VMOPT_XGCTHREADS (above), except it sets gcThreadCountForced to false rather than true. */ + if (-1 != FIND_ARG_IN_ARGS(args, EXACT_MEMORY_MATCH, VMOPT_XGCMAXTHREADS, NULL)) { + UDATA gcThreadCount = 0; + IDATA gcmaxthread_index = -1; + + result = option_set_to_opt_integer_args(vm, VMOPT_XGCMAXTHREADS, &gcmaxthread_index, EXACT_MEMORY_MATCH, &gcThreadCount, args); + if (OPTION_OK != result) { + if (OPTION_MALFORMED == result) { + j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_MUST_BE_NUMBER, VMOPT_XGCMAXTHREADS); + } else { + j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_OVERFLOWED, VMOPT_XGCMAXTHREADS); + } + goto _error; + } + + if (0 == gcThreadCount) { + j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_MUST_BE_ABOVE, VMOPT_XGCMAXTHREADS, (UDATA)0); + goto _error; + } + + if (gcmaxthread_index > gcthread_index) { + extensions->gcThreadCount = gcThreadCount; + extensions->gcThreadCountSpecified = true; + extensions->gcThreadCountForced = false; + } + } + return true; _error: diff --git a/runtime/gc_modron_startup/mmparseXgc.cpp b/runtime/gc_modron_startup/mmparseXgc.cpp index ada8e198e9c..f2c23c20765 100644 --- a/runtime/gc_modron_startup/mmparseXgc.cpp +++ b/runtime/gc_modron_startup/mmparseXgc.cpp @@ -153,6 +153,7 @@ j9gc_initialize_parse_gc_colon(J9JavaVM *javaVM, char **scan_start) goto _error; } + extensions->gcThreadCountSpecified = true; extensions->gcThreadCountForced = true; goto _exit; } @@ -233,6 +234,7 @@ j9gc_initialize_parse_gc_colon(J9JavaVM *javaVM, char **scan_start) goto _error; } + extensions->gcThreadCountSpecified = true; extensions->gcThreadCountForced = true; goto _exit; }