Skip to content

Commit 1d58314

Browse files
authored
Merge pull request #20394 from ThanHenderson/48-liberty-ppid
(0.48) Restrict getting the restore process start time to CRaC API
2 parents 935b098 + b5356e4 commit 1d58314

File tree

3 files changed

+14
-59
lines changed

3 files changed

+14
-59
lines changed

runtime/vm/CRIUHelpers.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,6 @@ criuCheckpointJVMImpl(JNIEnv *env,
15831583
I_32 syslogBufferSize = 0;
15841584
UDATA oldVMState = VM_VMHelpers::setVMState(currentThread, J9VMSTATE_CRIU_SUPPORT_CHECKPOINT_PHASE_START);
15851585
UDATA notSafeToCheckpoint = 0;
1586-
UDATA criuRestorePid = 0;
15871586
U_32 intGhostFileLimit = 0;
15881587
IDATA criuDumpReturnCode = 0;
15891588
bool restoreFailure = false;
@@ -1885,19 +1884,21 @@ criuCheckpointJVMImpl(JNIEnv *env,
18851884
}
18861885

18871886
if (hasDumpSucceeded) {
1888-
/* Calculate restore time excluding `criu restore ...` for MXBean API. */
1889-
criuRestorePid = j9sysinfo_get_ppid();
1890-
systemReturnCode = j9sysinfo_get_process_start_time(criuRestorePid, &restoreNanoUTCTime);
1891-
if (0 != systemReturnCode) {
1892-
currentExceptionClass = vm->checkpointState.criuSystemRestoreExceptionClass;
1893-
nlsMsgFormat = j9nls_lookup_message(
1894-
J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE,
1895-
J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE,
1896-
NULL);
1897-
restoreFailure = true;
1887+
/* Calculate restore time for CRaC MXBean API. */
1888+
if (J9_ARE_ALL_BITS_SET(vm->checkpointState.flags, J9VM_CRAC_IS_CHECKPOINT_ENABLED)) {
1889+
UDATA cracRestorePid = j9sysinfo_get_ppid();
1890+
systemReturnCode = j9sysinfo_get_process_start_time(cracRestorePid, &restoreNanoUTCTime);
1891+
if (0 != systemReturnCode) {
1892+
currentExceptionClass = vm->checkpointState.criuSystemRestoreExceptionClass;
1893+
nlsMsgFormat = j9nls_lookup_message(
1894+
J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE,
1895+
J9NLS_VM_CRIU_J9_GET_PROCESS_START_TIME_FAILURE,
1896+
NULL);
1897+
restoreFailure = true;
1898+
}
1899+
vm->checkpointState.processRestoreStartTimeInNanoseconds = (I_64)restoreNanoUTCTime;
1900+
Trc_VM_criu_process_restore_start_after_dump(currentThread, cracRestorePid, vm->checkpointState.processRestoreStartTimeInNanoseconds);
18981901
}
1899-
vm->checkpointState.processRestoreStartTimeInNanoseconds = (I_64)restoreNanoUTCTime;
1900-
Trc_VM_criu_process_restore_start_after_dump(currentThread, criuRestorePid, vm->checkpointState.processRestoreStartTimeInNanoseconds);
19011902

19021903
/* Load restore arguments from restore file or env vars. */
19031904
switch (loadRestoreArguments(currentThread, optionsFileChars, envFileChars)) {

test/functional/cmdLineTests/criu/criu_nonPortable.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,6 @@
209209
<output type="failure" caseSensitive="yes" regex="no">User requested Java dump using</output>
210210
</test>
211211

212-
<test id="Create CRIU checkpoint image and restore once - testGetProcessRestoreStartTime">
213-
<command>bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ $XTRACE_CRIU$ $STD_CMD_OPTS$" $MAINCLASS_TIMECHANGE$ testGetProcessRestoreStartTime 1 false false</command>
214-
<output type="success" caseSensitive="no" regex="no">Killed</output>
215-
<output type="success" caseSensitive="yes" regex="no">PASSED: InternalCRIUSupport.getProcessRestoreStartTime()</output>
216-
<output type="failure" caseSensitive="yes" regex="no">CRIU is not enabled</output>
217-
<output type="failure" caseSensitive="yes" regex="no">Operation not permitted</output>
218-
<output type="failure" caseSensitive="yes" regex="no">FAILED: InternalCRIUSupport.getProcessRestoreStartTime()</output>
219-
<!-- If CRIU can't acquire the original thread IDs, this test will fail. Nothing can be done about this failure. -->
220-
<output type="success" caseSensitive="yes" regex="no">Thread pid mismatch</output>
221-
<output type="success" caseSensitive="yes" regex="no">do not match expected</output>
222-
<output type="success" caseSensitive="yes" regex="no">Unable to create a thread:</output>
223-
<!-- In the past, the failure below was caused by an issue where CRIU can't be found on the PATH. -->
224-
<output type="failure" caseSensitive="yes" regex="no">Could not dump the JVM processes, err=-70</output>
225-
<output type="failure" caseSensitive="yes" regex="no">User requested Java dump using</output>
226-
</test>
227-
228212
<test id="Create CRIU checkpoint image and restore once - testMXBeanUpTime">
229213
<command>bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -Xtrace:print={j9jcl.533,j9vm.684-696,j9vm.699,j9vm.717-743} $STD_CMD_OPTS$" -Xdump:java+system+jit:events=throw+systhrow,filter=org/eclipse/openj9/criu/JVMCheckpointException $MAINCLASS_TIMECHANGE$ testMXBeanUpTime 1 false false</command>
230214
<output type="success" caseSensitive="no" regex="no">Killed</output>

test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ public static void main(String args[]) throws InterruptedException {
6161
case "testGetLastRestoreTime":
6262
tct.testGetLastRestoreTime();
6363
break;
64-
case "testGetProcessRestoreStartTime":
65-
tct.testGetProcessRestoreStartTime();
66-
break;
6764
case "testMXBeanUpTime":
6865
tct.testMXBeanUpTime();
6966
break;
@@ -267,33 +264,6 @@ private void testGetLastRestoreTime() {
267264
}
268265
}
269266

270-
private void testGetProcessRestoreStartTime() {
271-
long processRestoreStartTime = InternalCRIUSupport.getProcessRestoreStartTime();
272-
if (processRestoreStartTime != -1) {
273-
System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime
274-
+ " is not -1 before restore");
275-
}
276-
CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath);
277-
long beforeCheckpointTime = TimeUtilities.getCurrentTimeInNanoseconds();
278-
CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false);
279-
processRestoreStartTime = InternalCRIUSupport.getProcessRestoreStartTime();
280-
long lastRestoreTime = InternalCRIUSupport.getLastRestoreTime();
281-
long afterRestoreTime = TimeUtilities.getCurrentTimeInNanoseconds();
282-
if (beforeCheckpointTime >= processRestoreStartTime) {
283-
System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime
284-
+ " is less than beforeCheckpointTime - " + beforeCheckpointTime);
285-
} else if (processRestoreStartTime >= lastRestoreTime) {
286-
System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime
287-
+ " is more than InternalCRIUSupport.getLastRestoreTime() - " + lastRestoreTime);
288-
} else if (processRestoreStartTime >= afterRestoreTime) {
289-
System.out.println("FAILED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime
290-
+ " is more than afterRestoreTime - " + afterRestoreTime);
291-
} else {
292-
System.out.println("PASSED: InternalCRIUSupport.getProcessRestoreStartTime() - " + processRestoreStartTime
293-
+ " is between beforeCheckpointTime - " + beforeCheckpointTime + " and afterRestoreTime - " + afterRestoreTime);
294-
}
295-
}
296-
297267
private void testMXBeanUpTime() {
298268
CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath);
299269
RuntimeMXBean mxb = ManagementFactory.getRuntimeMXBean();

0 commit comments

Comments
 (0)