QtxAcqHistTracker: implement heuristic gridlock detector
This commit is contained in:
@@ -106,7 +106,9 @@ public:
|
||||
}
|
||||
|
||||
bool heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||
Qutex &firstFailedQutex) const;
|
||||
Qutex &firstFailedQutex,
|
||||
std::shared_ptr<AsynchronousContinuationChainLink>& currentContinuation)
|
||||
const;
|
||||
bool completelyTraceContinuationHistoryForGridlockOn(
|
||||
Qutex &firstFailedQutex) const;
|
||||
|
||||
|
||||
@@ -134,13 +134,16 @@ public:
|
||||
.getAcquiredQutexHistory();
|
||||
|
||||
// Add this continuation to the tracker
|
||||
auto currentContinuationShPtr = serializedContinuation
|
||||
.shared_from_this();
|
||||
|
||||
tracker.addIfNotExists(
|
||||
serializedContinuation.shared_from_this(),
|
||||
currentContinuationShPtr,
|
||||
firstFailedQutex, std::move(heldLocks));
|
||||
|
||||
gridlockIsHeuristicallyLikely = tracker
|
||||
.heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||
firstFailedQutex);
|
||||
firstFailedQutex, currentContinuationShPtr);
|
||||
|
||||
if (gridlockIsHeuristicallyLikely)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,9 @@ namespace smo {
|
||||
*/
|
||||
|
||||
bool QutexAcquisitionHistoryTracker
|
||||
::heuristicallyTraceContinuationHistoryForGridlockOn(Qutex &firstFailedQutex)
|
||||
::heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||
Qutex &firstFailedQutex,
|
||||
std::shared_ptr<AsynchronousContinuationChainLink>& currentContinuation)
|
||||
const
|
||||
{
|
||||
/** HEURISTIC APPROACH:
|
||||
@@ -80,6 +82,34 @@ const
|
||||
* explanation.
|
||||
*/
|
||||
|
||||
// Iterate through all entries in the acquisition history
|
||||
for (const auto& entry : acquisitionHistory) {
|
||||
const auto& continuation = entry.first;
|
||||
const auto& historyEntry = entry.second;
|
||||
|
||||
// Skip the current continuation (don't compare with itself)
|
||||
if (continuation == currentContinuation) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if firstFailedQutex is in this continuation's held locks
|
||||
const std::unique_ptr<std::forward_list<std::reference_wrapper<Qutex>>>&
|
||||
heldLocks = historyEntry.second;
|
||||
|
||||
if (!heldLocks)
|
||||
{ continue; }
|
||||
|
||||
for (const auto& heldLock : *heldLocks)
|
||||
{
|
||||
/* Found firstFailedQutex in another continuation's held locks
|
||||
* This indicates a potential gridlock
|
||||
*/
|
||||
if (&heldLock.get() == &firstFailedQutex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user