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

8262881: port JVM/DI tests from JDK-4413752 to JVM/TI #2899

Closed
wants to merge 4 commits into from

Conversation

dcubed-ojdk
Copy link
Member

@dcubed-ojdk dcubed-ojdk commented Mar 9, 2021

Add three tests from JDK-4413752 ported to JVM/TI:

  • RawMonitorEnter() with SuspendThread()

    • test/hotspot/jtreg/serviceability/jvmti/SuspendWithRawMonitorEnter/SuspendWithRawMonitorEnter.java
    • test/hotspot/jtreg/serviceability/jvmti/SuspendWithRawMonitorEnter/libSuspendWithRawMonitorEnter.cpp
  • ObjectMonitor enter() with SuspendThread()

    • test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorEnter/SuspendWithObjectMonitorEnter.java
    • test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorEnter/libSuspendWithObjectMonitorEnter.cpp
  • ObjectMonitor wait() with SuspendThread

    • test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/SuspendWithObjectMonitorWait.java
    • test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/libSuspendWithObjectMonitorWait.cpp

The Java files have a transaction diagram to show what each of the
threads in the test is doing.


Progress

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

Issue

  • JDK-8262881: port JVM/DI tests from JDK-4413752 to JVM/TI

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2899

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 9, 2021

👋 Welcome back dcubed! 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
Copy link

openjdk bot commented Mar 9, 2021

@dcubed-ojdk The following label will be automatically applied to this pull request:

  • serviceability

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 serviceability serviceability-dev@openjdk.org label Mar 9, 2021
@dcubed-ojdk
Copy link
Member Author

/label add hotspot-runtime

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Mar 9, 2021
@openjdk
Copy link

openjdk bot commented Mar 9, 2021

@dcubed-ojdk
The hotspot-runtime label was successfully added.

@dcubed-ojdk
Copy link
Member Author

dcubed-ojdk commented Mar 9, 2021

These new tests were exercised with Mach5 Tier[134567] testing.
They have also been tested on macOSX and Linux-X64 with the three
build configs running in parallel: fastdebug, release, slowdebug for
each of the three new tests for 6 hours. The results for macOS and
Linux-X64 are in the bug report.

@dcubed-ojdk dcubed-ojdk marked this pull request as ready for review March 10, 2021 16:08
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 10, 2021
@mlbridge
Copy link

mlbridge bot commented Mar 10, 2021

Webrevs

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Dan,
It is interesting how much these tests were changed when ported.
A couple of indent-related comments.
There are incorrect indents in the following lines in all .cpp files:

68 Java_SuspendWithObjectMonitorEnter_GetResult(JNIEnv *env, jclass cls) {
69     return iGlobalStatus;
70 }
 72 JNIEXPORT void JNICALL
73 Java_SuspendWithObjectMonitorEnter_SetPrintDebug(JNIEnv *env, jclass cls) {
74     printdebug = 1;
75 }
97 Java_SuspendWithObjectMonitorEnterWorker_GetPrintDebug(JNIEnv *env, jclass cls) {
98     return printdebug;
99 }

Thanks,
Serguei

@dcubed-ojdk
Copy link
Member Author

@sspitsyn - Thanks for the review! I figured you would enjoy this 20 year old
blast from the past! I'm tempted to ping @karenkinnear just to see if she'll
remember these tests!

I'll fix the indents in the .cpp files. Right now I'm using these tests to shake
out @robehn's work on "JDK-8257831 Suspend with handshakes".


native static int GetResult();
native static void SetPrintDebug();
native static void SuspendThread(int id, SuspendWithObjectMonitorEnterWorker thr);
Copy link

@lyndseyBeil lyndseyBeil Mar 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I detect that this code is problematic. According to the Bad practice (BAD_PRACTICE), Nm: Method names should start with a lower case letter (NM_METHOD_NAMING_CONVENTION).
Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. In the original 20 year old test those methods were:

    native static int diobj4413752GetMonitorInfo(int id, Object mon);
    native static int diobj4413752GetResult();
    native static int diobj4413752SuspendThread(int id, diobjWorker thr);
    native static int diobj4413752Wait4ContendedEnter(int id, diobjWorker thr);

so when I got rid of the diobj4413752 prefix I forgot to fix the new first letter.
I'll take care of those method renames and I'll double check for others.

@robehn
Copy link
Contributor

