mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added StackPointer* for lock
This commit is contained in:
parent
4454181448
commit
07738ddb0a
@ -21,10 +21,12 @@ void LockClass::DeadLock(SpinLockData Lock)
|
|||||||
long CCore = 0xdead;
|
long CCore = 0xdead;
|
||||||
if (CoreData != nullptr)
|
if (CoreData != nullptr)
|
||||||
CCore = CoreData->ID;
|
CCore = CoreData->ID;
|
||||||
warn("Potential deadlock in lock '%s' held by '%s'! %ld locks in queue. Core %ld is being held by %ld. (%ld times happened)",
|
|
||||||
|
warn("Potential deadlock in lock '%s' held by '%s'! %ld %s in queue. Interrupts are %s. Core %ld is being held by %ld. (%ld times happened)",
|
||||||
Lock.AttemptingToGet, Lock.CurrentHolder,
|
Lock.AttemptingToGet, Lock.CurrentHolder,
|
||||||
Lock.Count, CCore, Lock.Core,
|
Lock.Count, Lock.Count > 1 ? "locks" : "lock",
|
||||||
this->DeadLocks);
|
CPU::Interrupts(CPU::Check) ? "enabled" : "disabled",
|
||||||
|
CCore, Lock.Core, this->DeadLocks);
|
||||||
|
|
||||||
// TODO: Print on screen too.
|
// TODO: Print on screen too.
|
||||||
|
|
||||||
@ -44,6 +46,7 @@ void LockClass::DeadLock(SpinLockData Lock)
|
|||||||
int LockClass::Lock(const char *FunctionName)
|
int LockClass::Lock(const char *FunctionName)
|
||||||
{
|
{
|
||||||
LockData.AttemptingToGet = FunctionName;
|
LockData.AttemptingToGet = FunctionName;
|
||||||
|
LockData.StackPointerAttempt = (uintptr_t)__builtin_frame_address(0);
|
||||||
Retry:
|
Retry:
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while (IsLocked.Exchange(true, MemoryOrder::Acquire) && ++i < 0x10000000)
|
while (IsLocked.Exchange(true, MemoryOrder::Acquire) && ++i < 0x10000000)
|
||||||
@ -55,6 +58,7 @@ Retry:
|
|||||||
}
|
}
|
||||||
LockData.Count++;
|
LockData.Count++;
|
||||||
LockData.CurrentHolder = FunctionName;
|
LockData.CurrentHolder = FunctionName;
|
||||||
|
LockData.StackPointerHolder = (uintptr_t)__builtin_frame_address(0);
|
||||||
CPUData *CoreData = GetCurrentCPU();
|
CPUData *CoreData = GetCurrentCPU();
|
||||||
if (CoreData != nullptr)
|
if (CoreData != nullptr)
|
||||||
LockData.Core = CoreData->ID;
|
LockData.Core = CoreData->ID;
|
||||||
@ -79,10 +83,12 @@ void LockClass::TimeoutDeadLock(SpinLockData Lock, uint64_t Timeout)
|
|||||||
long CCore = 0xdead;
|
long CCore = 0xdead;
|
||||||
if (CoreData != nullptr)
|
if (CoreData != nullptr)
|
||||||
CCore = CoreData->ID;
|
CCore = CoreData->ID;
|
||||||
warn("Potential deadlock in lock '%s' held by '%s'! %ld locks in queue. Core %ld is being held by %ld. Timeout in %ld",
|
|
||||||
|
warn("Potential deadlock in lock '%s' held by '%s'! %ld %s in queue. Interrupts are %s. Core %ld is being held by %ld. Timeout in %ld",
|
||||||
Lock.AttemptingToGet, Lock.CurrentHolder,
|
Lock.AttemptingToGet, Lock.CurrentHolder,
|
||||||
Lock.Count, CCore, Lock.Core,
|
Lock.Count, Lock.Count > 1 ? "locks" : "lock",
|
||||||
Timeout);
|
CPU::Interrupts(CPU::Check) ? "enabled" : "disabled",
|
||||||
|
CCore, Lock.Core, this->DeadLocks, Timeout);
|
||||||
|
|
||||||
// TODO: Print on screen too.
|
// TODO: Print on screen too.
|
||||||
|
|
||||||
@ -100,6 +106,7 @@ void LockClass::TimeoutDeadLock(SpinLockData Lock, uint64_t Timeout)
|
|||||||
int LockClass::TimeoutLock(const char *FunctionName, uint64_t Timeout)
|
int LockClass::TimeoutLock(const char *FunctionName, uint64_t Timeout)
|
||||||
{
|
{
|
||||||
LockData.AttemptingToGet = FunctionName;
|
LockData.AttemptingToGet = FunctionName;
|
||||||
|
LockData.StackPointerAttempt = (uintptr_t)__builtin_frame_address(0);
|
||||||
Atomic<uint64_t> Target = 0;
|
Atomic<uint64_t> Target = 0;
|
||||||
Retry:
|
Retry:
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
@ -114,6 +121,7 @@ Retry:
|
|||||||
}
|
}
|
||||||
LockData.Count++;
|
LockData.Count++;
|
||||||
LockData.CurrentHolder = FunctionName;
|
LockData.CurrentHolder = FunctionName;
|
||||||
|
LockData.StackPointerHolder = (uintptr_t)__builtin_frame_address(0);
|
||||||
CPUData *CoreData = GetCurrentCPU();
|
CPUData *CoreData = GetCurrentCPU();
|
||||||
if (CoreData != nullptr)
|
if (CoreData != nullptr)
|
||||||
LockData.Core = CoreData->ID;
|
LockData.Core = CoreData->ID;
|
||||||
|
@ -19,6 +19,8 @@ class LockClass
|
|||||||
Atomic<uint64_t> LockData = 0x0;
|
Atomic<uint64_t> LockData = 0x0;
|
||||||
Atomic<const char *> CurrentHolder = "(nul)";
|
Atomic<const char *> CurrentHolder = "(nul)";
|
||||||
Atomic<const char *> AttemptingToGet = "(nul)";
|
Atomic<const char *> AttemptingToGet = "(nul)";
|
||||||
|
Atomic<uintptr_t> StackPointerHolder = 0;
|
||||||
|
Atomic<uintptr_t> StackPointerAttempt = 0;
|
||||||
Atomic<size_t> Count = 0;
|
Atomic<size_t> Count = 0;
|
||||||
Atomic<long> Core = 0;
|
Atomic<long> Core = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user