-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8373118: Test java/lang/Thread/virtual/Starvation.java timed out #28797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DougLea
wants to merge
16
commits into
openjdk:master
Choose a base branch
from
DougLea:JDK-8373118
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
96b399a
For testing
DougLea 1fb8970
filter by index
DougLea 094d7d7
signalWork diagnostic
DougLea 496cef3
Address review comments
DougLea 357a3cb
Merge branch 'openjdk:master' into JDK-8373118
DougLea 685a3eb
Revert topLevelExec
DougLea e3f012f
Reorder signalWork filter
DougLea 76dd5dd
Adjust runworker for previous update
DougLea 61adb1d
Reduce fencing
DougLea 7cc2dd1
Relax orderings in push
DougLea debaf27
Another diagnostic
DougLea 9b2f082
Merge branch 'openjdk:master' into JDK-8373118
DougLea 45f8a9a
Avoid double-filtering
DougLea 3370c0b
Check diagnosis
DougLea 2d8cff2
Merge branch 'openjdk:master' into JDK-8373118
DougLea b0b37d3
Merge branch 'openjdk:master' into JDK-8373118
DougLea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1254,18 +1254,17 @@ final int queueSize() { | |
| * @throws RejectedExecutionException if array could not be resized | ||
| */ | ||
| final void push(ForkJoinTask<?> task, ForkJoinPool pool, boolean internal) { | ||
| int s = top, b = base, m, cap, room; ForkJoinTask<?>[] a, na; | ||
| int s = top, b = base, m, cap, room; ForkJoinTask<?>[] a; | ||
| if ((a = array) != null && (cap = a.length) > 0) { // else disabled | ||
| int k = (m = cap - 1) & s; | ||
| if ((room = m - (s - b)) >= 0) { | ||
| if ((room = (m = cap - 1) - (s - b)) >= 0) { | ||
| top = s + 1; | ||
| long pos = slotOffset(k); | ||
| long pos = slotOffset(m & s); | ||
| if (!internal) | ||
| U.putReference(a, pos, task); // inside lock | ||
| else | ||
| U.getAndSetReference(a, pos, task); // fully fenced | ||
| if (room == 0 && (na = growArray(a, cap, s)) != null) | ||
| k = ((a = na).length - 1) & s; // resize | ||
| if (room == 0) | ||
| growArray(a, cap, s); | ||
| } | ||
| if (!internal) | ||
| unlockPhase(); | ||
|
|
@@ -1274,7 +1273,7 @@ final void push(ForkJoinTask<?> task, ForkJoinPool pool, boolean internal) { | |
| if (pool != null && | ||
| (room == 0 || | ||
| U.getReferenceAcquire(a, slotOffset(m & (s - 1))) == null)) | ||
| pool.signalWork(a, k); // may have appeared empty | ||
| pool.signalWork(this, s); // may have appeared empty | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1283,9 +1282,8 @@ final void push(ForkJoinTask<?> task, ForkJoinPool pool, boolean internal) { | |
| * @param a old array | ||
| * @param cap old array capacity | ||
| * @param s current top | ||
| * @return new array, or null on failure | ||
| */ | ||
| private ForkJoinTask<?>[] growArray(ForkJoinTask<?>[] a, int cap, int s) { | ||
| private void growArray(ForkJoinTask<?>[] a, int cap, int s) { | ||
| int newCap = (cap >= 1 << 16) ? cap << 1 : cap << 2; | ||
| ForkJoinTask<?>[] newArray = null; | ||
| if (a != null && a.length == cap && cap > 0 && newCap > 0) { | ||
|
|
@@ -1305,7 +1303,6 @@ a, slotOffset(k & mask), null)) == null) | |
| updateArray(newArray); // fully fenced | ||
| } | ||
| } | ||
| return newArray; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1434,7 +1431,31 @@ else if (U.compareAndSetReference(a, k, t, null)) { | |
| final void topLevelExec(ForkJoinTask<?> task, int fifo) { | ||
| while (task != null) { | ||
| task.doExec(); | ||
| task = (fifo != 0) ? localPoll() : localPop(); | ||
| task = null; | ||
| int p = top, cap; ForkJoinTask<?>[] a; | ||
| if ((a = array) == null || (cap = a.length) <= 0) | ||
| break; // currently impossible | ||
| if (fifo == 0) { // specialized localPop | ||
| int s = p - 1; long k; | ||
| if (U.getReference( | ||
| a, k = slotOffset((cap - 1) & s)) != null && | ||
| (task = (ForkJoinTask<?>) | ||
| U.getAndSetReference(a, k, null)) != null) | ||
| top = s; | ||
| } else { // specialized localPoll | ||
| for (int b = base; p - b > 0; ) { | ||
| int nb = b + 1; | ||
| if ((task = (ForkJoinTask<?>)U.getAndSetReference( | ||
| a, slotOffset((cap - 1) & b), null)) != null) { | ||
| base = nb; | ||
| break; | ||
| } | ||
| if (nb == p) | ||
| break; | ||
| while (b == (b = U.getIntAcquire(this, BASE))) | ||
| Thread.onSpinWait(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1854,9 +1875,12 @@ final void deregisterWorker(ForkJoinWorkerThread wt, Throwable ex) { | |
|
|
||
| /** | ||
| * Releases an idle worker, or creates one if not enough exist, | ||
| * giving up if array a is nonnull and task at a[k] already taken. | ||
| * giving up q is nonull and signalled slot already taken. | ||
| * | ||
| * @param q, if nonnull, the WorkQueue containing signalled task | ||
| * @param qbase q's base index for the task | ||
| */ | ||
| final void signalWork(ForkJoinTask<?>[] a, int k) { | ||
| final void signalWork(WorkQueue q, int qbase) { | ||
| int pc = parallelism; | ||
| for (long c = ctl;;) { | ||
| WorkQueue[] qs = queues; | ||
|
|
@@ -1878,9 +1902,7 @@ else if ((v = w) == null) | |
| break; | ||
| else | ||
| nc = (v.stackPred & LMASK) | (c & TC_MASK) | ac; | ||
| if (a != null && k < a.length && k >= 0 && a[k] == null) | ||
| break; | ||
| if (c == (c = ctl) && c == (c = compareAndExchangeCtl(c, nc))) { | ||
| if (c == (c = compareAndExchangeCtl(c, nc))) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the risk here is that this introduces more cache-coordination contention, esp. on multisocket aarch64. |
||
| if (v == null) | ||
| createWorker(); | ||
| else { | ||
|
|
@@ -1890,6 +1912,8 @@ else if ((v = w) == null) | |
| } | ||
| break; | ||
| } | ||
| if (q != null && q.base - qbase > 0) | ||
| break; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1976,10 +2000,10 @@ final void runWorker(WorkQueue w) { | |
| if ((q = qs[qid = i & (n - 1)]) != null) { | ||
| ForkJoinTask<?>[] a; int cap; // poll queue | ||
| while ((a = q.array) != null && (cap = a.length) > 0) { | ||
| int b, nb, nk; long bp; ForkJoinTask<?> t; | ||
| int b, nb; long bp; ForkJoinTask<?> t; | ||
| t = (ForkJoinTask<?>)U.getReferenceAcquire( | ||
| a, bp = slotOffset((cap - 1) & (b = q.base))); | ||
| long np = slotOffset(nk = (nb = b + 1) & (cap - 1)); | ||
| long np = slotOffset((nb = b + 1) & (cap - 1)); | ||
| if (q.base == b) { // else inconsistent | ||
| if (t == null) { | ||
| if (q.array == a) { // else resized | ||
|
|
@@ -2001,13 +2025,11 @@ else if (inactive != 0) { | |
| } | ||
| else if (U.compareAndSetReference(a, bp, t, null)) { | ||
| q.base = nb; | ||
| Object nt = U.getReferenceAcquire(a, np); | ||
| w.source = qid; | ||
| rescans = 1; | ||
| ++taken; | ||
| if (nt != null && // confirm a[nk] | ||
| U.getReferenceAcquire(a, np) == nt) | ||
| signalWork(a, nk); // propagate | ||
| if (U.getReferenceAcquire(a, np) != null) | ||
| signalWork(q, nb); // propagate | ||
| w.topLevelExec(t, fifo); | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.