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-8280940: gtest os.release_multi_mappings_vm is racy #7288
JDK-8280940: gtest os.release_multi_mappings_vm is racy #7288
Conversation
|
817cafc
to
bc634f1
Compare
e0e73df
to
b35b2f0
Compare
b35b2f0
to
36bcff1
Compare
Webrevs
|
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.
You may want to correct 'NUMASwitchter' in the PR so that
any searches find the correct name.
// re-reserve it. This should work unless release failed. | ||
address p2 = (address)os::attempt_reserve_memory_at((char*)p, total_range_len); | ||
ASSERT_EQ(p2, p); | ||
// ...re-reserve the middle stripes. This should work unless release failed. |
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:
s/failed/failed silently/
just to be clear.
@tstuefe 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 161 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 @dcubed-ojdk ! |
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.
@@ -449,31 +449,54 @@ struct NUMASwitcher { | |||
} |
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.
Not a review (I'm not an expert in the relevant area), just a couple drive-by comments. However, GitHub UI won't let me comment on the parts that I want. So getting as close as I can.
(1) The TEST_VM
line should be outdented.
(2) After 8277822, I think the tracking level is always going to be > NMT_off
in a debug build, so we'll only be testing in product builds. That seems problematic.
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 Kim,
thanks for taking a look!
Not a review (I'm not an expert in the relevant area), just a couple drive-by comments. However, GitHub UI won't let me comment on the parts that I want. So getting as close as I can.
(1) The
TEST_VM
line should be outdented.
Sure.
(2) After 8277822, I think the tracking level is always going to be >
NMT_off
in a debug build, so we'll only be testing in product builds. That seems problematic.
We run the gtests in all NMT modes (off, summary, default), see:
jdk/test/hotspot/jtreg/gtest/NMTGtests.java
Lines 30 to 36 in 072e7b4
/* @test id=nmt-off | |
* @summary Run NMT-related gtests with NMT switched off | |
* @library /test/lib | |
* @modules java.base/jdk.internal.misc | |
* java.xml | |
* @run main/native GTestWrapper --gtest_filter=NMT*:os* -XX:NativeMemoryTracking=off | |
*/ |
so we run these tests in debug builds with NMT=off. The NMT gtests have been introduced with 8256844 and extended to cover the os* tests with 8277822.
That said, I should take a look at 8263464, see if this still is a problem.
Cheers, Thomas
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, https://bugs.openjdk.java.net/browse/JDK-8263464 is still a problem. This means that even though we can release multiple mappings with os::release_memory, NMT cannot cope with that.
AFAIK the only real example of releasing multiple segments in one go is Windows + UseNUMA, and there os::release_memory(), when called over multiple segments, just recursively releases the segments individually. So I believe this works with NMT. Still, it would be nice to fix this.
@zhengyu123 : do you think https://bugs.openjdk.java.net/browse/JDK-8263464 is difficult to fix? Should I take a stab at it or do you want to take a look?
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.
There used to not be a way to run gtests with non-default -XX:whatever
arguments and the like. But it looks like you did something about that in
JDK-8251158. I had no idea!
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.
:) thanks. Yes, I was afraid of missing out on tests. Since then, we have embraced this pattern of XX-specific gtests. It's a nice way to get test coverage with not much effort.
No takers? Need a second 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.
Looks good
Took the test for some repeated spins through our test-environment and all looks good.
Thanks @kstefanj @kimbarrett and @dcubed-ojdk! /integrate |
Going to push as commit f07b816.
Your commit was automatically rebased without conflicts. |
release_multi_mappings_vm is unfortunately racy.
The original intention of the test was to check that
os::release_memory()
works across multiple mappings allocated with multiple calls toos::reserve_memory()
. This was broken for a long time on windows, since it relies on the implicit assumption that every platform uses mmap-ish APIs under the hood. But Windows virtual memory API (and SysV shmat, for that matter) does not work that way.The release_multi_mappings_vm test
Step (C) will fail if the os::release call in (B) failed to release the mapping. Which it sometimes did silently, so just checking the return code in (B) was not sufficient.
Unfortunately, it will also fail if someone concurrently mapped into the range between (B) and (C). It's rare, but it happens.
This is difficult to make completely airtight, but we could make it much more stable:
The patch does just that.
It also adds a lengthy comment.
I also needed to place the NUMASwitcher line in front of the last os::release_memory. That is done just to clean up everything before the tests ends, but now its a multi-mapping-release too (we now release front stripe, middle, and end stripe).
Tests:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7288/head:pull/7288
$ git checkout pull/7288
Update a local copy of the PR:
$ git checkout pull/7288
$ git pull https://git.openjdk.java.net/jdk pull/7288/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 7288
View PR using the GUI difftool:
$ git pr show -t 7288
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7288.diff