From 09c3a13d81bea253050c2f1fd26cde6ec545e24b Mon Sep 17 00:00:00 2001 From: Amarpreet Singh Date: Fri, 24 Nov 2023 10:13:59 -0500 Subject: [PATCH] Add NotCheckpointSafe annotations to PhantomCleanable Add NotCheckpointSafe annotations to PhantomCleanable to avoid blocking operations during restore in CRIU single thread mode, and fix the failures in the cmdLineTester_criu_nonPortableRestore tests and the cmdLineTester_criu_nonPortableRestore_Xtrace_outputFile tests that occur due to blocking operations during restore in CRIU single thread mode. Issues: https://github.com/eclipse-openj9/openj9/issues/18399, https://github.com/eclipse-openj9/openj9/issues/18514 Signed-off-by: Amarpreet Singh --- closed/GensrcJ9JCL.gmk | 1 + .../jdk/internal/ref/PhantomCleanable.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/closed/GensrcJ9JCL.gmk b/closed/GensrcJ9JCL.gmk index 4cfe82477da..a6ab121eaaa 100644 --- a/closed/GensrcJ9JCL.gmk +++ b/closed/GensrcJ9JCL.gmk @@ -47,6 +47,7 @@ $(eval $(call SetupCopyFiles,COPY_OVERLAY_FILES, \ src/java.base/share/classes/java/util/TimerTask.java \ src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java \ src/java.base/share/classes/jdk/internal/access/JavaNetInetAddressAccess.java \ + src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java \ src/java.base/share/classes/sun/security/jca/ProviderConfig.java \ src/java.base/share/classes/sun/security/jca/ProviderList.java \ src/java.base/unix/classes/java/lang/ProcessEnvironment.java \ diff --git a/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java b/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java index 24db6d8ef9a..fa7ac405288 100644 --- a/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java +++ b/src/java.base/share/classes/jdk/internal/ref/PhantomCleanable.java @@ -22,6 +22,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +/* + * =========================================================================== + * (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved + * =========================================================================== + */ package jdk.internal.ref; @@ -30,6 +35,10 @@ import java.lang.ref.PhantomReference; import java.util.Objects; +/*[IF CRIU_SUPPORT]*/ +import openj9.internal.criu.NotCheckpointSafe; +/*[ENDIF] CRIU_SUPPORT */ + /** * PhantomCleanable subclasses efficiently encapsulate cleanup state and * the cleaning action. @@ -83,6 +92,9 @@ public PhantomCleanable(T referent, Cleaner cleaner) { /** * Insert this PhantomCleanable after the list head. */ + /*[IF CRIU_SUPPORT]*/ + @NotCheckpointSafe + /*[ENDIF] CRIU_SUPPORT */ private void insert() { synchronized (list) { prev = list; @@ -98,6 +110,9 @@ private void insert() { * @return true if Cleanable was removed or false if not because * it had already been removed before */ + /*[IF CRIU_SUPPORT]*/ + @NotCheckpointSafe + /*[ENDIF] CRIU_SUPPORT */ private boolean remove() { synchronized (list) { if (next != this) { @@ -116,6 +131,9 @@ private boolean remove() { * * @return true if the list is empty */ + /*[IF CRIU_SUPPORT]*/ + @NotCheckpointSafe + /*[ENDIF] CRIU_SUPPORT */ boolean isListEmpty() { synchronized (list) { return list == list.next;