robehn commented Mar 22, 2021

Hi Dan,

If you change the native methods, e.g. :
native static void RawMonitorEnter(int id);
To something like:
native static int RawMonitorEnter();

You can then handle the jvmti error in the Java code, so you don't need to pass down the 'id' of the thread.
You then remove all debug code from the C-code agent, which removes some native methods also.
Which also leads to that you don't need the thread 'id', instead you can just use the thread name, which removes some Java code.

Also you shouldn't catch the UnsatisfiedLinkError, as docs also says: "An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch."

You also have a lot of code for argument parsing which is not used by the test inside the test methods.
Can you either remove that or if you want it put it in a separate class/method, so e.g. "doWork()" takes parsed arguments instead.

Thanks, Robbin

@dcubed-ojdk
Copy link
Member Author

@robehn - Thanks for the review and for the suggested improvements to the tests.
It will take me a bit of time to make and test these suggestions.

@sspitsyn
Copy link
Contributor

Hi Dan,

I figured you would enjoy this 20 year old blast from the past!
Yes, of course, but these tests look like they have been written today! :)

Thank you for making changes!
I've just noticed one minor issue:

libSuspendWithObjectMonitorEnter.cpp
libSuspendWithObjectMonitorWait.cpp:
The static variables below are not used and can be removed:

 32 static jrawMonitorID threadLock = NULL;
 33 static char threadLockName[] = "threadLock";

Thanks,
Serguei

@dcubed-ojdk
Copy link
Member Author

@sspitsyn - Thanks for the re-review. I'll take care of the unused variables
and I'll do an audit of all three tests and look for more.

@dcubed-ojdk
Copy link
Member Author

Changes for the next version of the tests:

  • @robehn CR changes:
    • changed the JVM/TI function wrappers to be much simpler and just return the JVM/TI return code to the Java code caller; all error checking is now on the Java side of the test.
    • dropped the 'id' parameter; deleted many native support functions.

@robehn - I kept the catch of UnsatisfiedLinkError because what I'm doing there is printing a nice error message and then rethrowing the same exception; it makes it easier to debug the build process for the test.
@robehn - I moved the argument parsing code to the main() method; while the default configuration of the test doesn't use command line arguments, I have stress wrappers for these tests that use the command line args.

@lyndseyBeil - I renamed the remaining native methods to camelCase() style.

@sspitsyn - I've removed the unused variables from the three tests.

@robehn, @lyndseyBeil and @sspitsyn - thanks for your reviews! New commit coming shortly.

@dcubed-ojdk
Copy link
Member Author

The v03 version was tested with Mach5 Tier[134567] testing. The three new tests passed
in all configurations in all of those tiers.

I also used the latest version of the tests to reproduce the failure mode that I'm
hunting in "JDK-8264393 JDK-8258284 introduced dangling TLH race" so these
tests still help reproduce that bug.

@dcubed-ojdk
Copy link
Member Author

@robehn, @lyndseyBeil and @sspitsyn - please re-review when you get the chance.

Copy link
Contributor

@robehn robehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like simple agent code 👍

Thanks!

/Robbin

@openjdk
Copy link

openjdk bot commented Apr 7, 2021

@dcubed-ojdk 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:

8262881: port JVM/DI tests from JDK-4413752 to JVM/TI

Reviewed-by: sspitsyn, rehn

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 93 new commits pushed to the master branch:

  • 774e5ae: 8264742: member variable _monitor of MonitorLocker is redundant
  • 7a99a98: 8262316: Reducing locks in RSA Blinding
  • d3fdd73: 8264173: [s390] Improve Hardware Feature Detection And Reporting
  • 9d65039: 8263984: Invalidate printServices when there are no printers
  • adb860e: 8255800: Raster creation methods need some specification clean up
  • eab8455: 8261137: Optimization of Box nodes in uncommon_trap
  • 92fad1b: 8264680: Use the blessed modifier order in java.desktop
  • 17202c8: 8264748: Do not include arguments.hpp from compilerDefinitions.hpp
  • c3abdc9: 8264797: Do not include klassVtable.hpp from instanceKlass.hpp
  • eb5c097: 8262389: Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present
  • ... and 83 more: https://git.openjdk.java.net/jdk/compare/353807c5f108c020a19bab707991d5ebdb68a8e3...master

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 Pull request is ready to be integrated label Apr 7, 2021
@dcubed-ojdk
Copy link
Member Author

