Qutex: Add gridlock detection wireframing

This is the basic wireframing required to enable us to detect
gridlocks among requests.
This commit is contained in:
2025-09-29 12:58:41 -04:00
parent 0090aa6e3a
commit 6b4fe05fc0
2 changed files with 25 additions and 3 deletions
+14 -3
View File
@@ -99,13 +99,16 @@ public:
Qutex *firstFailedQutexPtr = nullptr; Qutex *firstFailedQutexPtr = nullptr;
bool deadlockLikely = isDeadlockLikely(); bool deadlockLikely = isDeadlockLikely();
bool gridlockLikely = isGridlockLikely();
if (!serializedContinuation.requiredLocks.tryAcquireOrBackOff( if (!serializedContinuation.requiredLocks.tryAcquireOrBackOff(
*this, (deadlockLikely ? &firstFailedQutexPtr : nullptr))) *this,
((deadlockLikely || gridlockLikely)
? &firstFailedQutexPtr : nullptr)))
{ {
// Just allow this lockvoker to be dropped from its io_service. // Just allow this lockvoker to be dropped from its io_service.
allowAwakening(); allowAwakening();
if (!deadlockLikely) if (!deadlockLikely && !gridlockLikely)
{ return; } { return; }
#ifdef CONFIG_ENABLE_DEBUG_LOCKS #ifdef CONFIG_ENABLE_DEBUG_LOCKS
@@ -113,7 +116,10 @@ public:
bool isDeadlock = traceContinuationHistoryForDeadlockOn( bool isDeadlock = traceContinuationHistoryForDeadlockOn(
firstFailedQutex); firstFailedQutex);
if (!isDeadlock) bool isGridlock = traceContinuationHistoryForGridlockOn(
firstFailedQutex);
if (!isDeadlock && !isGridlock)
{ return; } { return; }
handleDeadlock(firstFailedQutex); handleDeadlock(firstFailedQutex);
@@ -202,8 +208,13 @@ public:
#endif #endif
} }
// Wrapper around isDeadlockLikely for gridlock detection
bool isGridlockLikely() const
{ return isDeadlockLikely(); }
#ifdef CONFIG_ENABLE_DEBUG_LOCKS #ifdef CONFIG_ENABLE_DEBUG_LOCKS
bool traceContinuationHistoryForDeadlockOn(Qutex &firstFailedQutex); bool traceContinuationHistoryForDeadlockOn(Qutex &firstFailedQutex);
bool traceContinuationHistoryForGridlockOn(Qutex &firstFailedQutex);
bool traceContinuationHistoryForDeadlock(void) bool traceContinuationHistoryForDeadlock(void)
{ {
for (auto& lockUsageDesc for (auto& lockUsageDesc
@@ -57,6 +57,17 @@ SerializedAsynchronousContinuation<OriginalCbFnT>
return false; return false;
} }
template <class OriginalCbFnT>
template <class InvocationTargetT>
bool
SerializedAsynchronousContinuation<OriginalCbFnT>
::LockerAndInvoker<InvocationTargetT>
::traceContinuationHistoryForGridlockOn(Qutex &firstFailedQutex)
{
// Empty implementation - to be filled in later
return false;
}
template <class OriginalCbFnT> template <class OriginalCbFnT>
template <class InvocationTargetT> template <class InvocationTargetT>
void void