Skip to content

Commit

Permalink
Merge pull request #16607 from tajila/criu_2
Browse files Browse the repository at this point in the history
Handle GC thread shutdown during checkpoint
  • Loading branch information
gacholio committed Jan 28, 2023
2 parents de0e456 + 4742130 commit 6cadc1d
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 94 deletions.
3 changes: 3 additions & 0 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -5822,6 +5822,9 @@ typedef struct J9JavaVM {
omrthread_monitor_t tlsPoolMutex;
jobject vthreadGroup;
#endif /* JAVA_SPEC_VERSION >= 19 */
#if defined(J9VM_OPT_CRIU_SUPPORT)
omrthread_monitor_t delayedLockingOperationsMutex;
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
} J9JavaVM;

#define J9VM_PHASE_STARTUP 1
Expand Down
6 changes: 4 additions & 2 deletions runtime/vm/CRIUHelpers.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2022 IBM Corp. and others
* Copyright (c) 2019, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -63,7 +63,8 @@ class VM_CRIUHelpers {
J9JavaVM *vm = currentThread->javaVM;
J9InternalVMFunctions* vmFuncs = vm->internalVMFunctions;

Assert_VM_true(vm->checkpointState.checkpointThread == currentThread);
/* This is only contended when the GC is shutting down threads. */
omrthread_monitor_enter(vm->delayedLockingOperationsMutex);

jobject globalRef = vmFuncs->j9jni_createGlobalRef((JNIEnv*) currentThread, instance, JNI_FALSE);
if (NULL == globalRef) {
Expand All @@ -88,6 +89,7 @@ class VM_CRIUHelpers {

Trc_VM_criu_delayedLockingOperation_delayOperation(currentThread, operation, instance);
done:
omrthread_monitor_exit(vm->delayedLockingOperationsMutex);
return rc;

throwOOM:
Expand Down
5 changes: 5 additions & 0 deletions runtime/vm/jvminit.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,11 @@ freeJavaVM(J9JavaVM * vm)
}

j9sl_close_shared_library(vm->checkpointState.libCRIUHandle);

if (NULL != vm->delayedLockingOperationsMutex) {
omrthread_monitor_destroy(vm->delayedLockingOperationsMutex);
vm->delayedLockingOperationsMutex = NULL;
}
}
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */

Expand Down
5 changes: 4 additions & 1 deletion runtime/vm/vmthinit.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2022 IBM Corp. and others
* Copyright (c) 1991, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -96,6 +96,9 @@ UDATA initializeVMThreading(J9JavaVM *vm)
omrthread_monitor_init_with_name(&vm->tlsFinalizersMutex, 0, "TLS finalizers mutex") ||
omrthread_monitor_init_with_name(&vm->tlsPoolMutex, 0, "TLS pool mutex") ||
#endif /* JAVA_SPEC_VERSION >= 19 */
#if defined(J9VM_OPT_CRIU_SUPPORT)
omrthread_monitor_init_with_name(&vm->delayedLockingOperationsMutex, 0, "Delayed locking operations mutex") ||
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */

initializeMonitorTable(vm)
)
Expand Down

0 comments on commit 6cadc1d

Please sign in to comment.