Skip to content
Permalink
Browse files
8277631: ZGC: CriticalMetaspaceAllocation asserts
Reviewed-by: pliden, stefank, dholmes
  • Loading branch information
fisk committed Nov 25, 2021
1 parent f0136ec commit 3034ae87ce4b94c7dc40cfb5a96d6d1e87910bbf
Showing 2 changed files with 39 additions and 9 deletions.
@@ -113,19 +113,25 @@ 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);
return request->result() != NULL;
}

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();
}
}
@@ -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.*;

1 comment on commit 3034ae8

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 3034ae8 Nov 25, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.