Skip to content

Commit

Permalink
Merge pull request #4826 from amicic/inactiveCopyCacheClean
Browse files Browse the repository at this point in the history
Inactive copy caches for Concurrent Scavenger
  • Loading branch information
youngar authored Mar 2, 2020
2 parents 5e3fd64 + 2f1b020 commit f02a6f7
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 64 deletions.
9 changes: 6 additions & 3 deletions example/glue/EnvironmentDelegate.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 IBM Corp. and others
* Copyright (c) 2017, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -178,6 +178,11 @@ class MM_EnvironmentDelegate
* Release shared VM acccess.
*/
void releaseVMAccess();

/**
* Returns true if a mutator threads entered native code without releasing VM access
*/
bool inNative() { return false; }

/**
* Check whether another thread is requesting exclusive VM access. This method must be
Expand Down Expand Up @@ -228,9 +233,7 @@ class MM_EnvironmentDelegate

void reacquireCriticalHeapAccess(uintptr_t data) {}

#if defined(OMR_GC_CONCURRENT_SCAVENGER)
void forceOutOfLineVMAccess() {}
#endif /* OMR_GC_CONCURRENT_SCAVENGER */

#if defined (OMR_GC_THREAD_LOCAL_HEAP)
/**
Expand Down
15 changes: 11 additions & 4 deletions gc/base/EnvironmentBase.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -424,6 +424,11 @@ class MM_EnvironmentBase : public MM_BaseVirtual
* Releases shared VM access.
*/
void releaseVMAccess();

/**
* Returns true if a mutator threads entered native code without releasing VM access
*/
MMINLINE bool inNative() { return _delegate.inNative(); }

/**
* Acquire exclusive access to request a gc.
Expand Down Expand Up @@ -512,13 +517,11 @@ class MM_EnvironmentBase : public MM_BaseVirtual
*/
bool exclusiveAccessBeatenByOtherThread() { return _exclusiveAccessBeatenByOtherThread; }

#if defined(OMR_GC_CONCURRENT_SCAVENGER)
/**
* Force thread to use out-of-line request for VM access. This may be required if there
* is there is an event waiting to be hooked the next time the thread acquires VM access.
*/
void forceOutOfLineVMAccess() { _delegate.forceOutOfLineVMAccess(); }
#endif /* OMR_GC_CONCURRENT_SCAVENGER */

#if defined (OMR_GC_THREAD_LOCAL_HEAP)
/**
Expand Down Expand Up @@ -588,7 +591,11 @@ class MM_EnvironmentBase : public MM_BaseVirtual
MMINLINE MM_WorkStack *getWorkStack() { return &_workStack; }

virtual void flushNonAllocationCaches() { _delegate.flushNonAllocationCaches(); }
virtual void flushGCCaches() {}
/* Flush GC specific caches (of mutator thread involved in object graph traversal)
* For example, push copy caches created by Read Barrier in Concurrent Scavenger to be scanned.
* @param final if true it's done in a STW pass at the start of GC. We may do some other things beyond pushing caches, like make the unused part of cache walkable. If false (called in a middle of a GC cycle) we don't care about having heap walkable)
*/
virtual void flushGCCaches(bool final) {}

/**
* Get a pointer to common GC metadata attached to this environment. The GC environment structure
Expand Down
6 changes: 3 additions & 3 deletions gc/base/MasterGCThread.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -248,9 +248,9 @@ MM_MasterGCThread::masterThreadEntryPoint()
/* thread attached successfully */
MM_EnvironmentBase *env = MM_EnvironmentBase::getEnvironment(omrVMThread);

/* attachVMThread could allocate an execute a barrier (since it that point, this thread acted as a mutator thread.
/* attachVMThread could have allocated and execute a barrier (until point, this thread acted as a mutator thread.
* Flush GC chaches (like barrier buffers) before turning into the master thread */
env->flushGCCaches();
env->flushGCCaches(true);

env->setThreadType(GC_MASTER_THREAD);

Expand Down
4 changes: 2 additions & 2 deletions gc/base/OMRVMThreadInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -35,7 +35,7 @@ GC_OMRVMThreadInterface::flushCachesForWalk(MM_EnvironmentBase *env)
env->_objectAllocationInterface->flushCache(env);
/* If we are in a middle of a concurrent GC, we want to flush GC caches, typically for mutator threads doing GC work.
* (GC threads are smart enough to do it themselves, before they let the walk occur) */
env->flushGCCaches();
env->flushGCCaches(true);
}

