From b198e30513bb638c36e334ccc1e8d0c203d881e5 Mon Sep 17 00:00:00 2001 From: Salman Rana Date: Thu, 15 Jun 2023 14:51:12 -0400 Subject: [PATCH] initializeGCParameters For CRIU Restore Relates to https://github.com/eclipse-openj9/openj9/pull/17459#discussion_r1231139601 Signed-off-by: Salman Rana --- gc/base/Configuration.cpp | 32 +++++++++++++++++++--- gc/base/Configuration.hpp | 14 ++++------ gc/base/standard/ConfigurationStandard.cpp | 6 ++-- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/gc/base/Configuration.cpp b/gc/base/Configuration.cpp index dd63babdec..ae41432cd1 100644 --- a/gc/base/Configuration.cpp +++ b/gc/base/Configuration.cpp @@ -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); } @@ -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); @@ -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()) { @@ -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) */ diff --git a/gc/base/Configuration.hpp b/gc/base/Configuration.hpp index 2bfc55e86c..32519cdd45 100644 --- a/gc/base/Configuration.hpp +++ b/gc/base/Configuration.hpp @@ -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; } @@ -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. @@ -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) diff --git a/gc/base/standard/ConfigurationStandard.cpp b/gc/base/standard/ConfigurationStandard.cpp index 255e92fcda..f2f647200f 100644 --- a/gc/base/standard/ConfigurationStandard.cpp +++ b/gc/base/standard/ConfigurationStandard.cpp @@ -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) @@ -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())) {