Skip to content
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

8277213: CompileTask_lock is acquired out of order with MethodCompileQueue_lock #6449

Closed
wants to merge 1 commit into from

Conversation

TobiHartmann
Copy link
Member

@TobiHartmann TobiHartmann commented Nov 18, 2021

In the rare case that the compiler threads fail during initialization or the code cache is full and flushing is disabled, we completely disable JIT compilation and shutdown the compiler runtime:

if (comp->should_perform_shutdown()) {
// There are two reasons for shutting down the compiler
// 1) compiler runtime initialization failed
// 2) The code cache is full and the following flag is set: -XX:-UseCodeCacheFlushing
warning("%s initialization failed. Shutting down all compilers", comp->name());

In the process, we free all compiler queues and notify potentially waiting compiler threads via the CompileTask::lock():

void CompileQueue::free_all() {
MutexLocker mu(MethodCompileQueue_lock);
CompileTask* next = _first;
// Iterate over all tasks in the compile queue
while (next != NULL) {
CompileTask* current = next;
next = current->next();
{
// Wake up thread that blocks on the compile task.
MutexLocker ct_lock(current->lock());
current->lock()->notify();

The problem is that since JDK-8273917 (see commit), the rank of CompileTask_lock is Mutex::safepoint which is equal to the rank of MethodCompileQueue_lock which we are already holding because we modify the compile queue.

I propose to fix this by modifying the rank of the CompileTask_lock similar to what is done for other locks:

// Holds Compile_lock
_extra_data_lock(Mutex::safepoint-2, "MDOExtraData_lock"),

The test that triggered this will be added with PR 6364. I verified that it now passes.

Thanks,
Tobias


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8277213: CompileTask_lock is acquired out of order with MethodCompileQueue_lock

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6449/head:pull/6449
$ git checkout pull/6449

Update a local copy of the PR:
$ git checkout pull/6449
$ git pull https://git.openjdk.java.net/jdk pull/6449/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6449

View PR using the GUI difftool:
$ git pr show -t 6449

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6449.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Nov 18, 2021

👋 Welcome back thartmann! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Nov 18, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Nov 18, 2021

@TobiHartmann The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler label Nov 18, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Nov 18, 2021

Webrevs

Copy link

@rickard rickard left a comment

Looks good.

@openjdk
Copy link

@openjdk openjdk bot commented Nov 18, 2021

@TobiHartmann This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8277213: CompileTask_lock is acquired out of order with MethodCompileQueue_lock

Reviewed-by: rbackman, coleenp

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 8 new commits pushed to the master branch:

  • a44b45f: 4337793: Mark non-serializable fields of java.security.cert.Certificate and CertPath
  • b3a62b4: 8276795: Deprecate seldom used CDS flags
  • 38345bd: 8277137: Set OnSpinWaitInst/OnSpinWaitInstCount defaults to "isb"/1 for Arm Neoverse N1
  • 2c06bca: 8266368: Inaccurate after_unwind hook in C2 exception handler
  • 77cc508: 8277215: Remove redundancy in ReferenceProcessor constructor args
  • 0a65e8b: 8276794: Change nested classes in java.desktop to static nested classes
  • db55f92: 8277343: dynamicArchive/SharedArchiveFileOption.java failed: '-XX:+RecordDynamicDumpInfo is unsupported when a dynamic CDS archive is specified in -XX:SharedArchiveFile:' missing
  • 2f4b540: 8276314: [JVMCI] check alignment of call displacement during code installation

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Nov 18, 2021
@TobiHartmann
Copy link
Member Author

@TobiHartmann TobiHartmann commented Nov 18, 2021

Thanks for the review, Rickard!

Copy link
Contributor

@coleenp coleenp left a comment

Looks good!

@TobiHartmann
Copy link
Member Author

@TobiHartmann TobiHartmann commented Nov 18, 2021

Thanks for the review, Coleen!

@TobiHartmann
Copy link
Member Author

@TobiHartmann TobiHartmann commented Nov 19, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Nov 19, 2021

Going to push as commit f34f119.
Since your change was applied there have been 22 commits pushed to the master branch:

  • 47564ca: 8275643: C2's unaryOp vector intrinsic does not properly handle LongVector.neg
  • 2f0bde1: 8277102: Dubious PrintCompilation output
  • 839033b: 8276976: Rename LIR_OprDesc to LIR_Opr
  • 89b125f: 8275527: Refactor forward pointer access
  • 36bd4a3: 8277404: Test VMDeprecatedOptions.java failing with Unable to create shared archive file
  • 57eb864: 8276927: [PPC64] Port shenandoahgc to linux on ppc64le
  • 8db0c36: 8277414: ProblemList runtime/CommandLine/VMDeprecatedOptions.java on windows-x64
  • 03473b4: 8270874: JFrame paint artifacts when dragged from standard monitor to HiDPI monitor
  • ce0f00f: 8276093: Improve naming in closures to iterate over card sets
  • 5d249c4: 8275071: [macos] A11y cursor gets stuck when combobox is closed
  • ... and 12 more: https://git.openjdk.java.net/jdk/compare/91607436b79126ccb999deaf38a98209dbfe6ec1...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 19, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Nov 19, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Nov 19, 2021

@TobiHartmann Pushed as commit f34f119.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler integrated
3 participants