Skip to content

Commit 3034ae8

Browse files
committed
8277631: ZGC: CriticalMetaspaceAllocation asserts
Reviewed-by: pliden, stefank, dholmes
1 parent f0136ec commit 3034ae8

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

src/hotspot/share/memory/metaspaceCriticalAllocation.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,25 @@ void MetaspaceCriticalAllocation::remove(MetadataAllocationRequest* request) {
113113
}
114114

115115
bool MetaspaceCriticalAllocation::try_allocate_critical(MetadataAllocationRequest* request) {
116-
MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag);
117-
if (_requests_head == request) {
118-
// The first request can't opportunistically ride on a previous GC
119-
return false;
116+
{
117+
MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag);
118+
if (_requests_head == request) {
119+
// The first request can't opportunistically ride on a previous GC
120+
return false;
121+
}
120122
}
121123
// Try to ride on a previous GC and hope for early satisfaction
122124
wait_for_purge(request);
123125
return request->result() != NULL;
124126
}
125127

126128
void MetaspaceCriticalAllocation::wait_for_purge(MetadataAllocationRequest* request) {
127-
while (!request->has_result()) {
128-
ThreadBlockInVM tbivm(JavaThread::current());
129+
ThreadBlockInVM tbivm(JavaThread::current());
130+
MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag);
131+
for (;;) {
132+
if (request->has_result()) {
133+
break;
134+
}
129135
MetaspaceCritical_lock->wait_without_safepoint_check();
130136
}
131137
}

test/hotspot/jtreg/vmTestbase/gc/gctests/LoadUnloadGC/LoadUnloadGC.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
* @summary converted from VM Testbase gc/gctests/LoadUnloadGC.
2929
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent, monitoring]
3030
* VM Testbase readme:
31-
* In this test a 1000 classes are loaded and unloaded in a loop.
31+
* In this test 1000 classes are loaded and unloaded in a loop.
3232
* Class0 gets loaded which results in Class1 getting loaded and so on all
33-
* the way uptill class1000. The classes should be unloaded whenever a
33+
* the way up to class1000. The classes should be unloaded whenever a
3434
* garbage collection takes place because their classloader is made unreachable
35-
* at the end of the each loop iteration. The loop is repeated 1000 times.
35+
* at the end of each loop iteration. The loop is repeated 1000 times.
3636
*
3737
* @requires vm.opt.final.ClassUnloading
3838
* @library /vmTestbase
@@ -45,6 +45,30 @@
4545
* gc.gctests.LoadUnloadGC.LoadUnloadGC
4646
*/
4747

48+
/*
49+
* @test
50+
* @key stress
51+
*
52+
* @summary converted from VM Testbase gc/gctests/LoadUnloadGC.
53+
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent, monitoring]
54+
* VM Testbase readme:
55+
* In this test 1000 classes are loaded and unloaded in a loop.
56+
* Class0 gets loaded which results in Class1 getting loaded and so on all
57+
* the way up to class1000. The classes should be unloaded whenever a
58+
* garbage collection takes place because their classloader is made unreachable
59+
* at the end of each loop iteration. The loop is repeated 1000 times.
60+
*
61+
* @requires vm.opt.final.ClassUnloading
62+
* @library /vmTestbase
63+
* /test/lib
64+
* @build nsk.share.gc.ClassChain
65+
* @run main/othervm
66+
* -XX:MaxMetaspaceSize=64M
67+
* -XX:MetaspaceSize=64M
68+
* -XX:CompressedClassSpaceSize=32M
69+
* gc.gctests.LoadUnloadGC.LoadUnloadGC
70+
*/
71+
4872
package gc.gctests.LoadUnloadGC;
4973

5074
import nsk.share.test.*;

0 commit comments

Comments
 (0)