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
8253694: Remove Thread::muxAcquire() from ThreadCrashProtection() #376
Conversation
|
@pchilano The following label will be automatically applied to this pull request: 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 add hotspot-jfr |
@pchilano |
Webrevs
|
src/hotspot/share/runtime/thread.hpp
Outdated
} | ||
} | ||
#endif | ||
|
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.
Could this be pushed down into osThread ?
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.
Yes, it can but it's not that clean I think given the osthread indirections. Here's how it looks: pchilano@73a41ad
I think another alternative could be to remove the "#ifndef _WINDOWS" clause and define an empty check_crash_protection() method in os_windows.hpp
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.
Ok, yes, I saw the ifdef WINDOWS and thought it should be more os platform specific, but if you had an empty method in os_windows.hpp that would be better imo. It's not as nice in osthread. Thank you for considering it.
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.
Hi Patricio,
This seems fine, but I'm wondering what the motivation for this change was? Adding more per-thread state is arguably just adding to the clutter of per-thread state. I don't know if this approach was considered when @robehn fixed JDK-8183925.
Thanks,
David
I don't think so. I have not seen crash protection catching anything since pre-JDK 9. (we did a lot of fixes to the stack-walking code) |
Like David I would also like to know more about the motivation. Is the feature expected to be used by a larger number of threads? If so, there might be concerns about scalability that was not considered initially. I agree that we have seen less, and for a long time almost no, asserts related to thread sampling in our testing with fastdebug builds (only product builds run with the protection). At the same time, I am not sure how representative that is considering all the code that is out there. We should also keep in mind that we have upcoming features that will have slightly different stack layouts which will affect how stackwalking is achieved, so I would recommend keeping the established safety mechanism. |
I looked at the users of Thread::muxAcquire/muxRelease and this was one of the two places where it is used. If we are going to have a crash protection mechanism for general use then the fields should not be static. Now, if we know only the JfrThreadSampler uses it and we want to optimize away that pointer in the thread object then that makes sense, but then we should remove _crash_mux. |
Please see the update. Since there was concern about adding a new pointer in the Thread class I kept the fields as static and just removed _crash_mux. I also fixed the comment about the class being used by the JfrSampler instead of the Watcher thread. |
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. I only have minor suggested changes, but it's your call
on whether to make those changes.
src/hotspot/os/posix/os_posix.cpp
Outdated
assert(Thread::current()->is_JfrSampler_thread(), "should be JFRSampler"); | ||
_protected_thread = Thread::current(); |
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.
Perhaps this:
_protected_thread = Thread::current();
assert(_protected_thread->is_JfrSampler_thread(), "should be JFRSampler");
would be a little more clean.
assert(Thread::current()->is_JfrSampler_thread(), "should be JFRSampler"); | ||
_protected_thread = Thread::current(); |
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.
Perhaps this:
_protected_thread = Thread::current();
assert(_protected_thread->is_JfrSampler_thread(), "should be JFRSampler");
would be a little more clean.
@pchilano This change now passes all automated pre-integration checks. 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 116 new commits pushed to the
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.
|
Thanks Dan! Updated. |
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.
Thumbs up.
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.
LGTM!
src/hotspot/share/runtime/thread.hpp
Outdated
} | ||
} | ||
#endif | ||
|
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.
Ok, yes, I saw the ifdef WINDOWS and thought it should be more os platform specific, but if you had an empty method in os_windows.hpp that would be better imo. It's not as nice in osthread. Thank you for considering it.
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.
So let me see if I've got this straight. Prior to JDK-8183925 CrashProtection was exclusively for the WatcherThread. JDK-8183925 generalized that to allow any(?) thread to use it. Now as the only client is the JfrSampler thread we are making crash protection exclusively only available to it.
Exactly. |
Thanks @dcubed-ojdk, @coleenp and @dholmes-ora for the reviews. |
/integrate |
@pchilano Since your change was applied there have been 124 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 57493c1. |
Hi all,
Please review the following patch. Current ThreadCrashProtection() implementation uses static members which requires the use of Thread::muxAcquire() to allow only one user at a time. We can avoid this synchronization requirement if each thread has its own ThreadCrashProtection *data.
I tested it builds on Linux, macOS and Windows. Since the JfrThreadSampler is the only one using this I run all the tests from test/jdk/jdk/jfr/. I also run some tests with JFR enabled while forcing a crash in OSThreadSampler::protected_task() and tests passed with several "Thread method sampler crashed" UL output. Also run tiers1-3.
Thanks,
Patricio
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/376/head:pull/376
$ git checkout pull/376