From e5517c7d14cdfe6571aa8170fffd2fcaf15550bc Mon Sep 17 00:00:00 2001 From: dchuyko Date: Thu, 13 Mar 2025 17:28:48 +0500 Subject: [PATCH 1/2] RC_MASK and TC_MASK instead of UMASK --- .../share/classes/java/util/concurrent/ForkJoinPool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 73fa3eea1bd3a..2d699208460a8 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -2077,7 +2077,7 @@ private int tryTrim(WorkQueue w, int phase, long deadline) { else if (deadline - System.currentTimeMillis() >= TIMEOUT_SLOP) stat = 0; // spurious wakeup else if (!compareAndSetCtl( - c, nc = (w.stackPred & LMASK) | (UMASK & (c - TC_UNIT)))) + c, nc = (w.stackPred & LMASK) | (c & RC_MASK) | ((c - TC_UNIT) & TC_MASK))) stat = -1; // lost race to signaller else { stat = 1; From 973c84cdac9634a1415178e333e065a6cc6b9f5e Mon Sep 17 00:00:00 2001 From: dchuyko Date: Tue, 18 Mar 2025 14:03:44 +0500 Subject: [PATCH 2/2] Aligned with JDK-8319447 --- .../share/classes/java/util/concurrent/ForkJoinPool.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 2d699208460a8..61e9f0e3ffa9e 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -2077,7 +2077,8 @@ private int tryTrim(WorkQueue w, int phase, long deadline) { else if (deadline - System.currentTimeMillis() >= TIMEOUT_SLOP) stat = 0; // spurious wakeup else if (!compareAndSetCtl( - c, nc = (w.stackPred & LMASK) | (c & RC_MASK) | ((c - TC_UNIT) & TC_MASK))) + c, nc = ((w.stackPred & LMASK) | (RC_MASK & c) | + (TC_MASK & (c - TC_UNIT))))) stat = -1; // lost race to signaller else { stat = 1;