8277631: ZGC: CriticalMetaspaceAllocation asserts

Reviewed-by: pliden, stefank, dholmes
This commit is contained in:
Erik Österlund 2021-11-25 09:50:43 +00:00
parent f0136ec945
commit 3034ae87ce
2 changed files with 39 additions and 9 deletions

View File

@ -113,10 +113,12 @@ void MetaspaceCriticalAllocation::remove(MetadataAllocationRequest* request) {
}
bool MetaspaceCriticalAllocation::try_allocate_critical(MetadataAllocationRequest* request) {
MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag);
if (_requests_head == request) {
// The first request can't opportunistically ride on a previous GC
return false;
{
MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag);
if (_requests_head == request) {
// The first request can't opportunistically ride on a previous GC
return false;
}
}
// Try to ride on a previous GC and hope for early satisfaction
wait_for_purge(request);
@ -124,8 +126,12 @@ bool MetaspaceCriticalAllocation::try_allocate_critical(MetadataAllocationReques
}
void MetaspaceCriticalAllocation::wait_for_purge(MetadataAllocationRequest* request) {
while (!request->has_result()) {
ThreadBlockInVM tbivm(JavaThread::current());
ThreadBlockInVM tbivm(JavaThread::current());
MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag);
for (;;) {
if (request->has_result()) {
break;
}
MetaspaceCritical_lock->wait_without_safepoint_check();
}
}

View File

@ -28,11 +28,11 @@
* @summary converted from VM Testbase gc/gctests/LoadUnloadGC.
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent, monitoring]
* VM Testbase readme:
* In this test a 1000 classes are loaded and unloaded in a loop.
* In this test 1000 classes are loaded and unloaded in a loop.
* Class0 gets loaded which results in Class1 getting loaded and so on all
* the way uptill class1000. The classes should be unloaded whenever a
* the way up to class1000. The classes should be unloaded whenever a
* garbage collection takes place because their classloader is made unreachable
* at the end of the each loop iteration. The loop is repeated 1000 times.
* at the end of each loop iteration. The loop is repeated 1000 times.
*
* @requires vm.opt.final.ClassUnloading
* @library /vmTestbase
@ -45,6 +45,30 @@
* gc.gctests.LoadUnloadGC.LoadUnloadGC
*/
/*
* @test
* @key stress
*
* @summary converted from VM Testbase gc/gctests/LoadUnloadGC.
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent, monitoring]
* VM Testbase readme:
* In this test 1000 classes are loaded and unloaded in a loop.
* Class0 gets loaded which results in Class1 getting loaded and so on all
* the way up to class1000. The classes should be unloaded whenever a
* garbage collection takes place because their classloader is made unreachable
* at the end of each loop iteration. The loop is repeated 1000 times.
*
* @requires vm.opt.final.ClassUnloading
* @library /vmTestbase
* /test/lib
* @build nsk.share.gc.ClassChain
* @run main/othervm
* -XX:MaxMetaspaceSize=64M
* -XX:MetaspaceSize=64M
* -XX:CompressedClassSpaceSize=32M
* gc.gctests.LoadUnloadGC.LoadUnloadGC
*/
package gc.gctests.LoadUnloadGC;
import nsk.share.test.*;