Skip to content

Commit dca55b4

Browse files
committed
8371420: Still sporadic failures of gc/TestAlwaysPreTouchBehavior.java#<gcname> on Linux after JDK-8359104
Reviewed-by: mdoerr, ayang
1 parent b5ac8f8 commit dca55b4

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

test/hotspot/jtreg/gc/TestAlwaysPreTouchBehavior.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,8 @@ public class TestAlwaysPreTouchBehavior {
133133
//
134134

135135
public static void main(String [] args) {
136-
long rss = WhiteBox.getWhiteBox().rss();
137-
System.out.println("RSS: " + rss);
138-
long available = WhiteBox.getWhiteBox().hostAvailableMemory();
139-
System.out.println("Host available memory: " + available);
140-
136+
int maxIter = 20;
141137
long heapSize = 256 * 1024 * 1024;
142-
143138
// On Linux, a JVM that runs with 256M pre-committed heap will use about 60MB (release JVM) RSS. Barring
144139
// memory pressure that causes us to lose RSS, pretouching should increase RSS to >256MB. So there should be a
145140
// clear distinction between non-pretouched and pretouched.
@@ -150,12 +145,28 @@ public static void main(String [] args) {
150145
// on the side of disregarding true errors than to produce false positives (if pretouching is broken, at least
151146
// some of the runs of this test will run on beefy enough machines and show the test as failed).
152147
long requiredAvailable = 1024 * 1024 * 1024;
153-
if (rss == 0) {
154-
throw new SkippedException("cannot get RSS?");
155-
}
156-
if (available > requiredAvailable) {
157-
Asserts.assertGreaterThan(rss, minRequiredRss, "RSS of this process(" + rss + "b) should be bigger " +
158-
"than or equal to heap size(" + heapSize + "b) (available memory: " + available + "). On Linux Kernel < 4.14 RSS can be inaccurate");
148+
149+
// RSS values we get are sometimes somewhat delayed or inaccurate
150+
for (int iter=0; iter < maxIter; iter++) {
151+
long rss = WhiteBox.getWhiteBox().rss();
152+
System.out.println("RSS: " + rss);
153+
long available = WhiteBox.getWhiteBox().hostAvailableMemory();
154+
System.out.println("Host available memory: " + available);
155+
156+
if (rss == 0) {
157+
throw new SkippedException("cannot get RSS?");
158+
}
159+
if (available <= requiredAvailable) {
160+
throw new SkippedException("Available memory on host " + available + " is too small, not larger than required available memory " + requiredAvailable);
161+
}
162+
163+
if ((rss < minRequiredRss) && iter < maxIter-1) {
164+
System.out.println("We got only an RSS value of " + rss + " but require " + minRequiredRss + ", let's retry!");
165+
} else {
166+
Asserts.assertGreaterThan(rss, minRequiredRss, "RSS of this process(" + rss + "b) should be bigger " +
167+
"than or equal to heap size(" + heapSize + "b) (available memory: " + available + "). On Linux Kernel < 4.14 RSS can be inaccurate");
168+
break;
169+
}
159170
}
160171
}
161172
}

0 commit comments

Comments
 (0)