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
8254877: GCLogPrecious::_lock rank constrains what locks you are allowed to have when crashing #903
Conversation
…wed to have when crashing
👋 Welcome back stefank! A progress list of the required criteria for merging this PR into |
Webrevs
|
st->print_cr("%s", _lines->base()); | ||
} | ||
|
||
_lock->signal(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed off-line, perhaps we might want to print something even if the log isn't initialized and/or is empty. Something like:
st->print_cr("GC Precious Log:");
if (_lines == NULL) {
st->print_cr("<Not initialized>");
return;
}
if (!_lock->trywait()) {
st->print_cr("<Skipped>");
return;
}
if (_lines->size() == 0) {
st->print_cr("<Empty>");
} else {
st->print_cr("%s", _lines->base());
}
_lock->signal();
You decide. Looks good otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with suggestion. I also added extra newlines to make the output look pretty. That was needed because _lines->base() is always terminated with a newline.
@stefank 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:
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 6 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
|
||
stringStream* GCLogPrecious::_lines = NULL; | ||
stringStream* GCLogPrecious::_temp = NULL; | ||
Mutex* GCLogPrecious::_lock = NULL; | ||
Semaphore* GCLogPrecious::_lock = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe renaming _lock
to _semaphore
? Additionally, since it's a binary semaphore, new Semaphore(1)
, some comments explaining why Mutex
is not suitable could avoid some future confusions.
PS: not a review, just a comment in passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used as a lock, so I think the name _lock
is appropriate. Instead I introduced a new class: SemaphoreLock
, to make the code more readable (IMHO). Also added a comment. Hopefully, this addressed your comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you; it does look more readable. BTW, mutex has try_lock
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Then I'll remove that part of the new comment.
In the latest update I added two new helper classes: |
Forked off the SemaphoreLock part into #927 |
Updates look good! |
…wed to have when crashing
|
fa17f12
to
9888692
Compare
I've thrown away the Semaphore implementation and replaced it with Patricio's new try_lock_without_range_check function. I've also changed the lock rank to be as low as possible. We'll still get a lock rank reordering problem if we crash while holding this lock, because EventLog takes its lock and it is of the same rank. I intend to address that with JDK-8256382. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Quite entertaining that the "leaf" rank is so far away from being a leaf level rank nowadays.
/integrate |
@stefank Since your change was applied there have been 97 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 287b829. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is an alternative version of the fix proposed in 900:
#900
Erik's description:
As Erik mentioned in that PR, I'd like to retain the ability to easily dump the precious log when debugging. The proposed fix changes the Mutex to a Semaphore, and use trywait to safely access the buffer. In the unlikely event that another thread is holding the lock, the hs_err printer skips printing the log.
This also makes it possible to call precious logging from within the stack watermark processing code. I think there's a possibility that we might call the following error logging, when we fail to commit memory for a ZPage, when relocating, during stack watermark processing:
log_error_p(gc)("Failed to commit memory (%s)", err.to_string());
Progress
Testing
Failed test tasks
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/903/head:pull/903
$ git checkout pull/903