Make spinlock stack per-CPU
This commit is contained in:
parent
4ce2388ef2
commit
d5535ded23
@ -119,6 +119,7 @@ void Machine_SyscallInit()
|
||||
|
||||
void Machine_EarlyInit()
|
||||
{
|
||||
Spinlock_EarlyInit();
|
||||
Critical_Init();
|
||||
Critical_Enter();
|
||||
Console_Init();
|
||||
|
@ -21,10 +21,20 @@ Spinlock lockListLock = {
|
||||
};
|
||||
LIST_HEAD(LockListHead, Spinlock) lockList = LIST_HEAD_INITIALIZER(lockList);
|
||||
|
||||
TAILQ_HEAD(LockStack, Spinlock) lockStack = TAILQ_HEAD_INITIALIZER(lockStack);
|
||||
TAILQ_HEAD(LockStack, Spinlock) lockStack[MAX_CPUS];
|
||||
|
||||
extern uint64_t ticksPerSecond;
|
||||
|
||||
void
|
||||
Spinlock_EarlyInit()
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < MAX_CPUS; c++) {
|
||||
TAILQ_INIT(&lockStack[c]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Spinlock_Init(Spinlock *lock, const char *name, uint64_t type)
|
||||
{
|
||||
@ -77,13 +87,13 @@ Spinlock_Lock(Spinlock *lock)
|
||||
if (lock->rCount == 1)
|
||||
lock->lockedTSC = Time_GetTSC();
|
||||
|
||||
TAILQ_INSERT_TAIL(&lockStack, lock, lockStack);
|
||||
TAILQ_INSERT_TAIL(&lockStack[CPU()], lock, lockStack);
|
||||
}
|
||||
|
||||
void
|
||||
Spinlock_Unlock(Spinlock *lock)
|
||||
{
|
||||
TAILQ_REMOVE(&lockStack, lock, lockStack);
|
||||
TAILQ_REMOVE(&lockStack[CPU()], lock, lockStack);
|
||||
|
||||
lock->rCount--;
|
||||
if (lock->rCount == 0) {
|
||||
@ -124,10 +134,11 @@ REGISTER_DBGCMD(spinlocks, "Display list of spinlocks", Debug_Spinlocks);
|
||||
void
|
||||
Debug_LockStack(int argc, const char *argv[])
|
||||
{
|
||||
int c = CPU();
|
||||
Spinlock *lock;
|
||||
|
||||
kprintf("Lock Stack:\n");
|
||||
TAILQ_FOREACH(lock, &lockStack, lockStack) {
|
||||
TAILQ_FOREACH(lock, &lockStack[c], lockStack) {
|
||||
kprintf(" %s\n", lock->name);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user