Skip to content

Commit

Permalink
Merge pull request #5131 from amicic/collector_stw_flag
Browse files Browse the repository at this point in the history
  • Loading branch information
youngar authored Apr 28, 2020
2 parents baddd6b + 4e30ec3 commit e93965e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
7 changes: 6 additions & 1 deletion gc/base/Collector.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2016 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 @@ -202,6 +202,8 @@ MM_Collector::preCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* subSpace, M
*/
completeExternalConcurrentCycle(env);

_stwCollectionInProgress = true;

/* Record the master GC thread CPU time at the start to diff later */
_masterThreadCpuTimeStart = omrthread_get_self_cpu_time(env->getOmrVMThread()->_os_thread);

Expand Down Expand Up @@ -461,6 +463,9 @@ MM_Collector::postCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* subSpace)
/* Set the excessive GC state, whether it was an implicit or system GC */
setThreadFailAllocFlag(env, excessiveGCDetected);
}

Assert_MM_true(_stwCollectionInProgress);
_stwCollectionInProgress = false;
}

/**
Expand Down
13 changes: 12 additions & 1 deletion gc/base/Collector.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) Copyright 1991, 2018 IBM Corp. and others
* (c) Copyright 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 @@ -60,6 +60,7 @@ class MM_Collector : public MM_BaseVirtual
bool _gcCompleted;
bool _isRecursiveGC;
bool _disableGC;
bool _stwCollectionInProgress; /**< if set, the whole or partial STW phase is in progress (mutators not running) */

uintptr_t _collectorExpandedSize;
uintptr_t _cycleType;
Expand Down Expand Up @@ -90,6 +91,15 @@ class MM_Collector : public MM_BaseVirtual
* @return boolean indicating if the last GC completed successfully.
*/
bool gcCompleted() { return _gcCompleted; }

/*
* Return value of _stwCollectionInProgress flag
*/
bool isStwCollectionInProgress()
{
return _stwCollectionInProgress;
}


private:
void setThreadFailAllocFlag(MM_EnvironmentBase *env, bool flag);
Expand Down Expand Up @@ -305,6 +315,7 @@ class MM_Collector : public MM_BaseVirtual
, _gcCompleted(false)
, _isRecursiveGC(false)
, _disableGC(false)
, _stwCollectionInProgress(false)
, _collectorExpandedSize(0)
, _cycleType(OMR_GC_CYCLE_TYPE_DEFAULT)
, _masterThreadCpuTimeStart(0)
Expand Down
5 changes: 0 additions & 5 deletions gc/base/GlobalCollector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ class MM_GlobalCollector : public MM_Collector {
}

virtual void yield(MM_EnvironmentBase *env) {};

virtual bool isStwCollectionInProgress()
{
return false;
}

/**
* Perform any collector-specific initialization.
Expand Down
11 changes: 3 additions & 8 deletions gc/base/standard/ConcurrentGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ MM_ConcurrentGC::tuneToHeap(MM_EnvironmentBase *env)
*/
if(0 == heapSize) {
Trc_MM_ConcurrentGC_tuneToHeap_Exit1(env->getLanguageVMThread());
assume0(!_stwCollectionInProgress);
Assert_MM_true(!_stwCollectionInProgress);
return;
}

Expand Down Expand Up @@ -2922,11 +2922,7 @@ MM_ConcurrentGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *

/* Ensure caller acquired exclusive VM access before calling */
Assert_MM_mustHaveExclusiveVMAccess(env->getOmrVMThread());

/* Set flag to show STW collector is active; some operations need to know if they
* are called during a global collect or not, eg heapAddRange
*/
_stwCollectionInProgress = true;
Assert_MM_true(_stwCollectionInProgress);

/* Assume for now we will need to initialize the mark map. If we subsequenly find
* we got far enough through the concurrent mark cycle then we will reset this flag
Expand Down Expand Up @@ -3155,7 +3151,6 @@ MM_ConcurrentGC::internalPostCollect(MM_EnvironmentBase *env, MM_MemorySubSpace
}

/* Collection is complete so reset flags */
_stwCollectionInProgress = false;
_forcedKickoff = false;
_stats.clearKickoffReason();

Expand Down Expand Up @@ -3325,7 +3320,7 @@ MM_ConcurrentGC::heapReconfigured(MM_EnvironmentBase *env, HeapReconfigReason re
*
* It is necessary that _rebuildInitWorkForAdd is set when we're here during an expand (after heapAddRange), or
* _rebuildInitWorkForRemove in the case of contract. However, it is not a sufficient check to ensure the reason we're
* here. For instance, when Concurent is on, _rebuildInitWorkForAdd will be set but not cleared.
* here. For instance, when Concurrent is on, _rebuildInitWorkForAdd will be set but not cleared.
* As a result, we can have multiple calls of expands interleaved with contracts, resulting in both flags being set.
* Similarly, we can end up here after scavenger tilt with any of the flags set.
*/
Expand Down
12 changes: 1 addition & 11 deletions gc/base/standard/ConcurrentGC.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2018 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 @@ -200,7 +200,6 @@ class MM_ConcurrentGC : public MM_ParallelGlobalGC
volatile uint32_t _conHelpersShutdownCount;
omrthread_monitor_t _conHelpersActivationMonitor;

bool _stwCollectionInProgress; /**< if set, the final STW phase is in progress (mutators not running) */
bool _initializeMarkMap;
omrthread_monitor_t _initWorkMonitor;
omrthread_monitor_t _initWorkCompleteMonitor;
Expand Down Expand Up @@ -460,14 +459,6 @@ class MM_ConcurrentGC : public MM_ParallelGlobalGC
}
}

/*
* Return value of _stwCollectionInProgress flag
*/
virtual bool isStwCollectionInProgress()
{
return _stwCollectionInProgress;
}

/**
* Return reference to Card Table
*/
Expand All @@ -494,7 +485,6 @@ class MM_ConcurrentGC : public MM_ParallelGlobalGC
,_conHelpersStarted(0)
,_conHelpersShutdownCount(0)
,_conHelpersActivationMonitor(NULL)
,_stwCollectionInProgress(false)
,_initializeMarkMap(false)
,_initWorkMonitor(NULL)
,_initWorkCompleteMonitor(NULL)
Expand Down

0 comments on commit e93965e

Please sign in to comment.