QtxAcqHistTracker: implement heuristic gridlock detector
This commit is contained in:
@@ -106,7 +106,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool heuristicallyTraceContinuationHistoryForGridlockOn(
|
bool heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||||
Qutex &firstFailedQutex) const;
|
Qutex &firstFailedQutex,
|
||||||
|
std::shared_ptr<AsynchronousContinuationChainLink>& currentContinuation)
|
||||||
|
const;
|
||||||
bool completelyTraceContinuationHistoryForGridlockOn(
|
bool completelyTraceContinuationHistoryForGridlockOn(
|
||||||
Qutex &firstFailedQutex) const;
|
Qutex &firstFailedQutex) const;
|
||||||
|
|
||||||
|
|||||||
@@ -134,13 +134,16 @@ public:
|
|||||||
.getAcquiredQutexHistory();
|
.getAcquiredQutexHistory();
|
||||||
|
|
||||||
// Add this continuation to the tracker
|
// Add this continuation to the tracker
|
||||||
|
auto currentContinuationShPtr = serializedContinuation
|
||||||
|
.shared_from_this();
|
||||||
|
|
||||||
tracker.addIfNotExists(
|
tracker.addIfNotExists(
|
||||||
serializedContinuation.shared_from_this(),
|
currentContinuationShPtr,
|
||||||
firstFailedQutex, std::move(heldLocks));
|
firstFailedQutex, std::move(heldLocks));
|
||||||
|
|
||||||
gridlockIsHeuristicallyLikely = tracker
|
gridlockIsHeuristicallyLikely = tracker
|
||||||
.heuristicallyTraceContinuationHistoryForGridlockOn(
|
.heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||||
firstFailedQutex);
|
firstFailedQutex, currentContinuationShPtr);
|
||||||
|
|
||||||
if (gridlockIsHeuristicallyLikely)
|
if (gridlockIsHeuristicallyLikely)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ namespace smo {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool QutexAcquisitionHistoryTracker
|
bool QutexAcquisitionHistoryTracker
|
||||||
::heuristicallyTraceContinuationHistoryForGridlockOn(Qutex &firstFailedQutex)
|
::heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||||
|
Qutex &firstFailedQutex,
|
||||||
|
std::shared_ptr<AsynchronousContinuationChainLink>& currentContinuation)
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
/** HEURISTIC APPROACH:
|
/** HEURISTIC APPROACH:
|
||||||
@@ -80,6 +82,34 @@ const
|
|||||||
* explanation.
|
* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user