-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
JDK-8313251: Add NativeLibraryLoad event #15065
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
Webrevs
|
/label add hotspot-jfr |
@dholmes-ora |
Hi Johannes, thanks for the review ! May I get a second review please? |
I can review, but I like replies to my comments first. |
Hi Erik , maybe I miss something? What comment(s) are you referring to ? |
@@ -939,6 +939,13 @@ | |||
<Field type="ulong" contentType="address" name="topAddress" label="Top Address" description="Ending address of the module, if available" /> | |||
</Event> | |||
|
|||
<Event name="NativeLibraryLoad" category="Java Virtual Machine, Runtime" label="Native Library Load Operation" thread="false" stackTrace="true" startTime="true" |
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 think "Native Library Load" is sufficient as an event label and "Success" for the success field.
I think "error" is sufficient for the error field. We could use "errorMessage", if you believe there are other error related information we may want to add in the future.
The "name" label could changed to "Name", similar to the NativeLibrary event,
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 Erik, I will adjust. I will use errorMessage because on some platforms we have already coding to describe shared lib load error situations in more detail (see for example os_linux.cpp).
src/hotspot/os/linux/os_linux.cpp
Outdated
} else { | ||
Events::log_dll_message(nullptr, "Loaded shared library %s", filename); | ||
log_info(os)("shared library load of %s was successful", filename); | ||
#if INCLUDE_JFR | ||
event.set_success(true); | ||
event.set_errorDescription(""); |
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.
Use null if there is no error message
@@ -1008,11 +1023,22 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { | |||
return os::get_default_process_handle(); | |||
#else | |||
log_info(os)("attempting shared library load of %s", filename); | |||
|
|||
#if INCLUDE_JFR |
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.
We typically skip INCLUDE_JFR for events and rely on empty stubs in the code generation. This to make the code more easy to read.
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 Erik , I removed the JFR with configure and attempted this (however on Linux) but for some reason I got build errors. So I better added the macros. (not sure why this happened, with some other JFR event living without INCLUDE_JFR seemed to work as expected)
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
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.
Just for completeness the various os_xxx.cpp files all use INCLUDE_JFR around event code.
private final static String EVENT_NAME = EventNames.NativeLibraryLoad; | ||
|
||
public static void main(String[] args) throws Throwable { | ||
Recording recording = new Recording(); |
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.
Use try-with-resources.
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 Erik, this was taken from test/jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java , I do not see in main there a try with resources. What do you want to put in the try block exactly ? The new Recording() ?
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.
try (Recording r = new Recording()) {
...
}
It's not used everywhere, but it seems proper to release chunk resources when the test is finished.
(I should probably go over all tests and change to avoid the pattern being copied.)
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 Erik, I adjusted the test as recommended .
Hi Matthias. Sorry, I forgot to press submit. |
@MBaesken 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 69 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. ➡️ To integrate this PR with the above commit message to the |
Hi Erik, thanks for the review ! |
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.
Overall looks okay but I have a request for the test. Thanks.
@@ -1008,11 +1023,22 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { | |||
return os::get_default_process_handle(); | |||
#else | |||
log_info(os)("attempting shared library load of %s", filename); | |||
|
|||
#if INCLUDE_JFR |
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.
Just for completeness the various os_xxx.cpp files all use INCLUDE_JFR around event code.
if (Platform.isWindows()) { | ||
libTemplate = "%s.dll"; | ||
} else if (Platform.isOSX()) { | ||
libTemplate = "lib%s.dylib"; |
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.
We have Platform.sharedLibraryExt()
to simplify this a bit. Unfortunately we don't have a sharedLibraryPrefix()
to reduce it to one line. :(
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 David, that coding can indeed be improved. But let's do it in a follow-up. And in the follow-up also for existing https://github.com/openjdk/jdk/blob/master/test/jdk/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java where the same/similar code is present. The follow-up should also introduce 'sharedLibraryPrefix' .
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.
Okay
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 created https://bugs.openjdk.org/browse/JDK-8313670 .
try (Recording recording = new Recording()) { | ||
recording.enable(EVENT_NAME); | ||
recording.start(); | ||
System.loadLibrary("awt"); |
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 don't think loading libawt is a good choice - maybe libnet or libnio? Headless builds may not have libawt and I'd be concerned about loading it directly and running the OnLoad hooks.
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.
libnet does not work, it gives us the error 'Native Library /testdir/images/jdk/lib/libnet.so already loaded in another classloader' . So we have to load something that is not there already. But I agree, awt might not be the best choice. What about libinstrument ?
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.
Yeah that might work. If worse comes to worst, you could create a trivial library just or the test.
David are you fine with the latest version? |
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 okay. Thanks
Hi David , thanks for the review ! /integrate |
Going to push as commit 5d23295.
Your commit was automatically rebased without conflicts. |
Add a NativeLibraryLoad event that provides us more detail about shared lib/dll loads. This gives a time stamp and success + error details of the load operation. It enhances the already existing information we get from the existing NativeLibrary event (that periodically samples the native modules of the jvm process).
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15065/head:pull/15065
$ git checkout pull/15065
Update a local copy of the PR:
$ git checkout pull/15065
$ git pull https://git.openjdk.org/jdk.git pull/15065/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15065
View PR using the GUI difftool:
$ git pr show -t 15065
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15065.diff
Webrev
Link to Webrev Comment