@robehn - Thanks for the re-review! And thank you for suggesting the
much simpler agent code!!

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Dan,
It looks good in general.
But I think moving JVMTI error code checks to Java is a step in a wrong direction.
First, it makes it inconsistent with all existing JVMTI tests. In this particular case, all the complexity is moved to Java side making it unbalanced. Also, we are working with Leonid toward creating relevant native testing lib for serviceability/jvmti tests (created it for Loom first) which has a support to print symbolic names (for error codes as well) if necessary.
Not sure, I understood what wrong with the native check_jvmti_status(). It seems the id argument is not needed much and can be removed anyway.
Thanks,
Serguei

@dcubed-ojdk
Copy link
Member Author

Hi @sspitsyn,

I rather like the much simpler agent code and it puts the majority of logic
in the .java file so the reader/reviewer doesn't have to jump back and forth
between the two files nearly as much.

The id argument had to be passed to the old version of the function calls
in order for the logging messages generated by the agent code to (easily)
have the same thread names as the Java side logging. Once all the error
checking was moved to the Java side, that made the id argument no longer
necessary and also allowed the native check_jvmti_status() function (along
with other functions) to be removed. So there was nothing wrong with the
native check_jvmti_status() function; it was just made obsolete by the code
migration to the Java side.

I consider @robehn's idea here to be good evolution for these kinds of tests to
move code from the native side, where the code is more platform dependent,
to the Java side, where the code is more platform independent.

I hope I have convinced you that this is a good changeset for moving forward.

@sspitsyn
Copy link
Contributor

sspitsyn commented Apr 7, 2021

Dan,
I'm sorry, I do not see much value in this approach going forward. One line with a call to check_jvmti_status() does not add much to the platform dependency no to complexity in native code. Also, more sophisticated analysis of the returned error code frequently is needed. Also, I consider it not feasible to move a thousand of JVMTI tests in this direction. So that we will end up with inconsistency over all tests.
I've already marked this as reviewed, so you can push it. But I'm against following this pattern going forward. Or at least, we need to consult with the SQE engineers first.
Thanks,
Serguei

@dcubed-ojdk
Copy link
Member Author

@sspitsyn - First, thanks for approving the changes!

Second, I'm not proposing changing any other JVM/TI tests to use this style. The only
reason that this style works (for me and @robehn) is because none of these JVM/TI calls
is expected to fail. The tests are carefully constructed to exercise the code for a race
condition that will result in a hang or a crash (if something goes wrong). In the case of
these tests, we don't need sophisticated analysis of the returned error codes.

Again, thanks for approving these tests.

@sspitsyn
Copy link
Contributor

sspitsyn commented Apr 8, 2021

Dan, thank you for extra explanation and for taking care to port these old tests!

@dcubed-ojdk
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this Apr 9, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 9, 2021
@openjdk
Copy link

openjdk bot commented Apr 9, 2021

@dcubed-ojdk Since your change was applied there have been 127 commits pushed to the master branch:

  • 06e6b1f: 8259242: Remove ProtectionDomainSet_lock
  • 9bb1863: 8260923: Add more tests for SSLSocket input/output shutdown
  • 33fa855: 8264732: Clean up LinkResolver::vtable_index_of_interface_method()
  • b3782ea: 8264918: [JVMCI] getVtableIndexForInterfaceMethod doesn't check that type and method are related
  • f7a6c63: 8259822: [PPC64] Support the prefixed instruction format added in POWER10
  • a45733f: 8264779: Fix doclint warnings in java/nio
  • 3e57924: 8264885: Fix the code style of macro in aarch64_neon_ad.m4
  • 051c117: 8264923: PNGImageWriter.write_zTXt throws Exception with a typo
  • 1c6b113: 8264513: Cleanup CardTableBarrierSetC2::post_barrier
  • 666fd62: 8264881: Remove the old development option MemProfiling
  • ... and 117 more: https://git.openjdk.java.net/jdk/compare/353807c5f108c020a19bab707991d5ebdb68a8e3...master

Your commit was automatically rebased without conflicts.

Pushed as commit 1ca4abe.

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

@dcubed-ojdk dcubed-ojdk deleted the JDK-8262881 branch April 9, 2021 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
4 participants