Skip to content

Commit

Permalink
Add JVMTI events for CRIU checkpoint and restore
Browse files Browse the repository at this point in the history
Also, do not suspend new JDWP threads created in single threaded mode. If JDWP
is enabled, then handling the JVMTI events for checkpoint/restore can create
new threads. Added new threadName parameter to allocateVMThread in order to
check if thread is used for JDWP debugging.
Also fix order of restore phase hooks.

Signed-off-by: Mike Zhang <mike.h.zhang@ibm.com>
  • Loading branch information
mikezhang1234567890 authored and JasonFengJ9 committed May 16, 2024
1 parent a56cbdf commit 2f9d1d2
Show file tree
Hide file tree
Showing 17 changed files with 3,351 additions and 9 deletions.
1,158 changes: 1,158 additions & 0 deletions runtime/criusupport/criusupport.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions runtime/include/ibmjvmti.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
#define COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_MOUNT "com.sun.hotspot.events.VirtualThreadMount"
#define COM_SUN_HOTSPOT_EVENTS_VIRTUAL_THREAD_UNMOUNT "com.sun.hotspot.events.VirtualThreadUnmount"

#define OPENJ9_EVENT_VM_CHECKPOINT "openj9.criu.events.VMCheckpoint"
#define OPENJ9_EVENT_VM_RESTORE "openj9.criu.events.VMRestore"

#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA5 1
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA6 2
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA7 3
Expand Down
9 changes: 9 additions & 0 deletions runtime/jvmti/j9jvmti.tdf
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ TraceEntry=Trc_JVMTI_jvmtiHookVirtualThreadMount_Entry Overhead=1 Level=5 Noenv
TraceExit=Trc_JVMTI_jvmtiHookVirtualThreadMount_Exit Overhead=1 Level=5 Noenv Template="HookVirtualThreadMount"

TraceEvent=Trc_JVMTI_loadAgentLibraryOnAttach_agentLoadingDisabled Overhead=1 Level=5 Noenv Template="loadAgentLibraryOnAttach: Dynamic agent loading is disabled"
<<<<<<< Upstream, based on master
TraceExit-Exception=Trc_JVMTI_loadAgentLibraryGeneric_execNameNotFound_Exit Overhead=1 Level=1 Noenv Template="loadAgentLibraryGeneric failed to obtain executable name with error code=%d while loading library %s"
TraceExit-Exception=Trc_JVMTI_loadAgentLibraryGeneric_failedOpeningAgentLibrary_Exit Overhead==1 Level=1 Noenv Template="loadAgentLibraryGeneric failed to open agent library %s with error message %s"
TraceExit-Exception=Trc_JVMTI_loadAgentLibraryGeneric_agentAttachFailed1_Exit Overhead==1 Level=1 Noenv Template="loadAgentLibraryGeneric failed attaching agent library %s; load function %s not found"
Expand All @@ -678,3 +679,11 @@ TraceEvent=Trc_JVMTI_isFileNameInLibPath_path_not_match Overhead=1 Level=5 Noenv
TraceEvent=Trc_JVMTI_isFileNameInLibPath_path_match Overhead=1 Level=3 Noenv Template="isFileNameInLibPath() fileName(%s) path matches (%s) with dirLen (%zu)"
TraceEvent=Trc_JVMTI_searchObjectFileFromLDInfo_library_object_file_found Overhead=1 Level=5 Noenv Template="searchObjectFileFromLDInfo() fileName(%s) is same as libName"
TraceEvent=Trc_JVMTI_searchObjectFileFromLDInfo_library_object_file_not_found Overhead=1 Level=5 Noenv Template="searchObjectFileFromLDInfo() fileName(%s) is not same as libName(%s)"
=======

TraceEntry=Trc_JVMTI_jvmtiHookVMCheckpoint_Entry Overhead=1 Level=2 Noenv Template="HookVMCheckpoint"
TraceExit=Trc_JVMTI_jvmtiHookVMCheckpoint_Exit Overhead=1 Level=2 Noenv Template="HookVMCheckpoint"

TraceEntry=Trc_JVMTI_jvmtiHookVMRestore_Entry Overhead=1 Level=2 Noenv Template="HookVMRestore"
TraceExit=Trc_JVMTI_jvmtiHookVMRestore_Exit Overhead=1 Level=2 Noenv Template="HookVMRestore"
>>>>>>> 337f1f0 Add JVMTI events for CRIU checkpoint and restore
26 changes: 26 additions & 0 deletions runtime/jvmti/jvmtiExtensionMechanism.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ static const jvmtiParamInfo jvmtiGetCarrierThread_params[] = {
};
#endif /* JAVA_SPEC_VERSION >= 19 */

#if defined(J9VM_OPT_CRIU_SUPPORT)
/* (jvmtiEnv *jvmti_env) */
static const jvmtiParamInfo jvmtiVMCheckpoint_params[] = {
{ "jni_env", JVMTI_KIND_IN_PTR, JVMTI_TYPE_JNIENV, JNI_FALSE },
{ "thread", JVMTI_KIND_IN, JVMTI_TYPE_JTHREAD, JNI_FALSE },
};
static const jvmtiParamInfo jvmtiVMRestore_params[] = {
{ "jni_env", JVMTI_KIND_IN_PTR, JVMTI_TYPE_JNIENV, JNI_FALSE },
{ "thread", JVMTI_KIND_IN, JVMTI_TYPE_JTHREAD, JNI_FALSE },
};
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */

/*
* Error lists for extended functions
*/
Expand Down Expand Up @@ -850,6 +862,20 @@ static const J9JVMTIExtensionEventInfo J9JVMTIExtensionEventInfoTable[] = {
SIZE_AND_TABLE(jvmtiVirtualThreadUnmount_params),
},
#endif /* JAVA_SPEC_VERSION >= 19 */
#if defined(J9VM_OPT_CRIU_SUPPORT)
{
J9JVMTI_EVENT_OPENJ9_VM_CHECKPOINT,
OPENJ9_EVENT_VM_CHECKPOINT,
J9NLS_J9JVMTI_EVENT_OPENJ9_VM_CHECKPOINT,
SIZE_AND_TABLE(jvmtiVMCheckpoint_params),
},
{
J9JVMTI_EVENT_OPENJ9_VM_RESTORE,
OPENJ9_EVENT_VM_RESTORE,
J9NLS_J9JVMTI_EVENT_OPENJ9_VM_RESTORE,
SIZE_AND_TABLE(jvmtiVMRestore_params),
},
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
};

#define NUM_EXTENSION_EVENTS (sizeof(J9JVMTIExtensionEventInfoTable) / sizeof(J9JVMTIExtensionEventInfoTable[0]))
Expand Down
Loading

0 comments on commit 2f9d1d2

Please sign in to comment.