Skip to content

Commit

Permalink
Merge pull request #179 from RSalman/v0.40-2
Browse files Browse the repository at this point in the history
(0.40) initializeGCParameters For CRIU Restore
  • Loading branch information
pshipton authored Jun 22, 2023
2 parents 0fc6cf3 + b87ebc1 commit 2e351ba
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
32 changes: 28 additions & 4 deletions gc/base/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ MM_Configuration::tearDown(MM_EnvironmentBase* env)
/* DefaultMemorySpace needs to be killed before
* ext->heap is freed in MM_Configuration::tearDown. */
if (NULL != extensions->heap) {
MM_MemorySpace *modronMemorySpace = extensions->heap->getDefaultMemorySpace();
MM_MemorySpace* modronMemorySpace = extensions->heap->getDefaultMemorySpace();
if (NULL != modronMemorySpace) {
modronMemorySpace->kill(env);
}
Expand Down Expand Up @@ -153,7 +153,7 @@ void
MM_Configuration::destroyCollectors(MM_EnvironmentBase* env)
{
MM_GCExtensionsBase* extensions = env->getExtensions();
MM_Collector *collector = extensions->getGlobalCollector();
MM_Collector* collector = extensions->getGlobalCollector();

if (NULL != collector) {
collector->kill(env);
Expand Down Expand Up @@ -279,7 +279,7 @@ bool
MM_Configuration::initializeRunTimeObjectAlignmentAndCRShift(MM_EnvironmentBase* env, MM_Heap* heap)
{
MM_GCExtensionsBase* extensions = env->getExtensions();
OMR_VM *omrVM = env->getOmrVM();
OMR_VM* omrVM = env->getOmrVM();

#if defined(OMR_GC_COMPRESSED_POINTERS)
if (env->compressObjectReferences()) {
Expand Down Expand Up @@ -521,7 +521,31 @@ MM_Configuration::initializeNUMAManager(MM_EnvironmentBase* env)
}

MM_ParallelDispatcher *
MM_Configuration::createParallelDispatcher(MM_EnvironmentBase *env, omrsig_handler_fn handler, void* handler_arg, uintptr_t defaultOSStackSize)
MM_Configuration::createParallelDispatcher(MM_EnvironmentBase* env, omrsig_handler_fn handler, void* handler_arg, uintptr_t defaultOSStackSize)
{
return MM_ParallelDispatcher::newInstance(env, handler, handler_arg, defaultOSStackSize);
}

#if defined(J9VM_OPT_CRIU_SUPPORT)
bool
MM_Configuration::reinitializeForRestore(MM_EnvironmentBase* env)
{
MM_GCExtensionsBase* extensions = env->getExtensions();

/* The initialization of the GC thread count can only happen if it is not enforced by the user. */
initializeGCThreadCount(env);

/* Currently, threads don't shutdown during reinitialization, so it is important to
* prevent the thread count from dropping below the number of checkpoint threads.
* This adjustment may no longer be necessary in the future once the shutdown behavior
* of dispatcher threads during restore is thoroughly tested.
*/
extensions->gcThreadCount = OMR_MAX(
extensions->dispatcher->threadCountMaximum(),
extensions->gcThreadCount);

initializeGCParameters(env);

return true;
}
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
14 changes: 5 additions & 9 deletions gc/base/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class MM_Configuration : public MM_BaseVirtual
virtual MM_MemorySpace* createDefaultMemorySpace(MM_EnvironmentBase* env, MM_Heap* heap, MM_InitializationParameters* parameters) = 0;
MM_EnvironmentBase* createEnvironment(MM_GCExtensionsBase* extensions, OMR_VMThread* vmThread);
virtual J9Pool* createEnvironmentPool(MM_EnvironmentBase* env) = 0;
virtual MM_ParallelDispatcher* createParallelDispatcher(MM_EnvironmentBase *env, omrsig_handler_fn handler, void* handler_arg, uintptr_t defaultOSStackSize);
virtual MM_ParallelDispatcher* createParallelDispatcher(MM_EnvironmentBase* env, omrsig_handler_fn handler, void* handler_arg, uintptr_t defaultOSStackSize);

bool initializeHeapRegionDescriptor(MM_EnvironmentBase *env, MM_HeapRegionDescriptor *region) { return _delegate.initializeHeapRegionDescriptorExtension(env, region); }
void teardownHeapRegionDescriptor(MM_EnvironmentBase *env, MM_HeapRegionDescriptor *region) { _delegate.teardownHeapRegionDescriptorExtension(env, region); }
bool initializeHeapRegionDescriptor(MM_EnvironmentBase* env, MM_HeapRegionDescriptor* region) { return _delegate.initializeHeapRegionDescriptorExtension(env, region); }
void teardownHeapRegionDescriptor(MM_EnvironmentBase* env, MM_HeapRegionDescriptor* region) { _delegate.teardownHeapRegionDescriptorExtension(env, region); }

MMINLINE MM_GCWriteBarrierType getBarrierType() { return _writeBarrierType; }

Expand All @@ -134,7 +134,7 @@ class MM_Configuration : public MM_BaseVirtual
* Delegated method to determine when to start tracking heap fragmentation, which should be inhibited
* until the heap has grown to a stable operational size.
*/
MMINLINE bool canCollectFragmentationStats(MM_EnvironmentBase *env) { return _delegate.canCollectFragmentationStats(env); }
MMINLINE bool canCollectFragmentationStats(MM_EnvironmentBase* env) { return _delegate.canCollectFragmentationStats(env); }

/**
* Called once during startup to indicate that the default memory space has been allocated.
Expand Down Expand Up @@ -178,11 +178,7 @@ class MM_Configuration : public MM_BaseVirtual
* @param[in] env the current environment.
* @return boolean indicating whether the configuration was successfully updated.
*/
virtual bool reinitializeForRestore(MM_EnvironmentBase* env)
{
Assert_MM_unreachable();
return false;
}
virtual bool reinitializeForRestore(MM_EnvironmentBase* env);
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */

MM_Configuration(MM_EnvironmentBase* env, MM_GCPolicy gcPolicy, MM_AlignmentType alignmentType, uintptr_t defaultRegionSize, uintptr_t defaultArrayletLeafSize, MM_GCWriteBarrierType writeBarrierType, MM_GCAllocationType allocationType)
Expand Down
6 changes: 4 additions & 2 deletions gc/base/standard/ConfigurationStandard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ MM_GlobalCollector*
MM_ConfigurationStandard::createCollectors(MM_EnvironmentBase* env)
{
#if defined(OMR_GC_MODRON_CONCURRENT_MARK) || defined(OMR_GC_MODRON_CONCCURENT_SWEEP)
MM_GCExtensionsBase *extensions = env->getExtensions();
MM_GCExtensionsBase* extensions = env->getExtensions();
#endif /* OMR_GC_MODRON_CONCURRENT_MARK || OMR_GC_CONCURRENT_SWEEP */

#if defined(OMR_GC_MODRON_CONCURRENT_MARK)
Expand Down Expand Up @@ -340,7 +340,9 @@ MM_ConfigurationStandard::reinitializeForRestore(MM_EnvironmentBase* env)
{
MM_GCExtensionsBase* extensions = env->getExtensions();

MM_MemoryPool *memoryPool;
MM_Configuration::reinitializeForRestore(env);

MM_MemoryPool* memoryPool;
MM_HeapMemoryPoolIterator poolIterator(env, extensions->heap);

while (NULL != (memoryPool = poolIterator.nextPool())) {
Expand Down

0 comments on commit 2e351ba

Please sign in to comment.