void
Expand Down
8 changes: 4 additions & 4 deletions gc/base/standard/EnvironmentStandard.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2019 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -73,7 +73,7 @@ void
MM_EnvironmentStandard::tearDown(MM_GCExtensionsBase *extensions)
{
/* If we are in a middle of a concurrent GC, we may want to flush GC caches (if thread happens to do GC work) */
flushGCCaches();
flushGCCaches(true);
/* tearDown base class */
MM_EnvironmentBase::tearDown(extensions);
}
Expand All @@ -93,13 +93,13 @@ MM_EnvironmentStandard::flushNonAllocationCaches()
}

void
MM_EnvironmentStandard::flushGCCaches()
MM_EnvironmentStandard::flushGCCaches(bool final)
{
#if defined(OMR_GC_CONCURRENT_SCAVENGER)
if (getExtensions()->concurrentScavenger) {
if (MUTATOR_THREAD == getThreadType()) {
if (NULL != getExtensions()->scavenger) {
getExtensions()->scavenger->threadReleaseCaches(this, true);
getExtensions()->scavenger->threadReleaseCaches(this, true, final);
}
}
}
Expand Down
19 changes: 15 additions & 4 deletions gc/base/standard/EnvironmentStandard.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -52,6 +52,12 @@ class MM_EnvironmentStandard : public MM_EnvironmentBase
MM_CopyScanCacheStandard *_deferredCopyCache; /**< a copy cache about to be pushed to scan queue, but before that may be merged with some other caches that collectively form contiguous memory */
MM_CopyScanCacheStandard *_tenureCopyScanCache; /**< the current copy cache for tenuring */
MM_CopyScanCacheStandard *_effectiveCopyScanCache; /**< the the copy cache the received the most recently copied object, or NULL if no object copied in copy() */
#if defined(OMR_GC_CONCURRENT_SCAVENGER)
volatile MM_CopyScanCacheStandard *_inactiveSurvivorCopyScanCache; /**< variant of survivor copy cache, when mutator thread is inactive (released VM access) */
volatile MM_CopyScanCacheStandard *_inactiveDeferredCopyCache; /**< variant of deferred copy cache, when mutator thread is inactive (released VM access) */
volatile MM_CopyScanCacheStandard *_inactiveTenureCopyScanCache; /**< variant of tenure copy cache, when mutator thread is inactive (released VM access) */
#endif /* OMR_GC_CONCURRENT_SCAVENGER */

#if defined(OMR_GC_MODRON_SCAVENGER)
J9VMGC_SublistFragment _scavengerRememberedSet;
#endif
Expand All @@ -70,12 +76,12 @@ class MM_EnvironmentStandard : public MM_EnvironmentBase
static MM_EnvironmentStandard *newInstance(MM_GCExtensionsBase *extensions, OMR_VMThread *vmThread);

virtual void flushNonAllocationCaches();
virtual void flushGCCaches();
virtual void flushGCCaches(bool final);

virtual void initializeGCThread() {
/* before a thread turning into a GC one, it shortly acted as a mutator (during thread attach sequence),
* which means it may have allocated or exacuted an object access barrier. */
flushGCCaches();
* which means it may have allocated or executed an object access barrier. */
flushGCCaches(true);
}

MMINLINE static MM_EnvironmentStandard *getEnvironment(OMR_VMThread *omrVMThread) { return static_cast<MM_EnvironmentStandard*>(omrVMThread->_gcOmrVMThreadExtensions); }
Expand All @@ -88,6 +94,11 @@ class MM_EnvironmentStandard : public MM_EnvironmentBase
,_deferredCopyCache(NULL)
,_tenureCopyScanCache(NULL)
,_effectiveCopyScanCache(NULL)
#if defined(OMR_GC_CONCURRENT_SCAVENGER)
,_inactiveSurvivorCopyScanCache(NULL)
,_inactiveDeferredCopyCache(NULL)
,_inactiveTenureCopyScanCache(NULL)
#endif /* OMR_GC_CONCURRENT_SCAVENGER */
,_tenureTLHRemainderBase(NULL)
,_tenureTLHRemainderTop(NULL)
,_loaAllocation(false)
Expand Down
Loading

0 comments on commit f02a6f7

Please sign in to comment.