diff --git a/doc/compiler/control/OptionsPostRestore.md b/doc/compiler/control/OptionsPostRestore.md index f736ed12562..49a309ff985 100644 --- a/doc/compiler/control/OptionsPostRestore.md +++ b/doc/compiler/control/OptionsPostRestore.md @@ -155,3 +155,16 @@ then specified post-restore, the options processing code will invalidate all JIT code in the code cache, as well as prevent further AOT compilation (since the AOT method header would have already been validated). + +### JITServer + +The following table outlines when a client JVM will connect to a +JITServer instance. + +||Non-Portable CRIU Pre-Checkpoint|Non-Portable CRIU Post-Restore|Portable CRIU Pre-Checkpoint|Portable CRIU Post-Restore| +|--|--|--|--|--| +|No Options Pre-Checkpoint; No Options Post-Restore|:x:|:x:|:x:|:x:| +|No Options Pre-checkpoint; `-XX:+UseJITServer` Post-Restore|:x:|:white_check_mark:|:x:|:white_check_mark:| +|`-XX:+UseJITServer` Pre-Checkpoint; No Options Post-Restore|:x:|:white_check_mark:|:white_check_mark:|:white_check_mark:| +|`-XX:+UseJITServer` Pre-Checkpoint; `-XX:-UseJITServer` Post-Restore|:x:|:x:|:white_check_mark:|:x:| +|`-XX:-UseJITServer` Pre-Checkpoint; `-XX:+UseJITServer` Post-Restore|:x:|:x:|:x:|:x:| diff --git a/runtime/compiler/control/CompilationRuntime.hpp b/runtime/compiler/control/CompilationRuntime.hpp index 54a5e0b7c4b..bb67f37acfa 100644 --- a/runtime/compiler/control/CompilationRuntime.hpp +++ b/runtime/compiler/control/CompilationRuntime.hpp @@ -733,8 +733,20 @@ class CompilationInfo bool resetStartAndElapsedTime() { return _resetStartAndElapsedTime; } void setResetStartAndElapsedTime(bool reset) { _resetStartAndElapsedTime = reset; } + +#if defined(J9VM_OPT_JITSERVER) + bool canPerformRemoteCompilationInCRIUMode() { return _canPerformRemoteCompilationInCRIUMode; } + void setCanPerformRemoteCompilationInCRIUMode(bool remoteComp) { _canPerformRemoteCompilationInCRIUMode = remoteComp; } + + bool remoteCompilationRequestedAtBootstrap() { return _remoteCompilationRequestedAtBootstrap; } + void setRemoteCompilationRequestedAtBootstrap(bool remoteComp) { _remoteCompilationRequestedAtBootstrap = remoteComp; } + + bool remoteCompilationExplicitlyDisabledAtBootstrap() { return _remoteCompilationExplicitlyDisabledAtBootstrap; } + void setRemoteCompilationExplicitlyDisabledAtBootstrap(bool remoteComp) { _remoteCompilationExplicitlyDisabledAtBootstrap = remoteComp; } #endif +#endif // #if defined(J9VM_OPT_CRIU_SUPPORT) + TR_PersistentMemory * persistentMemory() { return _persistentMemory; } TR::PersistentInfo * getPersistentInfo() { return persistentMemory()->getPersistentInfo(); } @@ -1380,7 +1392,12 @@ class CompilationInfo bool _vmMethodTraceEnabled; bool _vmExceptionEventsHooked; bool _resetStartAndElapsedTime; +#if defined(J9VM_OPT_JITSERVER) + bool _canPerformRemoteCompilationInCRIUMode; + bool _remoteCompilationRequestedAtBootstrap; + bool _remoteCompilationExplicitlyDisabledAtBootstrap; #endif +#endif // #if defined(J9VM_OPT_CRIU_SUPPORT) TR::Monitor *_vlogMonitor; TR::Monitor *_rtlogMonitor; diff --git a/runtime/compiler/control/CompilationThread.cpp b/runtime/compiler/control/CompilationThread.cpp index ef609eaa730..7d5ebebcd63 100644 --- a/runtime/compiler/control/CompilationThread.cpp +++ b/runtime/compiler/control/CompilationThread.cpp @@ -1184,6 +1184,7 @@ TR::CompilationInfo::CompilationInfo(J9JITConfig *jitConfig) : #if defined(J9VM_JIT_DYNAMIC_LOOP_TRANSFER) _dltMonitor = TR::Monitor::create("JIT-DLTmonitor"); #endif + #if defined(J9VM_OPT_CRIU_SUPPORT) _crMonitor = TR::Monitor::create("JIT-CheckpointRestoreMonitor"); _checkpointStatus = TR_CheckpointStatus::NO_CHECKPOINT_IN_PROGRESS; @@ -1205,7 +1206,15 @@ TR::CompilationInfo::CompilationInfo(J9JITConfig *jitConfig) : _vmExceptionEventsHooked = exceptionCatchEventHooked || exceptionThrowEventHooked; _resetStartAndElapsedTime = false; + +#if defined(J9VM_OPT_JITSERVER) + _canPerformRemoteCompilationInCRIUMode = false; + _remoteCompilationRequestedAtBootstrap = false; + _remoteCompilationExplicitlyDisabledAtBootstrap = false; #endif + +#endif // #if defined(J9VM_OPT_CRIU_SUPPORT) + _iprofilerBufferArrivalMonitor = TR::Monitor::create("JIT-IProfilerBufferArrivalMonitor"); _classUnloadMonitor = TR::MonitorTable::get()->getClassUnloadMonitor(); // by this time this variable is initialized // TODO: hang these monitors to something persistent @@ -7413,14 +7422,7 @@ TR::CompilationInfoPerThreadBase::cannotPerformRemoteComp( { return #if defined(J9VM_OPT_CRIU_SUPPORT) - // In non-portable restore (i.e. single checkpoint) mode prevent remote compilations until - // after the process is restored. In portable restore mode checkpoints are always possible - // so there's no point to delaying remote compilations. - (_jitConfig->javaVM->internalVMFunctions->isCheckpointAllowed(vmThread) && _jitConfig->javaVM->internalVMFunctions->isNonPortableRestoreMode(vmThread)) || - - // If -XX:-UseJITServer is specified post-restore, then the Remote Compilation Mode will - // be set to JITServer::NONE - _compInfo.getPersistentInfo()->getRemoteCompilationMode() == JITServer::NONE || + (_jitConfig->javaVM->internalVMFunctions->isCheckpointAllowed(vmThread) && !_compInfo.canPerformRemoteCompilationInCRIUMode()) || #endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ !JITServer::ClientStream::isServerCompatible(OMRPORT_FROM_J9PORT(_jitConfig->javaVM->portLibrary)) || (!JITServerHelpers::isServerAvailable() && !JITServerHelpers::shouldRetryConnection(OMRPORT_FROM_J9PORT(_jitConfig->javaVM->portLibrary))) || diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 93edd691df0..1d0d7d8d0d0 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -2300,26 +2300,35 @@ bool J9::Options::preProcessJitServer(J9JavaVM *vm, J9JITConfig *jitConfig) int32_t xxUseJITServerArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxUseJITServerOption, 0); int32_t xxDisableUseJITServerArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableUseJITServerOption, 0); - bool explicitClientMode = xxUseJITServerArgIndex > xxDisableUseJITServerArgIndex; + bool useJitServerExplicitlySpecified = xxUseJITServerArgIndex > xxDisableUseJITServerArgIndex; + #if defined(J9VM_OPT_CRIU_SUPPORT) + bool useJitServerExplicitlyDisabled = xxDisableUseJITServerArgIndex > xxUseJITServerArgIndex; + struct J9InternalVMFunctions *ifuncs = vm->internalVMFunctions; J9VMThread *currentThread = ifuncs->currentVMThread(vm); + // Enable JITServer client mode if // 1) CRIU support is enabled - // 2) non-portable restore mode is enabled - // 3) client mode is not explicitly disabled - // In portable restore mode let the user explicitly decide whether to enable JITServer. - bool implicitClientMode = ifuncs->isCRIUSupportEnabled(currentThread) && - ifuncs->isNonPortableRestoreMode(currentThread) && - (xxUseJITServerArgIndex >= xxDisableUseJITServerArgIndex); + // 2) client mode is not explicitly disabled + bool implicitClientMode = ifuncs->isCRIUSupportEnabled(currentThread) && !useJitServerExplicitlyDisabled; #endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ - if (explicitClientMode + if (useJitServerExplicitlySpecified #if defined(J9VM_OPT_CRIU_SUPPORT) || implicitClientMode #endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ ) { +#if defined(J9VM_OPT_CRIU_SUPPORT) + if (implicitClientMode && useJitServerExplicitlySpecified) + { + compInfo->setRemoteCompilationRequestedAtBootstrap(true); + if (!ifuncs->isNonPortableRestoreMode(currentThread)) + compInfo->setCanPerformRemoteCompilationInCRIUMode(true); + } +#endif + J9::PersistentInfo::_remoteCompilationMode = JITServer::CLIENT; compInfo->getPersistentInfo()->setSocketTimeout(DEFAULT_JITCLIENT_TIMEOUT); @@ -2355,7 +2364,14 @@ bool J9::Options::preProcessJitServer(J9JavaVM *vm, J9JITConfig *jitConfig) compInfo->getPersistentInfo()->setJITServerAOTCacheName(name); } } +#if defined(J9VM_OPT_CRIU_SUPPORT) + else if (useJitServerExplicitlyDisabled) + { + compInfo->setRemoteCompilationExplicitlyDisabledAtBootstrap(true); + } +#endif // #if defined(J9VM_OPT_CRIU_SUPPORT) } + if (!JITServerParseCommonOptions(vm->vmArgsArray, vm, compInfo)) { // Could not parse JITServer options successfully diff --git a/runtime/compiler/control/OptionsPostRestore.cpp b/runtime/compiler/control/OptionsPostRestore.cpp index 20e3312c77c..00156cf1b16 100644 --- a/runtime/compiler/control/OptionsPostRestore.cpp +++ b/runtime/compiler/control/OptionsPostRestore.cpp @@ -280,13 +280,17 @@ void J9::OptionsPostRestore::processJitServerOptions() { #if defined(J9VM_OPT_JITSERVER) - if (_argIndexUseJITServer >= _argIndexDisableUseJITServer) + bool jitserverEnabled + = ((_argIndexUseJITServer > _argIndexDisableUseJITServer) + && !_compInfo->remoteCompilationExplicitlyDisabledAtBootstrap()) + || ((_argIndexUseJITServer == _argIndexDisableUseJITServer) + && _compInfo->remoteCompilationRequestedAtBootstrap()); + + if (jitserverEnabled) { // Needed for GET_OPTION_VALUE_RESTORE_ARGS J9JavaVM *vm = _jitConfig->javaVM; - // TODO: Determine what other JITServer init is required - // Parse common options if (!TR::Options::JITServerParseCommonOptions(vm->checkpointState.restoreArgsList, vm, _compInfo)) { @@ -314,11 +318,14 @@ J9::OptionsPostRestore::processJitServerOptions() } // Re-compute client UID post restore uint64_t clientUID = JITServerHelpers::generateUID(); - _compInfo->getPersistentInfo()->setClientUID(clientUID); _jitConfig->clientUID = clientUID; + _compInfo->getPersistentInfo()->setClientUID(clientUID); + _compInfo->getPersistentInfo()->setServerUID(0); + _compInfo->setCanPerformRemoteCompilationInCRIUMode(true); } else { + _compInfo->setCanPerformRemoteCompilationInCRIUMode(false); _compInfo->getPersistentInfo()->setClientUID(0); _compInfo->getPersistentInfo()->setServerUID(0); _jitConfig->clientUID = 0; diff --git a/test/functional/cmdLineTests/criu/build.xml b/test/functional/cmdLineTests/criu/build.xml index 917dd677c1b..2727dcdc99a 100644 --- a/test/functional/cmdLineTests/criu/build.xml +++ b/test/functional/cmdLineTests/criu/build.xml @@ -75,6 +75,7 @@ + diff --git a/test/functional/cmdLineTests/criu/criuJitServerScript.sh b/test/functional/cmdLineTests/criu/criuJitServerScript.sh new file mode 100644 index 00000000000..f53374d0278 --- /dev/null +++ b/test/functional/cmdLineTests/criu/criuJitServerScript.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# +# Copyright IBM Corp. and others 2023 +# +# This program and the accompanying materials are made available under +# the terms of the Eclipse Public License 2.0 which accompanies this +# distribution and is available at https://www.eclipse.org/legal/epl-2.0/ +# or the Apache License, Version 2.0 which accompanies this distribution and +# is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# This Source Code may also be made available under the following +# Secondary Licenses when the conditions for such availability set +# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU +# General Public License, version 2 with the GNU Classpath +# Exception [1] and GNU General Public License, version 2 with the +# OpenJDK Assembly Exception [2]. +# +# [1] https://www.gnu.org/software/classpath/license.html +# [2] https://openjdk.org/legal/assembly-exception.html +# +# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception +# + +echo "start running script"; +# the expected arguments are: +# $1 is the TEST_ROOT +# $2 is the TEST_JDK_BIN +# $3 is the JVM_OPTIONS +# $4 is the MAINCLASS +# $5 is the APP ARGS +# $6 is the NUM_CHECKPOINT +# $7 is the KEEP_CHECKPOINT + +source $1/jitserverconfig.sh + +echo "export GLIBC_TUNABLES=glibc.cpu.hwcaps=-XSAVEC,-XSAVE,-AVX2,-ERMS,-AVX,-AVX_Fast_Unaligned_Load"; +export GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.cpu.hwcaps=-XSAVEC,-XSAVE,-AVX2,-ERMS,-AVX,-AVX_Fast_Unaligned_Load +echo "export LD_BIND_NOT=on"; +export LD_BIND_NOT=on + +JITSERVER_PORT=$(random_port) +JITSERVER_OPTIONS="-XX:JITServerPort=$JITSERVER_PORT" + +echo "Starting $2/jitserver $JITSERVER_OPTIONS" +$2/jitserver $JITSERVER_OPTIONS & +sleep 2 + +$2/java -XX:+EnableCRIUSupport -XX:JITServerPort=$JITSERVER_PORT $3 -cp "$1/criu.jar" $4 $5 -XX:JITServerPort=$JITSERVER_PORT $6 >testOutput 2>&1; + +if [ "$7" != true ]; then + NUM_CHECKPOINT=$6 + for ((i=0; i<$NUM_CHECKPOINT; i++)); do + sleep 2; + criu restore -D ./cpData --shell-job; + done +fi + +cat testOutput; + +if [ "$7" != true ]; then + rm -rf testOutput + echo "Removed testOutput file" +fi + +echo "Terminating $2/jitserver $JITSERVER_OPTIONS" +pkill -9 -xf "$2/jitserver $JITSERVER_OPTIONS" +sleep 2 + +echo "finished script"; diff --git a/test/functional/cmdLineTests/criu/criu_jitserverAcrossCheckpoint.xml b/test/functional/cmdLineTests/criu/criu_jitserverAcrossCheckpoint.xml new file mode 100644 index 00000000000..6c61f998a30 --- /dev/null +++ b/test/functional/cmdLineTests/criu/criu_jitserverAcrossCheckpoint.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$ $PRE_CRIU_VERBOSE$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $ENABLE_JITSERVER$ $POST_CRIU_VERBOSE$" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + cat preCheckpointVlog + JITServer: JITServer Client Mode. + Connected to a server + + + + cat postRestoreVlog + CHECKPOINT RESTORE: Ready for restore + Connected to a server + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $POST_CRIU_VERBOSE$" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + cat postRestoreVlog + CHECKPOINT RESTORE: Ready for restore + Connected to a server + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$ $PORTABLE_CRIU_MODE$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $POST_CRIU_VERBOSE$" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + cat postRestoreVlog + CHECKPOINT RESTORE: Ready for restore + Connected to a server + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$ $ENABLE_JITSERVER$ $PRE_CRIU_VERBOSE$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $POST_CRIU_VERBOSE$" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + cat preCheckpointVlog + JITServer: JITServer Client Mode. + Connected to a server + + + + cat postRestoreVlog + CHECKPOINT RESTORE: Ready for restore + Connected to a server + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$ $ENABLE_JITSERVER$ $PORTABLE_CRIU_MODE$ $PRE_CRIU_VERBOSE$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $POST_CRIU_VERBOSE$" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + cat preCheckpointVlog + JITServer: JITServer Client Mode. + Connected to a server + + + + cat postRestoreVlog + CHECKPOINT RESTORE: Ready for restore + Connected to a server + + diff --git a/test/functional/cmdLineTests/criu/criu_jitserverPostRestore.xml b/test/functional/cmdLineTests/criu/criu_jitserverPostRestore.xml new file mode 100644 index 00000000000..2eca21b3b42 --- /dev/null +++ b/test/functional/cmdLineTests/criu/criu_jitserverPostRestore.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $ENABLE_JITSERVER$ $CRIU_VERBOSE$" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + cat vlog + CHECKPOINT RESTORE: Ready for restore + Connected to a server + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $ENABLE_JITSERVER$ -Xnojit -Xnoaot" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + Some or all compiled code in the code cache invalidated post restore. + JIT compilation disabled post restore. + AOT load and compilation disabled post restore. + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $ENABLE_JITSERVER$ -Xnoaot" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + Some or all compiled code in the code cache invalidated post restore. + JIT compilation disabled post restore. + AOT load and compilation disabled post restore. + + Thread pid mismatch + do not match expected + Unable to create a thread: + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$JVM_OPTIONS$" $MAINCLASS_OPTIONSFILE_TEST$ "JitOptionsTest $ENABLE_JITSERVER$ -Xjit:exclude={*}" 1 false + Killed + Pre-checkpoint + Post-checkpoint + CRIU is not enabled + Operation not permitted + Some or all compiled code in the code cache invalidated post restore. + JIT compilation disabled post restore. + AOT load and compilation disabled post restore. + + Thread pid mismatch + do not match expected + Unable to create a thread: + + diff --git a/test/functional/cmdLineTests/criu/playlist.xml b/test/functional/cmdLineTests/criu/playlist.xml index d031de3f631..77dc8725033 100644 --- a/test/functional/cmdLineTests/criu/playlist.xml +++ b/test/functional/cmdLineTests/criu/playlist.xml @@ -148,6 +148,76 @@ openj9 + + cmdLineTester_criu_jitserverAcrossCheckpoint + + NoOptions + + + if [ -x $(Q)$(TEST_JDK_BIN)$(D)jitserver$(Q) ]; \ + then \ + TR_Options=$(Q)disableSuffixLogs$(Q) \ + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ + -DSCRIPPATH=$(TEST_RESROOT)$(D)criuJitServerScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ + -DTEST_JDK_BIN=$(TEST_JDK_BIN) -DJVM_OPTIONS=$(Q)$(JVM_OPTIONS)$(Q) \ + -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)criu_jitserverAcrossCheckpoint.xml$(Q) \ + -explainExcludes -xids all,$(PLATFORM),$(VARIATION) -nonZeroExitWhenError; \ + else \ + echo; \ + echo $(Q)$(TEST_JDK_BIN)$(D)jitserver doesn't exist; assuming this JDK does not support JITServer and trivially passing the test.$(Q); \ + fi; \ + $(TEST_STATUS) + + os.linux,^arch.arm,^arch.aarch64,bits.64 + + CRIU:required + + + sanity + + + functional + + + openj9 + + + + cmdLineTester_criu_jitserverPostRestore + + -Xjit + -Xjit:count=0 + -Xjit:vlog=vlog + + + if [ -x $(Q)$(TEST_JDK_BIN)$(D)jitserver$(Q) ]; \ + then \ + TR_Options=$(Q)disableSuffixLogs$(Q) \ + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ + -DSCRIPPATH=$(TEST_RESROOT)$(D)criuJitServerScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ + -DTEST_JDK_BIN=$(TEST_JDK_BIN) -DJVM_OPTIONS=$(Q)$(JVM_OPTIONS)$(Q) \ + -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)criu_jitserverPostRestore.xml$(Q) \ + -explainExcludes -xids all,$(PLATFORM),$(VARIATION) -nonZeroExitWhenError; \ + else \ + echo; \ + echo $(Q)$(TEST_JDK_BIN)$(D)jitserver doesn't exist; assuming this JDK does not support JITServer and trivially passing the test.$(Q); \ + fi; \ + $(TEST_STATUS) + + os.linux,^arch.arm,^arch.aarch64,bits.64 + + CRIU:required + + + sanity + + + functional + + + openj9 + + cmdLineTester_criu_nonPortableRestore_Xtrace_tracepoint diff --git a/test/functional/cmdLineTests/jitserver/build.xml b/test/functional/cmdLineTests/jitserver/build.xml new file mode 100644 index 00000000000..d5fd628b45e --- /dev/null +++ b/test/functional/cmdLineTests/jitserver/build.xml @@ -0,0 +1,48 @@ + + + + + + + + Build cmdLineTest_jitserver + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/cmdLineTests/jitserver/jitserverArgumentTesting.xml b/test/functional/cmdLineTests/jitserver/jitserverArgumentTesting.xml new file mode 100644 index 00000000000..0fd04a31834 --- /dev/null +++ b/test/functional/cmdLineTests/jitserver/jitserverArgumentTesting.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$DEFAULT_JITSERVER_OPTIONS$" "$ENABLE_JITSERVER$ $JITSERVER_VERBOSE$" false + (java|openjdk|semeru) version + Connected to a server + (Fatal|Unhandled) Exception + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$DEFAULT_JITSERVER_OPTIONS$" "$DISABLE_JITSERVER$ $JITSERVER_VERBOSE$" false + (java|openjdk|semeru) version + Connected to a server + (Fatal|Unhandled) Exception + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$DEFAULT_JITSERVER_OPTIONS$" "$ENABLE_JITSERVER$ $JITSERVER_VERBOSE$ -XX:JITServerPort=38399" false + (java|openjdk|semeru) version + Connected to a server + (Fatal|Unhandled) Exception + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$DEFAULT_JITSERVER_OPTIONS$" "$ENABLE_JITSERVER$ $JITSERVER_VERBOSE$ -XX:JITServerAddress=bad.address" false + (java|openjdk|semeru) version + Connected to a server + (Fatal|Unhandled) Exception + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$DEFAULT_JITSERVER_OPTIONS$" "$ENABLE_JITSERVER$ $JITSERVER_VERBOSE$" true + (java|openjdk|semeru) version + jitserver_cpu_utilization + jitserver_available_memory + jitserver_connected_clients + jitserver_active_threads + Connection refused + (Fatal|Unhandled) Exception + + + + bash $SCRIPPATH$ $TEST_RESROOT$ $TEST_JDK_BIN$ "$DEFAULT_JITSERVER_OPTIONS$ -XX:-JITServerMetrics" "$ENABLE_JITSERVER$ $JITSERVER_VERBOSE$" true + (java|openjdk|semeru) version + jitserver_cpu_utilization + jitserver_available_memory + jitserver_connected_clients + jitserver_active_threads + Connection refused + (Fatal|Unhandled) Exception + + + diff --git a/test/functional/cmdLineTests/jitserver/jitserverScript.sh b/test/functional/cmdLineTests/jitserver/jitserverScript.sh new file mode 100644 index 00000000000..9df3be6213c --- /dev/null +++ b/test/functional/cmdLineTests/jitserver/jitserverScript.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# +# Copyright IBM Corp. and others 2023 +# +# This program and the accompanying materials are made available under +# the terms of the Eclipse Public License 2.0 which accompanies this +# distribution and is available at https://www.eclipse.org/legal/epl-2.0/ +# or the Apache License, Version 2.0 which accompanies this distribution and +# is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# This Source Code may also be made available under the following +# Secondary Licenses when the conditions for such availability set +# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU +# General Public License, version 2 with the GNU Classpath +# Exception [1] and GNU General Public License, version 2 with the +# OpenJDK Assembly Exception [2]. +# +# [1] https://www.gnu.org/software/classpath/license.html +# [2] https://openjdk.org/legal/assembly-exception.html +# +# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception +# + +echo "start running script"; +# the expected arguments are: +# $1 is the TEST_ROOT +# $2 is the TEST_JDK_BIN +# $3 is the JITServer Options +# $4 is the JVM Options +# %5 is the Metrics + +TEST_ROOT=$1 +TEST_JDK_BIN=$2 +JITSERVER_OPTS="$3" +JVM_OPTS="$4" +METRICS=$5 + +source $TEST_ROOT/jitserverconfig.sh + +JITSERVER_PORT=$(random_port) + +if [ "$METRICS" == true ]; then + METRICS_PORT=$(random_port) + METRICS_OPTS="-XX:+JITServerMetrics -XX:JITServerMetricsPort=$METRICS_PORT" +fi + +JITSERVER_OPTIONS="-XX:JITServerPort=$JITSERVER_PORT $METRICS_OPTS $JITSERVER_OPTS" + +echo "Starting $TEST_JDK_BIN/jitserver $JITSERVER_OPTIONS" +$TEST_JDK_BIN/jitserver $JITSERVER_OPTIONS & +JITSERVER_PID=$! +sleep 2 + +$TEST_JDK_BIN/java -XX:JITServerPort=$JITSERVER_PORT $JVM_OPTS -version; + +if [ "$METRICS" == true ]; then + curl http://localhost:$METRICS_PORT/metrics +fi + +echo "Terminating $TEST_JDK_BIN/jitserver $JITSERVER_OPTIONS" +kill -9 $JITSERVER_PID +# Running pkill seems to cause a hang... +#pkill -9 -xf "$TEST_JDK_BIN/jitserver $JITSERVER_OPTIONS" +sleep 2 + +echo "finished script"; diff --git a/test/functional/cmdLineTests/jitserver/jitserverconfig.sh b/test/functional/cmdLineTests/jitserver/jitserverconfig.sh new file mode 100644 index 00000000000..2e9f1600d2e --- /dev/null +++ b/test/functional/cmdLineTests/jitserver/jitserverconfig.sh @@ -0,0 +1,41 @@ +# Copyright IBM Corp. and others 2023 +# +# This program and the accompanying materials are made available under +# the terms of the Eclipse Public License 2.0 which accompanies this +# distribution and is available at https://www.eclipse.org/legal/epl-2.0/ +# or the Apache License, Version 2.0 which accompanies this distribution and +# is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# This Source Code may also be made available under the following +# Secondary Licenses when the conditions for such availability set +# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU +# General Public License, version 2 with the GNU Classpath +# Exception [1] and GNU General Public License, version 2 with the +# OpenJDK Assembly Exception [2]. +# +# [1] https://www.gnu.org/software/classpath/license.html +# [2] https://openjdk.org/legal/assembly-exception.html +# +# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception +# + +START_PORT=38400 +END_PORT=60000 + +DIFF=$(($END_PORT-$START_PORT+1)) +RANDOM=$$ + +random_port () { + RANDOM_PORT=$(($(($RANDOM%$DIFF))+$START_PORT)) + out=$(lsof -i -P -n | grep LISTEN | grep $RANDOM_PORT) + retVal=$? + + while [ $retVal -eq 0 ] + do + RANDOM_PORT=$(($(($RANDOM%$DIFF))+$START_PORT)) + out=$(lsof -i -P -n | grep LISTEN | grep $RANDOM_PORT) + retVal=$? + done + + echo "$RANDOM_PORT" +} diff --git a/test/functional/cmdLineTests/jitserver/playlist.xml b/test/functional/cmdLineTests/jitserver/playlist.xml new file mode 100644 index 00000000000..e5eb0c088bd --- /dev/null +++ b/test/functional/cmdLineTests/jitserver/playlist.xml @@ -0,0 +1,56 @@ + + + + ../variables.mk + + testJitserverArguments + + NoOptions + + + if [ -x $(Q)$(TEST_JDK_BIN)$(D)jitserver$(Q) ]; \ + then \ + TR_Options=$(Q)disableSuffixLogs$(Q) \ + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ + -DSCRIPPATH=$(TEST_RESROOT)$(D)jitserverScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ + -DTEST_JDK_BIN=$(TEST_JDK_BIN) \ + -jar $(CMDLINETESTER_JAR) -config $(Q)$(TEST_RESROOT)$(D)jitserverArgumentTesting.xml$(Q) \ + -explainExcludes -xids all,$(PLATFORM),$(VARIATION) -nonZeroExitWhenError; \ + else \ + echo; \ + echo $(Q)$(TEST_JDK_BIN)$(D)jitserver doesn't exist; assuming this JDK does not support JITServer and trivially passing the test.$(Q); \ + fi; \ + $(TEST_STATUS) + + os.linux,^arch.arm,^arch.aarch64,bits.64 + + sanity + + + functional + + + openj9 + + +